/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. HL.jj */ /*@egen*/options { IGNORE_CASE=true; DEBUG_PARSER=false; // This is needed to create the visitor infrastructure } PARSER_BEGIN(HL) public class HL/*@bgen(jjtree)*/implements HLTreeConstants/*@egen*/ {/*@bgen(jjtree)*/ protected static JJTHLState jjtree = new JJTHLState(); /*@egen*/ } PARSER_END(HL) TOKEN_MGR_DECLS : { } SKIP : { " " | "\t" | "\n" | "\r" } TOKEN : { < #DIGIT: ["0"-"9"]> | < INTEGER: ()+ > } // =========================================================================== // P A R S E R // =========================================================================== SimpleNode start () : {} { expression() ";" { return (SimpleNode) (jjtree.popNode()); } | < EOF > {throw new ParseException("End of File.");} } void expression() : {} {/*@bgen(jjtree) #sum(> 1) */ { ASTsum jjtn001 = new ASTsum(JJTSUM); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ (term() ("+" term())*)/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1); } } /*@egen*/ } void term() : {} {/*@bgen(jjtree) #prod(> 1) */ { ASTprod jjtn001 = new ASTprod(JJTPROD); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); } try { /*@egen*/ (simpleterm() ("*" simpleterm())*)/*@bgen(jjtree)*/ } catch (Throwable jjte001) { if (jjtc001) { jjtree.clearNodeScope(jjtn001); jjtc001 = false; } else { jjtree.popNode(); } if (jjte001 instanceof RuntimeException) { throw (RuntimeException)jjte001; } if (jjte001 instanceof ParseException) { throw (ParseException)jjte001; } throw (Error)jjte001; } finally { if (jjtc001) { jjtree.closeNodeScope(jjtn001, jjtree.nodeArity() > 1); } } /*@egen*/ } void simpleterm() : {} { Integer() | "(" expression() ")" } void Integer () : {/*@bgen(jjtree) Integer */ ASTInteger jjtn000 = new ASTInteger(JJTINTEGER); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); /*@egen*/Token t;} {/*@bgen(jjtree) Integer */ try { /*@egen*/ t=/*@bgen(jjtree)*/ { jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; } /*@egen*/ {jjtn000.jjtSetValue(t.getValue());}/*@bgen(jjtree)*/ } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } /*@egen*/ }