// // parser skeleton, CS 480, Winter 2004 // written by Tim Budd // modified by: // public class Parser { private Lexer lex; private boolean debug; public Parser (Lexer l, boolean d) { lex = l; debug = d; } public void parse () throws ParseException { lex.nextLex(); program(); if (lex.tokenCategory() != lex.endOfInput) parseError(3); // expecting end of file } private final void start (String n) { if (debug) System.out.println("start " + n + " token: " + lex.tokenText()); } private final void stop (String n) { if (debug) System.out.println("recognized " + n + " token: " + lex.tokenText()); } private void parseError(int number) throws ParseException { throw new ParseException(number); } private void program () throws ParseException { start("program"); while (lex.tokenCategory() != Lexer.endOfInput) declaration(); stop("program"); } // your stuff goes here }