options { IGNORE_CASE=true; DEBUG_PARSER=false; MULTI=true; // This will generate one AST class for each non-suppressed non-terminal JJTREE_OUTPUT_DIRECTORY="AST"; // This will put all your AST classes in the AST directory VISITOR=true; // This is needed to create the visitor infrastructure } PARSER_BEGIN(HL) public class HL { } PARSER_END(HL) TOKEN_MGR_DECLS : { } SKIP : { " " | "\t" | "\n" | "\r" } TOKEN : { < #DIGIT: ["0"-"9"]> | < INTEGER: ()+ > } // =========================================================================== // P A R S E R // =========================================================================== SimpleNode start () #void : {} { expression() ";" { return (SimpleNode) (jjtree.popNode()); } | < EOF > {throw new ParseException("End of File.");} } void expression() #void: {} { (term() ("+" term())*) #sum(>1) } void term() #void : {} { (simpleterm() ("*" simpleterm())*) #prod(>1) } void simpleterm() #void : {} { Integer() | "(" expression() ")" } void Integer () : {Token t;} { t= {jjtThis.jjtSetValue(t.getValue());} }