// $ANTLR start "term" // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:14:0: term : ( IntegerLiteral | ID | '(' additiveExpression ')' ); public SimpleParser.term_return term() // throws RecognitionException [1] { SimpleParser.term_return retval = new SimpleParser.term_return(); retval.Start = input.LT(1); CommonTree root_0 = null; IToken IntegerLiteral11 = null; IToken ID12 = null; IToken char_literal13 = null; IToken char_literal15 = null; SimpleParser.additiveExpression_return additiveExpression14 = default(SimpleParser.additiveExpression_return); CommonTree IntegerLiteral11_tree = null; CommonTree ID12_tree = null; CommonTree char_literal13_tree = null; CommonTree char_literal15_tree = null; try { // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:15:2: ( IntegerLiteral | ID | '(' additiveExpression ')' ) int alt5 = 3; switch (input.LA(1)) { case IntegerLiteral: { alt5 = 1; } break; case ID: { alt5 = 2; } break; case 9: { alt5 = 3; } break; default: NoViableAltException nvae_d5s0 = new NoViableAltException("", 5, 0, input); throw nvae_d5s0; } switch (alt5) { case 1: // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:15:2: IntegerLiteral { root_0 = (CommonTree)adaptor.GetNilNode(); IntegerLiteral11 = (IToken)Match(input, IntegerLiteral, FOLLOW_IntegerLiteral_in_term101); IntegerLiteral11_tree = (CommonTree)adaptor.Create(IntegerLiteral11); adaptor.AddChild(root_0, IntegerLiteral11_tree); } break; case 2: // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:16:2: ID { root_0 = (CommonTree)adaptor.GetNilNode(); ID12 = (IToken)Match(input, ID, FOLLOW_ID_in_term107); ID12_tree = (CommonTree)adaptor.Create(ID12); adaptor.AddChild(root_0, ID12_tree); } break; case 3: // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:17:2: '(' additiveExpression ')' { root_0 = (CommonTree)adaptor.GetNilNode(); char_literal13 = (IToken)Match(input, 9, FOLLOW_9_in_term113); PushFollow(FOLLOW_additiveExpression_in_term116); additiveExpression14 = additiveExpression(); state.followingStackPointer--; adaptor.AddChild(root_0, additiveExpression14.Tree); char_literal15 = (IToken)Match(input, 10, FOLLOW_10_in_term118); } break; } retval.Stop = input.LT(-1); retval.Tree = (CommonTree)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 = (CommonTree)adaptor.ErrorNode(input, (IToken)retval.Start, input.LT(-1), re); } finally { } return(retval); }
// $ANTLR start "multiplicativeExpression" // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:12:0: multiplicativeExpression : ( term ) ( ( '*' | '/' | '%' ) term )* ; public SimpleParser.multiplicativeExpression_return multiplicativeExpression() // throws RecognitionException [1] { SimpleParser.multiplicativeExpression_return retval = new SimpleParser.multiplicativeExpression_return(); retval.Start = input.LT(1); CommonTree root_0 = null; IToken char_literal7 = null; IToken char_literal8 = null; IToken char_literal9 = null; SimpleParser.term_return term6 = default(SimpleParser.term_return); SimpleParser.term_return term10 = default(SimpleParser.term_return); CommonTree char_literal7_tree = null; CommonTree char_literal8_tree = null; CommonTree char_literal9_tree = null; try { // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:13:2: ( ( term ) ( ( '*' | '/' | '%' ) term )* ) // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:13:2: ( term ) ( ( '*' | '/' | '%' ) term )* { root_0 = (CommonTree)adaptor.GetNilNode(); // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:13:2: ( term ) // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:13:3: term { PushFollow(FOLLOW_term_in_multiplicativeExpression76); term6 = term(); state.followingStackPointer--; adaptor.AddChild(root_0, term6.Tree); } // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:13:9: ( ( '*' | '/' | '%' ) term )* do { int alt4 = 2; int LA4_0 = input.LA(1); if ((LA4_0 == 8 || (LA4_0 >= 11 && LA4_0 <= 12))) { alt4 = 1; } switch (alt4) { case 1: // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:13:10: ( '*' | '/' | '%' ) term { // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:13:10: ( '*' | '/' | '%' ) int alt3 = 3; switch (input.LA(1)) { case 11: { alt3 = 1; } break; case 12: { alt3 = 2; } break; case 8: { alt3 = 3; } break; default: NoViableAltException nvae_d3s0 = new NoViableAltException("", 3, 0, input); throw nvae_d3s0; } switch (alt3) { case 1: // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:13:11: '*' { char_literal7 = (IToken)Match(input, 11, FOLLOW_11_in_multiplicativeExpression81); char_literal7_tree = (CommonTree)adaptor.Create(char_literal7); root_0 = (CommonTree)adaptor.BecomeRoot(char_literal7_tree, root_0); } break; case 2: // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:13:16: '/' { char_literal8 = (IToken)Match(input, 12, FOLLOW_12_in_multiplicativeExpression84); char_literal8_tree = (CommonTree)adaptor.Create(char_literal8); root_0 = (CommonTree)adaptor.BecomeRoot(char_literal8_tree, root_0); } break; case 3: // D:\\Szkolenia\\Artykuł ProgramistaMag - DSL\\Code\\DSLSamples\\SimpleDSL\\Simple.g:13:21: '%' { char_literal9 = (IToken)Match(input, 8, FOLLOW_8_in_multiplicativeExpression87); char_literal9_tree = (CommonTree)adaptor.Create(char_literal9); root_0 = (CommonTree)adaptor.BecomeRoot(char_literal9_tree, root_0); } break; } PushFollow(FOLLOW_term_in_multiplicativeExpression91); term10 = term(); state.followingStackPointer--; adaptor.AddChild(root_0, term10.Tree); } break; default: goto loop4; } } while (true); loop4: ; // Stops C# compiler whining that label 'loop4' has no statements } retval.Stop = input.LT(-1); retval.Tree = (CommonTree)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 = (CommonTree)adaptor.ErrorNode(input, (IToken)retval.Start, input.LT(-1), re); } finally { } return(retval); }