PARSER_BEGIN(Exp) public class Exp { public static void main(String args[]) throws ParseException { Exp parser = new Exp(System.in); parser.ExpressionList(); } } PARSER_END(Exp) SKIP : { " " | "\t" | "\n" | "\r" } TOKEN : { < ID: ["a"-"z","A"-"Z"] ( ["a"-"z","A"-"Z","0"-"9"] )* > | < NUM: ( ["0"-"9"] )+ > } void ExpressionList() : { String s; } { { System.out.println( "Please type in an expression followed by a \";\" or ^D to quit:"); System.out.println(""); } ( Expression() ";" )* } void Expression() : { } { Term() ( "+" Term() )* } void Term() : { } { Factor() ( "*" Factor() )* } void Factor() : { Token t; String s; } { t= { System.out.println("Just read a " +t.image); } | t= { System.out.println("Just read a " + t.image); } | "(" Expression() ")" { System.out.println("Just read a parenthesized expression"); } }