// $ANTLR start "program" // Interp.g:29:1: program returns [List<Element> ret] : ( expr )+ ; public InterpParser.program_return program() // throws RecognitionException [1] { InterpParser.program_return retval = new InterpParser.program_return(); retval.Start = input.LT(1); object root_0 = null; InterpParser.expr_return expr1 = null; retval.ret = new List<Element>(); try { // Interp.g:33:3: ( ( expr )+ ) // Interp.g:33:5: ( expr )+ { root_0 = (object)adaptor.GetNilNode(); // Interp.g:33:5: ( expr )+ int cnt1 = 0; do { int alt1 = 2; int LA1_0 = input.LA(1); if ( (LA1_0 == VARIABLE || LA1_0 == 16 || LA1_0 == 20) ) { alt1 = 1; } switch (alt1) { case 1 : // Interp.g:33:6: expr { PushFollow(FOLLOW_expr_in_program74); expr1 = expr(); state.followingStackPointer--; adaptor.AddChild(root_0, expr1.Tree); retval.ret.Add(((expr1 != null) ? expr1.ret : null)); } break; default: if ( cnt1 >= 1 ) goto loop1; EarlyExitException eee1 = new EarlyExitException(1, input); throw eee1; } cnt1++; } while (true); loop1: ; // Stops C# compiler whining that label 'loop1' has no statements } 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 "program" // H:\\Interp_CSharp\\Interp_CSharp\\Interp_CSharp\\Interp.g:41:1: program returns [List<Element> ret] : ( expr )+ ; public InterpParser.program_return program() // throws RecognitionException [1] { InterpParser.program_return retval = new InterpParser.program_return(); retval.Start = input.LT(1); object root_0 = null; InterpParser.expr_return expr1 = null; retval.ret = new List<Element>(); try { dbg.EnterRule(GrammarFileName, "program"); if ( RuleLevel==0 ) {dbg.Commence();} IncRuleLevel(); dbg.Location(41, 1); try { // H:\\Interp_CSharp\\Interp_CSharp\\Interp_CSharp\\Interp.g:49:3: ( ( expr )+ ) dbg.EnterAlt(1); // H:\\Interp_CSharp\\Interp_CSharp\\Interp_CSharp\\Interp.g:49:5: ( expr )+ { root_0 = (object)adaptor.GetNilNode(); dbg.Location(49,5); // H:\\Interp_CSharp\\Interp_CSharp\\Interp_CSharp\\Interp.g:49:5: ( expr )+ int cnt1 = 0; try { dbg.EnterSubRule(1); do { int alt1 = 2; try { dbg.EnterDecision(1); int LA1_0 = input.LA(1); if ( (LA1_0 == VARIABLE || LA1_0 == 11) ) { alt1 = 1; } } finally { dbg.ExitDecision(1); } switch (alt1) { case 1 : dbg.EnterAlt(1); // H:\\Interp_CSharp\\Interp_CSharp\\Interp_CSharp\\Interp.g:49:6: expr { dbg.Location(49,6); PushFollow(FOLLOW_expr_in_program91); expr1 = expr(); state.followingStackPointer--; adaptor.AddChild(root_0, expr1.Tree); dbg.Location(49,11); retval.ret.Add(((expr1 != null) ? expr1.ret : null)); } break; default: if ( cnt1 >= 1 ) goto loop1; EarlyExitException eee1 = new EarlyExitException(1, input); dbg.RecognitionException(eee1); throw eee1; } cnt1++; } while (true); loop1: ; // Stops C# compiler whining that label 'loop1' has no statements } finally { dbg.ExitSubRule(1); } } 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 { } dbg.Location(49, 43); } finally { dbg.ExitRule(GrammarFileName, "program"); DecRuleLevel(); if ( RuleLevel==0 ) {dbg.Terminate();} } return retval; }