Results 1 to 3 of 3

Thread: Problem With Java

  1. #1
    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

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    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.
       }

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    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.");
            }

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,558,576.33581 seconds with 16 queries