private ISCNode statement() { EnterRule_statement(); EnterRule("statement", 9); TraceIn("statement", 9); ISCNode node = default(ISCNode); ISCNode st = default(ISCNode); VarDefNode varDef17 = default(VarDefNode); IExprNode expression18 = default(IExprNode); try { DebugEnterRule(GrammarFileName, "statement"); DebugLocation(91, 0); try { // Grammar\\SimpleCTreeWalker.g:91:33: ( varDef | STATEMENT | ^( STATEMENT expression ) | ^( STATEMENT (st= statement )+ ) ) int alt7=4; try { DebugEnterDecision(7, false); int LA7_0 = input.LA(1); if ((LA7_0==VAR_DEF)) { alt7 = 1; } else if ((LA7_0==STATEMENT)) { int LA7_2 = input.LA(2); if ((LA7_2==DOWN)) { int LA7_3 = input.LA(3); if (((LA7_3>=ADD && LA7_3<=BIT_AND)||(LA7_3>=BIT_OR && LA7_3<=BOOL_AND)||LA7_3==BOOL_OR||(LA7_3>=DIV && LA7_3<=EQUAL)||LA7_3==FUNC_CALL||(LA7_3>=GREATER && LA7_3<=IDENT)||LA7_3==INTEGER||(LA7_3>=LESS && LA7_3<=NOT_EQUAL)||(LA7_3>=SHIFT_LEFT && LA7_3<=SHIFT_RIGHT)||LA7_3==SUB)) { alt7 = 3; } else if ((LA7_3==STATEMENT||LA7_3==VAR_DEF)) { alt7 = 4; } else { NoViableAltException nvae = new NoViableAltException("", 7, 3, input); DebugRecognitionException(nvae); throw nvae; } } else if ((LA7_2==UP||LA7_2==STATEMENT||LA7_2==VAR_DEF)) { alt7 = 2; } else { NoViableAltException nvae = new NoViableAltException("", 7, 2, input); DebugRecognitionException(nvae); throw nvae; } } else { NoViableAltException nvae = new NoViableAltException("", 7, 0, input); DebugRecognitionException(nvae); throw nvae; } } finally { DebugExitDecision(7); } switch (alt7) { case 1: DebugEnterAlt(1); // Grammar\\SimpleCTreeWalker.g:92:2: varDef { DebugLocation(92, 2); PushFollow(Follow._varDef_in_statement315); varDef17=varDef(); PopFollow(); DebugLocation(92, 9); node = varDef17; } break; case 2: DebugEnterAlt(2); // Grammar\\SimpleCTreeWalker.g:93:4: STATEMENT { DebugLocation(93, 4); Match(input,STATEMENT,Follow._STATEMENT_in_statement322); DebugLocation(93, 14); node = new CompoundStatementNode(); } break; case 3: DebugEnterAlt(3); // Grammar\\SimpleCTreeWalker.g:94:4: ^( STATEMENT expression ) { DebugLocation(94, 4); DebugLocation(94, 6); Match(input,STATEMENT,Follow._STATEMENT_in_statement331); Match(input, TokenTypes.Down, null); DebugLocation(94, 16); PushFollow(Follow._expression_in_statement333); expression18=expression(); PopFollow(); Match(input, TokenTypes.Up, null); DebugLocation(94, 28); node = expression18; } break; case 4: DebugEnterAlt(4); // Grammar\\SimpleCTreeWalker.g:95:4: ^( STATEMENT (st= statement )+ ) { DebugLocation(95, 4); DebugLocation(95, 6); Match(input,STATEMENT,Follow._STATEMENT_in_statement342); DebugLocation(95, 16); node = new CompoundStatementNode(); CompoundStatementNode compoundNode = (CompoundStatementNode)node; Match(input, TokenTypes.Down, null); DebugLocation(98, 5); // Grammar\\SimpleCTreeWalker.g:98:5: (st= statement )+ int cnt6=0; try { DebugEnterSubRule(6); while (true) { int alt6=2; try { DebugEnterDecision(6, false); int LA6_0 = input.LA(1); if ((LA6_0==STATEMENT||LA6_0==VAR_DEF)) { alt6 = 1; } } finally { DebugExitDecision(6); } switch (alt6) { case 1: DebugEnterAlt(1); // Grammar\\SimpleCTreeWalker.g:98:6: st= statement { DebugLocation(98, 8); PushFollow(Follow._statement_in_statement354); st=statement(); PopFollow(); DebugLocation(98, 19); compoundNode.Statements.Add(st); } break; default: if (cnt6 >= 1) goto loop6; EarlyExitException eee6 = new EarlyExitException( 6, input ); DebugRecognitionException(eee6); throw eee6; } cnt6++; } loop6: ; } finally { DebugExitSubRule(6); } Match(input, TokenTypes.Up, null); } break; } } catch (RecognitionException re) { ReportError(re); Recover(input,re); } finally { TraceOut("statement", 9); LeaveRule("statement", 9); LeaveRule_statement(); } DebugLocation(99, 0); } finally { DebugExitRule(GrammarFileName, "statement"); } return node; }
public FuncDefNode() { Body = new CompoundStatementNode(); // An empty statement }
private CompoundStatementNode funcBody() { EnterRule_funcBody(); EnterRule("funcBody", 8); TraceIn("funcBody", 8); CompoundStatementNode node = default(CompoundStatementNode); ISCNode statement16 = default(ISCNode); node = new CompoundStatementNode(); try { DebugEnterRule(GrammarFileName, "funcBody"); DebugLocation(84, 0); try { // Grammar\\SimpleCTreeWalker.g:87:3: ( ^( FUNC_BODY ( statement )* ) ) DebugEnterAlt(1); // Grammar\\SimpleCTreeWalker.g:88:2: ^( FUNC_BODY ( statement )* ) { DebugLocation(88, 2); DebugLocation(88, 4); Match(input,FUNC_BODY,Follow._FUNC_BODY_in_funcBody294); if (input.LA(1) == TokenTypes.Down) { Match(input, TokenTypes.Down, null); DebugLocation(88, 14); // Grammar\\SimpleCTreeWalker.g:88:14: ( statement )* try { DebugEnterSubRule(5); while (true) { int alt5=2; try { DebugEnterDecision(5, false); int LA5_0 = input.LA(1); if ((LA5_0==STATEMENT||LA5_0==VAR_DEF)) { alt5 = 1; } } finally { DebugExitDecision(5); } switch ( alt5 ) { case 1: DebugEnterAlt(1); // Grammar\\SimpleCTreeWalker.g:88:15: statement { DebugLocation(88, 15); PushFollow(Follow._statement_in_funcBody297); statement16=statement(); PopFollow(); DebugLocation(88, 25); node.Statements.Add(statement16); } break; default: goto loop5; } } loop5: ; } finally { DebugExitSubRule(5); } Match(input, TokenTypes.Up, null); } } } catch (RecognitionException re) { ReportError(re); Recover(input,re); } finally { TraceOut("funcBody", 8); LeaveRule("funcBody", 8); LeaveRule_funcBody(); } DebugLocation(89, 0); } finally { DebugExitRule(GrammarFileName, "funcBody"); } return node; }
private ISCNode statement() { EnterRule_statement(); EnterRule("statement", 10); TraceIn("statement", 10); ISCNode node = default(ISCNode); ISCNode st = default(ISCNode); VarDefNode varDef20 = default(VarDefNode); IExprNode expression21 = default(IExprNode); try { DebugEnterRule(GrammarFileName, "statement"); DebugLocation(108, 0); try { // Grammar\\SimpleCTreeWalker.g:108:33: ( varDef | STATEMENT | ^( STATEMENT expression ) | ^( STATEMENT (st= statement )+ ) ) int alt8=4; try { DebugEnterDecision(8, false); int LA8_0 = input.LA(1); if ((LA8_0==VAR_DEF)) { alt8 = 1; } else if ((LA8_0==STATEMENT)) { int LA8_2 = input.LA(2); if ((LA8_2==DOWN)) { int LA8_3 = input.LA(3); if (((LA8_3>=ADD && LA8_3<=BIT_AND)||(LA8_3>=BIT_OR && LA8_3<=BOOL_AND)||LA8_3==BOOL_OR||LA8_3==DIV||LA8_3==EQUAL||LA8_3==FUNC_CALL||(LA8_3>=GREATER && LA8_3<=IDENT)||LA8_3==INTEGER||(LA8_3>=LESS && LA8_3<=LESS_OR_EQUAL)||(LA8_3>=MOD && LA8_3<=NOT_EQUAL)||(LA8_3>=SHIFT_LEFT && LA8_3<=SHIFT_RIGHT)||LA8_3==STRING||LA8_3==SUB)) { alt8 = 3; } else if ((LA8_3==STATEMENT||LA8_3==VAR_DEF)) { alt8 = 4; } else { NoViableAltException nvae = new NoViableAltException("", 8, 3, input); DebugRecognitionException(nvae); throw nvae; } } else if ((LA8_2==UP||LA8_2==STATEMENT||LA8_2==VAR_DEF)) { alt8 = 2; } else { NoViableAltException nvae = new NoViableAltException("", 8, 2, input); DebugRecognitionException(nvae); throw nvae; } } else { NoViableAltException nvae = new NoViableAltException("", 8, 0, input); DebugRecognitionException(nvae); throw nvae; } } finally { DebugExitDecision(8); } switch (alt8) { case 1: DebugEnterAlt(1); // Grammar\\SimpleCTreeWalker.g:109:2: varDef { DebugLocation(109, 2); PushFollow(Follow._varDef_in_statement368); varDef20=varDef(); PopFollow(); DebugLocation(109, 9); node = varDef20; } break; case 2: DebugEnterAlt(2); // Grammar\\SimpleCTreeWalker.g:110:4: STATEMENT { DebugLocation(110, 4); Match(input,STATEMENT,Follow._STATEMENT_in_statement375); DebugLocation(110, 14); node = new CompoundStatementNode(); } break; case 3: DebugEnterAlt(3); // Grammar\\SimpleCTreeWalker.g:111:4: ^( STATEMENT expression ) { DebugLocation(111, 4); DebugLocation(111, 6); Match(input,STATEMENT,Follow._STATEMENT_in_statement384); Match(input, TokenTypes.Down, null); DebugLocation(111, 16); PushFollow(Follow._expression_in_statement386); expression21=expression(); PopFollow(); Match(input, TokenTypes.Up, null); DebugLocation(111, 28); node = expression21; } break; case 4: DebugEnterAlt(4); // Grammar\\SimpleCTreeWalker.g:112:4: ^( STATEMENT (st= statement )+ ) { DebugLocation(112, 4); DebugLocation(112, 6); Match(input,STATEMENT,Follow._STATEMENT_in_statement395); DebugLocation(112, 16); node = new CompoundStatementNode(); CompoundStatementNode compoundNode = (CompoundStatementNode)node; Match(input, TokenTypes.Down, null); DebugLocation(115, 5); // Grammar\\SimpleCTreeWalker.g:115:5: (st= statement )+ int cnt7=0; try { DebugEnterSubRule(7); while (true) { int alt7=2; try { DebugEnterDecision(7, false); int LA7_0 = input.LA(1); if ((LA7_0==STATEMENT||LA7_0==VAR_DEF)) { alt7 = 1; } } finally { DebugExitDecision(7); } switch (alt7) { case 1: DebugEnterAlt(1); // Grammar\\SimpleCTreeWalker.g:115:6: st= statement { DebugLocation(115, 8); PushFollow(Follow._statement_in_statement407); st=statement(); PopFollow(); DebugLocation(115, 19); compoundNode.Statements.Add(st); } break; default: if (cnt7 >= 1) goto loop7; EarlyExitException eee7 = new EarlyExitException( 7, input ); DebugRecognitionException(eee7); throw eee7; } cnt7++; } loop7: ; } finally { DebugExitSubRule(7); } Match(input, TokenTypes.Up, null); } break; } } catch (RecognitionException re) { ReportError(re); Recover(input,re); } finally { TraceOut("statement", 10); LeaveRule("statement", 10); LeaveRule_statement(); } DebugLocation(116, 0); } finally { DebugExitRule(GrammarFileName, "statement"); } return node; }