// $ANTLR start "block" // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:147:1: block : ( statement )* -> ^( BLOCK ^( STATEMENTS ( statement )* ) ) ; public SGLParser.block_return block() // throws RecognitionException [1] { SGLParser.block_return retval = new SGLParser.block_return(); retval.Start = input.LT(1); object root_0 = null; SGLParser.statement_return statement4 = default(SGLParser.statement_return); RewriteRuleSubtreeStream stream_statement = new RewriteRuleSubtreeStream(adaptor,"rule statement"); try { // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:148:2: ( ( statement )* -> ^( BLOCK ^( STATEMENTS ( statement )* ) ) ) // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:148:4: ( statement )* { // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:148:4: ( statement )* do { int alt2 = 2; int LA2_0 = input.LA(1); if ( ((LA2_0 >= Identifier && LA2_0 <= ObjectType) || LA2_0 == 57 || (LA2_0 >= 60 && LA2_0 <= 62) || (LA2_0 >= 64 && LA2_0 <= 66)) ) { alt2 = 1; } switch (alt2) { case 1 : // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:148:4: statement { PushFollow(FOLLOW_statement_in_block258); statement4 = statement(); state.followingStackPointer--; stream_statement.Add(statement4.Tree); } break; default: goto loop2; } } while (true); loop2: ; // Stops C# compiler whining that label 'loop2' has no statements // AST REWRITE // elements: statement // token labels: // rule labels: retval // token list labels: // rule list labels: // wildcard labels: retval.Tree = root_0; RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null); root_0 = (object)adaptor.GetNilNode(); // 149:3: -> ^( BLOCK ^( STATEMENTS ( statement )* ) ) { // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:149:6: ^( BLOCK ^( STATEMENTS ( statement )* ) ) { object root_1 = (object)adaptor.GetNilNode(); root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(BLOCK, "BLOCK"), root_1); // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:149:14: ^( STATEMENTS ( statement )* ) { object root_2 = (object)adaptor.GetNilNode(); root_2 = (object)adaptor.BecomeRoot((object)adaptor.Create(STATEMENTS, "STATEMENTS"), root_2); // C:\\Users\\Dominik Halfkann\\Documents\\Visual Studio 2010\\Projects\\SGLParserTester\\SGL\\AntlrParser\\SGL.g:149:27: ( statement )* while ( stream_statement.HasNext() ) { adaptor.AddChild(root_2, stream_statement.NextTree()); } stream_statement.Reset(); adaptor.AddChild(root_1, root_2); } adaptor.AddChild(root_0, root_1); } } retval.Tree = root_0;retval.Tree = root_0; } retval.Stop = input.LT(-1); retval.Tree = (object)adaptor.RulePostProcessing(root_0); adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop); } catch (RecognitionException re) { ReportError(re); Recover(input,re); // Conversion of the second argument necessary, but harmless retval.Tree = (object)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re); } finally { } return retval; }
// $ANTLR start "block" // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:168:1: block : ( statement )* -> ^( BLOCK ( statement )* ) ; public SGLParser.block_return block() // throws RecognitionException [1] { SGLParser.block_return retval = new SGLParser.block_return(); retval.Start = input.LT(1); int block_StartIndex = input.Index(); object root_0 = null; SGLParser.statement_return statement4 = default(SGLParser.statement_return); RewriteRuleSubtreeStream stream_statement = new RewriteRuleSubtreeStream(adaptor,"rule statement"); try { if ( (state.backtracking > 0) && AlreadyParsedRule(input, 3) ) { return retval; } // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:169:2: ( ( statement )* -> ^( BLOCK ( statement )* ) ) // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:169:4: ( statement )* { // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:169:4: ( statement )* do { int alt2 = 2; int LA2_0 = input.LA(1); if ( (LA2_0 == Identifier || LA2_0 == VarStartInit || (LA2_0 >= 82 && LA2_0 <= 86) || LA2_0 == 88) ) { alt2 = 1; } switch (alt2) { case 1 : // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:0:0: statement { PushFollow(FOLLOW_statement_in_block303); statement4 = statement(); state.followingStackPointer--; if (state.failed) return retval; if ( (state.backtracking==0) ) stream_statement.Add(statement4.Tree); } break; default: goto loop2; } } while (true); loop2: ; // Stops C# compiler whining that label 'loop2' has no statements // AST REWRITE // elements: statement // token labels: // rule labels: retval // token list labels: // rule list labels: // wildcard labels: if ( (state.backtracking==0) ) { retval.Tree = root_0; RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null); root_0 = (object)adaptor.GetNilNode(); // 170:3: -> ^( BLOCK ( statement )* ) { // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:170:6: ^( BLOCK ( statement )* ) { object root_1 = (object)adaptor.GetNilNode(); root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(BLOCK, "BLOCK"), root_1); // E:\\SGL\\sgl4c#\\NewSGLGramma\\SGL.g:170:14: ( statement )* while ( stream_statement.HasNext() ) { adaptor.AddChild(root_1, stream_statement.NextTree()); } stream_statement.Reset(); adaptor.AddChild(root_0, root_1); } } retval.Tree = root_0;retval.Tree = root_0;} } retval.Stop = input.LT(-1); if ( (state.backtracking==0) ) { retval.Tree = (object)adaptor.RulePostProcessing(root_0); adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);} } catch (RecognitionException re) { ReportError(re); Recover(input,re); // Conversion of the second argument necessary, but harmless retval.Tree = (object)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re); } finally { if ( state.backtracking > 0 ) { Memoize(input, 3, block_StartIndex); } } return retval; }