options { IGNORE_CASE=true; MULTI=true; // This will generate one AST class for each non-suppressed non-terminal VISITOR=true; // This won't be used until the next assignment, but will be needed to make your assignment compile properly JJTREE_OUTPUT_DIRECTORY="AST"; // This will put all your AST classes in the AST directory } PARSER_BEGIN(HL) public class HL { } PARSER_END(HL) TOKEN_MGR_DECLS : { } SKIP : { " " | "\t" | "\n" | "\r" } TOKEN : { < PRINT:"PRINT"> | < ERR:"ERR"> | < INTEGER: (["0"-"9"])+ > } // =========================================================================== // P A R S E R // =========================================================================== SimpleNode start () : {} { statement() { return (SimpleNode) (jjtree.popNode()); } | < EOF > {throw new ParseException("End of File.");} } void statement() : {} { assignment() ";" | print_stat() ";" } void assignment () : {} { Identifier() "=" expression() } void print_stat() : {} { (print_stdout() | print_stderr()) } void print_stdout() : {} { expression() } void print_stderr(): {} { expression() } void expression() : {} { product() ("+" product())* } void product() : {} { term() ("*" term())* } void term() : {} { Identifier() | Integer() } void Identifier() #void : {} { "a" #a | "b" #b | "c" #c } void Integer () : {Token t;} { t= {jjtThis.jjtSetValue(t.getValue());} }