/* throws ParseException */ /* final */ public static AstStmtList astStmtList() { AstStmt s; AstStmtList sl = new AstStmtList(); bool done = false; jj_consume_token(AstRegExpId.kw56); jj_consume_token(AstRegExpId.kwStmtList); //label_5: while (!done) { switch ((jj_ntk == AstRegExpId.UNDEFINED)?jj_ntk_fn():jj_ntk) { case AstRegExpId.kw56: break; default: jj_la1[4] = jj_gen; done = true; break /* label_5 */; } if (!done) { s = astStmt(); sl.Add(s); } } jj_consume_token(AstRegExpId.kw57); {if (true) return sl;} throw new Error("Missing return statement in function"); }
/* throws ParseException */ // ----------------------------------------------------------------------------- // "public" (Type | "void") <ID> "(" [Formals] ")" "{" {VarDecl} {Statement} "}" // ----------------------------------------------------------------------------- /* final */ public static AstMethodDecl MethodDecl() { DemiTasse.ast.AstType t = null; AstId id; AstFormalList fl = null; AstVarDecl v; AstVarDeclList vl = new AstVarDeclList(); AstStmt s; AstStmtList sl = new AstStmtList(); jj_consume_token(MpRegExpId.PUBLIC); switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk) { case MpRegExpId.VOID: jj_consume_token(MpRegExpId.VOID); break; case MpRegExpId.BOOLEAN: t = Type(); break; case MpRegExpId.INT: t = Type(); break; case MpRegExpId.ID: t = Type(); break; default: jj_la1[7] = jj_gen; jj_consume_token(MpRegExpId.UNDEFINED); throw new MiniParseException(); } id = Id(); jj_consume_token(MpRegExpId.LPAREN); switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk) { case MpRegExpId.BOOLEAN: fl = Formals(); break; case MpRegExpId.INT: fl = Formals(); break; case MpRegExpId.ID: fl = Formals(); break; default: jj_la1[8] = jj_gen; break; } jj_consume_token(MpRegExpId.RPAREN); jj_consume_token(MpRegExpId.LBRACE); /* label_8: */ while (jj_2_2(2)) { v = VarDecl(); vl.Add(v); } /* label_9:*/ bool done = false; while (!done) { switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk) { case MpRegExpId.IF: break; case MpRegExpId.RETURN: break; case MpRegExpId.SYSTEM_OUT_PRINTLN: break; case MpRegExpId.THIS: break; case MpRegExpId.WHILE: break; case MpRegExpId.ID: break; case MpRegExpId.LBRACE: break; default: jj_la1[9] = jj_gen; done = true; break /* label_9 */; } if (!done) { s = Statement(); sl.Add(s); } } jj_consume_token(MpRegExpId.RBRACE); return new AstMethodDecl( t, id, fl, vl, sl ); }
/* throws ParseException */ // -------------------------------------------------------------------------- // BlockStmt -> <LBRACE> ( Statement() )* <RBRACE> // -------------------------------------------------------------------------- /* final */ public static AstBlock BlockStmt() { AstStmt s = null; AstStmtList sl = new AstStmtList(); jj_consume_token( MpRegExpId.LBRACE); /* label_11: */ bool done = false; while (!done) { switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk) { case MpRegExpId.IF: break; case MpRegExpId.RETURN: break; case MpRegExpId.SYSTEM_OUT_PRINTLN: break; case MpRegExpId.THIS: break; case MpRegExpId.WHILE: break; case MpRegExpId.ID: break; case MpRegExpId.LBRACE: break; default: jj_la1[16] = jj_gen; done = true; break /* label_11 */; } if (!done) { s = Statement(); sl.Add(s); } } jj_consume_token(MpRegExpId.RBRACE); return new AstBlock( sl ); }
/* throws ParseException */ /// <summary> /// MainMethod -> "public" "static" "void" "main" "(" "String" "[" "]" <ID> ")" "{" {VarDecl} {Statement} "}" /// </summary> /// <returns></returns> /* final */ public static AstMethodDecl MainMethod() { DemiTasse.ast.AstType t = null; AstId id = new AstId( "main" ); AstFormalList fl = null; AstVarDecl v; AstVarDeclList vl = new AstVarDeclList(); AstStmt s; AstStmtList sl = new AstStmtList(); bool done; jj_consume_token(MpRegExpId.PUBLIC); jj_consume_token(MpRegExpId.STATIC); jj_consume_token(MpRegExpId.VOID); jj_consume_token(MpRegExpId.MAIN); jj_consume_token(MpRegExpId.LPAREN); jj_consume_token(MpRegExpId.STRING); jj_consume_token(MpRegExpId.LBRACKET); jj_consume_token(MpRegExpId.RBRACKET); jj_consume_token(MpRegExpId.ID); jj_consume_token(MpRegExpId.RPAREN); jj_consume_token(MpRegExpId.LBRACE); /* label_6: */ while (jj_2_1(2)) { v = VarDecl(); vl.Add(v); } /* label_7: */ done = false; while (!done) { switch ((jj_ntk == MpRegExpId.UNDEFINED) ? jj_ntk_fn() : jj_ntk) { case MpRegExpId.IF: break; case MpRegExpId.RETURN: break; case MpRegExpId.SYSTEM_OUT_PRINTLN: break; case MpRegExpId.THIS: break; case MpRegExpId.WHILE: break; case MpRegExpId.ID: break; case MpRegExpId.LBRACE: break; default: jj_la1[6] = jj_gen; done = true; break /* label_7 */; } if(!done) { s = Statement(); sl.Add(s); } } jj_consume_token(MpRegExpId.RBRACE); return new AstMethodDecl( t, id, fl, vl, sl ); }