Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 17-03-2009
Member
 
Join Date: Jan 2009
Posts: 69
Problem With Java

I am not a good programmer in java but can anyone of you provide some examples regarding lexical analysis in java and syntactical analysis in java
Reply With Quote
  #2  
Old 17-03-2009
Member
 
Join Date: May 2008
Posts: 2,383
Re: Problem With Java

Code:
Color getColor(String name) {
    String data;
      StringTokenizer st;
      int red, green, blue;
    
     data = getParameter(name);
       if (data == null)
         return null;
          
      st = new StringTokenizer(data, ",");
       try {
        red = Integer.parseInt(st.nextToken());
           green = Integer.parseInt(st.nextToken());
           blue = Integer.parseInt(st.nextToken());
      } catch (Exception e) {
         return null; // (ERROR STATE) could not parse it
       }
       return new Color(red, green, blue); // (END STATE) done.
   }
Reply With Quote
  #3  
Old 17-03-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: Problem With Java

Code:
while (true) {
           Expression res;
        int c = StreamTokenizer.TT_EOL;
            String varName = null;

         System.out.println("Enter an expression...");
            try {
             while (true) {
                 c = st.nextToken();
                 if (c == StreamTokenizer.TT_EOF) {
                      System.exit(1);
                 } else if (c == StreamTokenizer.TT_EOL) {
                       continue;
                 } else if (c == StreamTokenizer.TT_WORD) {
                 if (st.sval.compareTo("dump") == 0) {
                          dumpVariables(variables);
                     continue;
                      } else if (st.sval.compareTo("clear") == 0) {
                         variables = new Hashtable();
                          continue;
                     } else if (st.sval.compareTo("quit") == 0) {
                       System.exit(0);
                      } else if (st.sval.compareTo("exit") == 0) {
                          System.exit(0);
                     } else if (st.sval.compareTo("help") == 0) {
                            help();
                         continue;
                     }
                      varName = st.sval;
                    c = st.nextToken();
             }
                  break;
            }
            if (c != '=') {
                   throw new SyntaxError("missing initial '=' sign.");
        }
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Problem With Java"
Thread Thread Starter Forum Replies Last Post
Java JDK problem Samara Software Development 6 19-07-2010 01:02 PM
Problem with IE7 after upgrade to Java 1.6 matchbox44471 Windows Software 9 09-06-2010 12:49 AM
Problem in java.io.IOException GlassFish Software Development 4 25-02-2010 03:31 AM
Java Problem suhjonathan Windows Software 5 12-11-2009 09:48 AM
Java keylistener problem ANSEL Software Development 3 26-08-2009 09:13 PM


All times are GMT +5.5. The time now is 10:59 AM.