Compiler Construction with ANTLR and Java
By Gary L. Schaps
Dr. Dobb's Journal March 1999
// ... parse the file ... public static void parseFile(InputStream s, String fname) throws Exception { try { // Create a scanner that reads from the input stream KPLLexer lexer = new KPLLexer(s); // Create a parser that reads from the scanner KPLParser parser = new KPLParser(lexer); parser.setCurrentFile(fname); // start parsing at the compilationUnit rule parser.compilationUnit(); ...
Example 2: Starting the parser.
Copyright © 1999, Dr. Dobb's Journal