Calling the main production (excerpt from main()).

Power Java
Parsing With JavaCC
by Steve Kapp
Listing 5. Calling the main production (excerpt from main()).


01    PSParser parser = new PSParser(new
                  FileInputStream(args[0]));
02    try {
03        while (true) {
04            PSObject objectToExecute;
05            // Have we reached EOF?
06            if (parser.translationUnit(parser.m_environment)
                                == false) {
07                break;
08            }
09            // Execute the object if present.
10            objectToExecute =
                    parser.m_environment.getCurrentObject();
11            if (objectToExecute != null) {
12                objectToExecute.execute(parser.m_environment);
13            }
14        }
15    }
16    catch (ParseException e) {
17        System.out.println(e);
18        System.exit(3);
19    }

About the Author

Steve Kapp is a client partner at EMRT in Rochester, NY. Steve can be contacted at [email protected].