コード例 #1
0
ファイル: simpletikzParser.cs プロジェクト: paladin74/tikzedt
    // throws RecognitionException [1]
    // $ANTLR start "coord_part"
    // C:\\_TUHH\\SVN\\projects\\wsn\\dibus\\SvgMap\\SvgNaviMap\\bargraph\\tikzedt\\TikzParser\\simpletikz.g:460:1: coord_part : ( idd -> ^( IM_DONTCARE idd ) | '{' idd '}' -> ^( IM_DONTCARE '{' idd '}' ) | ( idd '=' numberunit ( ',' )? )+ -> ^( IM_DONTCARE ( idd '=' numberunit ( ',' )? )+ ) );
    public simpletikzParser.coord_part_return coord_part()
    {
        simpletikzParser.coord_part_return retval = new simpletikzParser.coord_part_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken char_literal285 = null;
        IToken char_literal287 = null;
        IToken char_literal289 = null;
        IToken char_literal291 = null;
        simpletikzParser.idd_return idd284 = default(simpletikzParser.idd_return);

        simpletikzParser.idd_return idd286 = default(simpletikzParser.idd_return);

        simpletikzParser.idd_return idd288 = default(simpletikzParser.idd_return);

        simpletikzParser.numberunit_return numberunit290 = default(simpletikzParser.numberunit_return);

        object char_literal285_tree=null;
        object char_literal287_tree=null;
        object char_literal289_tree=null;
        object char_literal291_tree=null;
        RewriteRuleTokenStream stream_45 = new RewriteRuleTokenStream(adaptor,"token 45");
        RewriteRuleTokenStream stream_43 = new RewriteRuleTokenStream(adaptor,"token 43");
        RewriteRuleTokenStream stream_44 = new RewriteRuleTokenStream(adaptor,"token 44");
        RewriteRuleTokenStream stream_47 = new RewriteRuleTokenStream(adaptor,"token 47");
        RewriteRuleSubtreeStream stream_numberunit = new RewriteRuleSubtreeStream(adaptor,"rule numberunit");
        RewriteRuleSubtreeStream stream_idd = new RewriteRuleSubtreeStream(adaptor,"rule idd");
        try
        {
            // C:\\_TUHH\\SVN\\projects\\wsn\\dibus\\SvgMap\\SvgNaviMap\\bargraph\\tikzedt\\TikzParser\\simpletikz.g:461:2: ( idd -> ^( IM_DONTCARE idd ) | '{' idd '}' -> ^( IM_DONTCARE '{' idd '}' ) | ( idd '=' numberunit ( ',' )? )+ -> ^( IM_DONTCARE ( idd '=' numberunit ( ',' )? )+ ) )
            int alt73 = 3;
            alt73 = dfa73.Predict(input);
            switch (alt73)
            {
                case 1 :
                    // C:\\_TUHH\\SVN\\projects\\wsn\\dibus\\SvgMap\\SvgNaviMap\\bargraph\\tikzedt\\TikzParser\\simpletikz.g:461:4: idd
                    {
                        PushFollow(FOLLOW_idd_in_coord_part3010);
                        idd284 = idd();
                        state.followingStackPointer--;
                        if (state.failed) return retval;
                        if ( state.backtracking==0 ) stream_idd.Add(idd284.Tree);

                        // AST REWRITE
                        // elements:          idd
                        // token labels:
                        // rule labels:       retval
                        // token list labels:
                        // rule list labels:
                        if ( state.backtracking==0 ) {
                        retval.Tree = root_0;
                        RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "token retval", (retval!=null ? retval.Tree : null));

                        root_0 = (object)adaptor.GetNilNode();
                        // 461:9: -> ^( IM_DONTCARE idd )
                        {
                            // C:\\_TUHH\\SVN\\projects\\wsn\\dibus\\SvgMap\\SvgNaviMap\\bargraph\\tikzedt\\TikzParser\\simpletikz.g:461:12: ^( IM_DONTCARE idd )
                            {
                            object root_1 = (object)adaptor.GetNilNode();
                            root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(IM_DONTCARE, "IM_DONTCARE"), root_1);

                            adaptor.AddChild(root_1, stream_idd.NextTree());

                            adaptor.AddChild(root_0, root_1);
                            }

                        }

                        retval.Tree = root_0;retval.Tree = root_0;}
                    }
                    break;
                case 2 :
                    // C:\\_TUHH\\SVN\\projects\\wsn\\dibus\\SvgMap\\SvgNaviMap\\bargraph\\tikzedt\\TikzParser\\simpletikz.g:462:4: '{' idd '}'
                    {
                        char_literal285=(IToken)Match(input,43,FOLLOW_43_in_coord_part3025); if (state.failed) return retval;
                        if ( state.backtracking==0 ) stream_43.Add(char_literal285);

                        PushFollow(FOLLOW_idd_in_coord_part3027);
                        idd286 = idd();
                        state.followingStackPointer--;
                        if (state.failed) return retval;
                        if ( state.backtracking==0 ) stream_idd.Add(idd286.Tree);
                        char_literal287=(IToken)Match(input,44,FOLLOW_44_in_coord_part3029); if (state.failed) return retval;
                        if ( state.backtracking==0 ) stream_44.Add(char_literal287);

                        // AST REWRITE
                        // elements:          idd, 43, 44
                        // token labels:
                        // rule labels:       retval
                        // token list labels:
                        // rule list labels:
                        if ( state.backtracking==0 ) {
                        retval.Tree = root_0;
                        RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "token retval", (retval!=null ? retval.Tree : null));

                        root_0 = (object)adaptor.GetNilNode();
                        // 462:16: -> ^( IM_DONTCARE '{' idd '}' )
                        {
                            // C:\\_TUHH\\SVN\\projects\\wsn\\dibus\\SvgMap\\SvgNaviMap\\bargraph\\tikzedt\\TikzParser\\simpletikz.g:462:19: ^( IM_DONTCARE '{' idd '}' )
                            {
                            object root_1 = (object)adaptor.GetNilNode();
                            root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(IM_DONTCARE, "IM_DONTCARE"), root_1);

                            adaptor.AddChild(root_1, stream_43.NextNode());
                            adaptor.AddChild(root_1, stream_idd.NextTree());
                            adaptor.AddChild(root_1, stream_44.NextNode());

                            adaptor.AddChild(root_0, root_1);
                            }

                        }

                        retval.Tree = root_0;retval.Tree = root_0;}
                    }
                    break;
                case 3 :
                    // C:\\_TUHH\\SVN\\projects\\wsn\\dibus\\SvgMap\\SvgNaviMap\\bargraph\\tikzedt\\TikzParser\\simpletikz.g:463:4: ( idd '=' numberunit ( ',' )? )+
                    {
                        // C:\\_TUHH\\SVN\\projects\\wsn\\dibus\\SvgMap\\SvgNaviMap\\bargraph\\tikzedt\\TikzParser\\simpletikz.g:463:4: ( idd '=' numberunit ( ',' )? )+
                        int cnt72 = 0;
                        do
                        {
                            int alt72 = 2;
                            int LA72_0 = input.LA(1);

                            if ( (LA72_0 == 78) )
                            {
                                int LA72_2 = input.LA(2);

                                if ( ((LA72_2 >= FLOAT_WO_EXP && LA72_2 <= INT)) )
                                {
                                    int LA72_4 = input.LA(3);

                                    if ( ((LA72_4 >= 57 && LA72_4 <= 62)) )
                                    {
                                        int LA72_5 = input.LA(4);

                                        if ( ((LA72_5 >= IM_PATH && LA72_5 <= 42) || (LA72_5 >= 45 && LA72_5 <= 46) || LA72_5 == 51 || (LA72_5 >= 57 && LA72_5 <= 94)) )
                                        {
                                            alt72 = 1;
                                        }

                                    }
                                    else if ( ((LA72_4 >= IM_PATH && LA72_4 <= 42) || (LA72_4 >= 45 && LA72_4 <= 46) || LA72_4 == 51 || (LA72_4 >= 63 && LA72_4 <= 94)) )
                                    {
                                        alt72 = 1;
                                    }

                                }
                                else if ( ((LA72_2 >= IM_PATH && LA72_2 <= COMMAND) || (LA72_2 >= WS && LA72_2 <= 42) || (LA72_2 >= 45 && LA72_2 <= 46) || LA72_2 == 51 || (LA72_2 >= 57 && LA72_2 <= 94)) )
                                {
                                    alt72 = 1;
                                }

                            }
                            else if ( ((LA72_0 >= IM_PATH && LA72_0 <= 42) || LA72_0 == 46 || LA72_0 == 51 || (LA72_0 >= 57 && LA72_0 <= 77) || (LA72_0 >= 79 && LA72_0 <= 94)) )
                            {
                                alt72 = 1;
                            }

                            switch (alt72)
                            {
                                case 1 :
                                    // C:\\_TUHH\\SVN\\projects\\wsn\\dibus\\SvgMap\\SvgNaviMap\\bargraph\\tikzedt\\TikzParser\\simpletikz.g:463:5: idd '=' numberunit ( ',' )?
                                    {
                                        PushFollow(FOLLOW_idd_in_coord_part3047);
                                        idd288 = idd();
                                        state.followingStackPointer--;
                                        if (state.failed) return retval;
                                        if ( state.backtracking==0 ) stream_idd.Add(idd288.Tree);
                                        char_literal289=(IToken)Match(input,45,FOLLOW_45_in_coord_part3049); if (state.failed) return retval;
                                        if ( state.backtracking==0 ) stream_45.Add(char_literal289);

                                        PushFollow(FOLLOW_numberunit_in_coord_part3051);
                                        numberunit290 = numberunit();
                                        state.followingStackPointer--;
                                        if (state.failed) return retval;
                                        if ( state.backtracking==0 ) stream_numberunit.Add(numberunit290.Tree);
                                        // C:\\_TUHH\\SVN\\projects\\wsn\\dibus\\SvgMap\\SvgNaviMap\\bargraph\\tikzedt\\TikzParser\\simpletikz.g:463:24: ( ',' )?
                                        int alt71 = 2;
                                        int LA71_0 = input.LA(1);

                                        if ( (LA71_0 == 47) )
                                        {
                                            alt71 = 1;
                                        }
                                        switch (alt71)
                                        {
                                            case 1 :
                                                // C:\\_TUHH\\SVN\\projects\\wsn\\dibus\\SvgMap\\SvgNaviMap\\bargraph\\tikzedt\\TikzParser\\simpletikz.g:463:24: ','
                                                {
                                                    char_literal291=(IToken)Match(input,47,FOLLOW_47_in_coord_part3053); if (state.failed) return retval;
                                                    if ( state.backtracking==0 ) stream_47.Add(char_literal291);

                                                }
                                                break;

                                        }

                                    }
                                    break;

                                default:
                                    if ( cnt72 >= 1 ) goto loop72;
                                    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
                                        EarlyExitException eee =
                                            new EarlyExitException(72, input);
                                        throw eee;
                            }
                            cnt72++;
                        } while (true);

                        loop72:
                            ;	// Stops C# compiler whinging that label 'loop72' has no statements

                        // AST REWRITE
                        // elements:          47, numberunit, idd, 45
                        // token labels:
                        // rule labels:       retval
                        // token list labels:
                        // rule list labels:
                        if ( state.backtracking==0 ) {
                        retval.Tree = root_0;
                        RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "token retval", (retval!=null ? retval.Tree : null));

                        root_0 = (object)adaptor.GetNilNode();
                        // 463:31: -> ^( IM_DONTCARE ( idd '=' numberunit ( ',' )? )+ )
                        {
                            // C:\\_TUHH\\SVN\\projects\\wsn\\dibus\\SvgMap\\SvgNaviMap\\bargraph\\tikzedt\\TikzParser\\simpletikz.g:463:34: ^( IM_DONTCARE ( idd '=' numberunit ( ',' )? )+ )
                            {
                            object root_1 = (object)adaptor.GetNilNode();
                            root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(IM_DONTCARE, "IM_DONTCARE"), root_1);

                            if ( !(stream_numberunit.HasNext() || stream_idd.HasNext() || stream_45.HasNext()) ) {
                                throw new RewriteEarlyExitException();
                            }
                            while ( stream_numberunit.HasNext() || stream_idd.HasNext() || stream_45.HasNext() )
                            {
                                adaptor.AddChild(root_1, stream_idd.NextTree());
                                adaptor.AddChild(root_1, stream_45.NextNode());
                                adaptor.AddChild(root_1, stream_numberunit.NextTree());
                                // C:\\_TUHH\\SVN\\projects\\wsn\\dibus\\SvgMap\\SvgNaviMap\\bargraph\\tikzedt\\TikzParser\\simpletikz.g:463:69: ( ',' )?
                                if ( stream_47.HasNext() )
                                {
                                    adaptor.AddChild(root_1, stream_47.NextNode());

                                }
                                stream_47.Reset();

                            }
                            stream_numberunit.Reset();
                            stream_idd.Reset();
                            stream_45.Reset();

                            adaptor.AddChild(root_0, root_1);
                            }

                        }

                        retval.Tree = root_0;retval.Tree = root_0;}
                    }
                    break;

            }
            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 e) {
                throw e;
            }
        finally
        {
        }
        return retval;
    }
コード例 #2
0
ファイル: AS3Parser.cs プロジェクト: jbakst/xas
	private AstParserRuleReturnScope<CommonTree, IToken> basicParameterDeclaration()
	{
		EnterRule_basicParameterDeclaration();
		EnterRule("basicParameterDeclaration", 35);
		TraceIn("basicParameterDeclaration", 35);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken CONST114 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> ident115 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> typeExpression116 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> parameterDefault117 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree CONST114_tree = default(CommonTree);
		RewriteRuleITokenStream stream_CONST=new RewriteRuleITokenStream(adaptor,"token CONST");
		RewriteRuleSubtreeStream stream_ident=new RewriteRuleSubtreeStream(adaptor,"rule ident");
		RewriteRuleSubtreeStream stream_typeExpression=new RewriteRuleSubtreeStream(adaptor,"rule typeExpression");
		RewriteRuleSubtreeStream stream_parameterDefault=new RewriteRuleSubtreeStream(adaptor,"rule parameterDefault");
		try { DebugEnterRule(GrammarFileName, "basicParameterDeclaration");
		DebugLocation(343, 1);
		try
		{
			// AS3.g:344:2: ( ( CONST )? ident ( typeExpression )? ( parameterDefault )? -> ^( PARAM ( CONST )? ident ( typeExpression )? ( parameterDefault )? ) )
			DebugEnterAlt(1);
			// AS3.g:344:4: ( CONST )? ident ( typeExpression )? ( parameterDefault )?
			{
			DebugLocation(344, 4);
			// AS3.g:344:4: ( CONST )?
			int alt28=2;
			try { DebugEnterSubRule(28);
			try { DebugEnterDecision(28, false);
			int LA28_1 = input.LA(1);

			if ((LA28_1==CONST))
			{
				alt28 = 1;
			}
			} finally { DebugExitDecision(28); }
			switch (alt28)
			{
			case 1:
				DebugEnterAlt(1);
				// AS3.g:344:4: CONST
				{
				DebugLocation(344, 4);
				CONST114=(IToken)Match(input,CONST,Follow._CONST_in_basicParameterDeclaration1877); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_CONST.Add(CONST114);


				}
				break;

			}
			} finally { DebugExitSubRule(28); }

			DebugLocation(344, 11);
			PushFollow(Follow._ident_in_basicParameterDeclaration1880);
			ident115=ident();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_ident.Add(ident115.Tree);
			DebugLocation(344, 17);
			// AS3.g:344:17: ( typeExpression )?
			int alt29=2;
			try { DebugEnterSubRule(29);
			try { DebugEnterDecision(29, false);
			int LA29_1 = input.LA(1);

			if ((LA29_1==COLON))
			{
				alt29 = 1;
			}
			} finally { DebugExitDecision(29); }
			switch (alt29)
			{
			case 1:
				DebugEnterAlt(1);
				// AS3.g:344:17: typeExpression
				{
				DebugLocation(344, 17);
				PushFollow(Follow._typeExpression_in_basicParameterDeclaration1882);
				typeExpression116=typeExpression();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_typeExpression.Add(typeExpression116.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(29); }

			DebugLocation(344, 33);
			// AS3.g:344:33: ( parameterDefault )?
			int alt30=2;
			try { DebugEnterSubRule(30);
			try { DebugEnterDecision(30, false);
			int LA30_1 = input.LA(1);

			if ((LA30_1==ASSIGN))
			{
				alt30 = 1;
			}
			} finally { DebugExitDecision(30); }
			switch (alt30)
			{
			case 1:
				DebugEnterAlt(1);
				// AS3.g:344:33: parameterDefault
				{
				DebugLocation(344, 33);
				PushFollow(Follow._parameterDefault_in_basicParameterDeclaration1885);
				parameterDefault117=parameterDefault();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_parameterDefault.Add(parameterDefault117.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(30); }



			{
			// AST REWRITE
			// elements: CONST, ident, typeExpression, parameterDefault
			// 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 = (CommonTree)adaptor.Nil();
			// 345:3: -> ^( PARAM ( CONST )? ident ( typeExpression )? ( parameterDefault )? )
			{
				DebugLocation(345, 6);
				// AS3.g:345:6: ^( PARAM ( CONST )? ident ( typeExpression )? ( parameterDefault )? )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(345, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(PARAM, "PARAM"), root_1);

				DebugLocation(345, 14);
				// AS3.g:345:14: ( CONST )?
				if (stream_CONST.HasNext)
				{
					DebugLocation(345, 14);
					adaptor.AddChild(root_1, stream_CONST.NextNode());

				}
				stream_CONST.Reset();
				DebugLocation(345, 21);
				adaptor.AddChild(root_1, stream_ident.NextTree());
				DebugLocation(345, 27);
				// AS3.g:345:27: ( typeExpression )?
				if (stream_typeExpression.HasNext)
				{
					DebugLocation(345, 27);
					adaptor.AddChild(root_1, stream_typeExpression.NextTree());

				}
				stream_typeExpression.Reset();
				DebugLocation(345, 43);
				// AS3.g:345:43: ( parameterDefault )?
				if (stream_parameterDefault.HasNext)
				{
					DebugLocation(345, 43);
					adaptor.AddChild(root_1, stream_parameterDefault.NextTree());

				}
				stream_parameterDefault.Reset();

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			if (state.backtracking == 0) {
			retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("basicParameterDeclaration", 35);
			LeaveRule("basicParameterDeclaration", 35);
			LeaveRule_basicParameterDeclaration();
		}
		DebugLocation(346, 1);
		} finally { DebugExitRule(GrammarFileName, "basicParameterDeclaration"); }
		return retval;

	}
コード例 #3
0
	private AstParserRuleReturnScope<CommonTree, IToken> global_alloc()
	{
		EnterRule_global_alloc();
		EnterRule("global_alloc", 8);
		TraceIn("global_alloc", 8);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken string_literal54 = default(IToken);
		IToken WS55 = default(IToken);
		IToken WS57 = default(IToken);
		IToken char_literal58 = default(IToken);
		IToken WS59 = default(IToken);
		IToken WS61 = default(IToken);
		IToken char_literal62 = default(IToken);
		IToken string_literal63 = default(IToken);
		IToken WS64 = default(IToken);
		IToken WS66 = default(IToken);
		IToken WS68 = default(IToken);
		IToken string_literal69 = default(IToken);
		IToken WS70 = default(IToken);
		IToken WS72 = default(IToken);
		IToken char_literal73 = default(IToken);
		IToken WS74 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> attribute53 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident_list56 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> type_name60 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> where_expr65 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> bracket_expr_list67 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> where_expr71 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> where_expr75 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal54_tree = default(CommonTree);
		CommonTree WS55_tree = default(CommonTree);
		CommonTree WS57_tree = default(CommonTree);
		CommonTree char_literal58_tree = default(CommonTree);
		CommonTree WS59_tree = default(CommonTree);
		CommonTree WS61_tree = default(CommonTree);
		CommonTree char_literal62_tree = default(CommonTree);
		CommonTree string_literal63_tree = default(CommonTree);
		CommonTree WS64_tree = default(CommonTree);
		CommonTree WS66_tree = default(CommonTree);
		CommonTree WS68_tree = default(CommonTree);
		CommonTree string_literal69_tree = default(CommonTree);
		CommonTree WS70_tree = default(CommonTree);
		CommonTree WS72_tree = default(CommonTree);
		CommonTree char_literal73_tree = default(CommonTree);
		CommonTree WS74_tree = default(CommonTree);
		RewriteRuleITokenStream stream_147=new RewriteRuleITokenStream(adaptor,"token 147");
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_121=new RewriteRuleITokenStream(adaptor,"token 121");
		RewriteRuleITokenStream stream_113=new RewriteRuleITokenStream(adaptor,"token 113");
		RewriteRuleITokenStream stream_111=new RewriteRuleITokenStream(adaptor,"token 111");
		RewriteRuleITokenStream stream_100=new RewriteRuleITokenStream(adaptor,"token 100");
		RewriteRuleSubtreeStream stream_type_name=new RewriteRuleSubtreeStream(adaptor,"rule type_name");
		RewriteRuleSubtreeStream stream_attribute=new RewriteRuleSubtreeStream(adaptor,"rule attribute");
		RewriteRuleSubtreeStream stream_ident_list=new RewriteRuleSubtreeStream(adaptor,"rule ident_list");
		RewriteRuleSubtreeStream stream_where_expr=new RewriteRuleSubtreeStream(adaptor,"rule where_expr");
		RewriteRuleSubtreeStream stream_bracket_expr_list=new RewriteRuleSubtreeStream(adaptor,"rule bracket_expr_list");
		try { DebugEnterRule(GrammarFileName, "global_alloc");
		DebugLocation(255, 1);
		try
		{
			// SugarCpp.g:256:2: ( ( attribute )? ( 'extern' ( WS )* )? ident_list ( ( WS )* ':' ( WS )* type_name ( ( WS )* ( '=' | ':=' ) ( WS )* where_expr -> ^( Expr_Alloc_Equal ( attribute )? ( 'extern' )? type_name ident_list ^( Expr_Args where_expr ) ) | ( WS )* bracket_expr_list -> ^( Expr_Alloc_Bracket ( attribute )? ( 'extern' )? type_name ident_list bracket_expr_list ) | -> ^( Expr_Alloc_Equal ( attribute )? ( 'extern' )? type_name ident_list ^( Expr_Args ) ) ) | ( WS )* ':=' ( WS )* ( where_expr ( ( WS )* ',' ( WS )* where_expr )* ) -> ^( ':=' ( attribute )? ( 'extern' )? ident_list ^( Expr_Args ( where_expr )+ ) ) ) )
			DebugEnterAlt(1);
			// SugarCpp.g:256:4: ( attribute )? ( 'extern' ( WS )* )? ident_list ( ( WS )* ':' ( WS )* type_name ( ( WS )* ( '=' | ':=' ) ( WS )* where_expr -> ^( Expr_Alloc_Equal ( attribute )? ( 'extern' )? type_name ident_list ^( Expr_Args where_expr ) ) | ( WS )* bracket_expr_list -> ^( Expr_Alloc_Bracket ( attribute )? ( 'extern' )? type_name ident_list bracket_expr_list ) | -> ^( Expr_Alloc_Equal ( attribute )? ( 'extern' )? type_name ident_list ^( Expr_Args ) ) ) | ( WS )* ':=' ( WS )* ( where_expr ( ( WS )* ',' ( WS )* where_expr )* ) -> ^( ':=' ( attribute )? ( 'extern' )? ident_list ^( Expr_Args ( where_expr )+ ) ) )
			{
			DebugLocation(256, 4);
			// SugarCpp.g:256:4: ( attribute )?
			int alt31=2;
			try { DebugEnterSubRule(31);
			try { DebugEnterDecision(31, false);
			int LA31_0 = input.LA(1);

			if ((LA31_0==132))
			{
				alt31 = 1;
			}
			} finally { DebugExitDecision(31); }
			switch (alt31)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:256:4: attribute
				{
				DebugLocation(256, 4);
				PushFollow(Follow._attribute_in_global_alloc905);
				attribute53=attribute();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_attribute.Add(attribute53.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(31); }

			DebugLocation(256, 15);
			// SugarCpp.g:256:15: ( 'extern' ( WS )* )?
			int alt33=2;
			try { DebugEnterSubRule(33);
			try { DebugEnterDecision(33, false);
			int LA33_0 = input.LA(1);

			if ((LA33_0==147))
			{
				alt33 = 1;
			}
			} finally { DebugExitDecision(33); }
			switch (alt33)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:256:16: 'extern' ( WS )*
				{
				DebugLocation(256, 16);
				string_literal54=(IToken)Match(input,147,Follow._147_in_global_alloc909); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_147.Add(string_literal54);

				DebugLocation(256, 25);
				// SugarCpp.g:256:25: ( WS )*
				try { DebugEnterSubRule(32);
				while (true)
				{
					int alt32=2;
					try { DebugEnterDecision(32, false);
					int LA32_0 = input.LA(1);

					if ((LA32_0==WS))
					{
						alt32 = 1;
					}


					} finally { DebugExitDecision(32); }
					switch ( alt32 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:256:25: WS
						{
						DebugLocation(256, 25);
						WS55=(IToken)Match(input,WS,Follow._WS_in_global_alloc911); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS55);


						}
						break;

					default:
						goto loop32;
					}
				}

				loop32:
					;

				} finally { DebugExitSubRule(32); }


				}
				break;

			}
			} finally { DebugExitSubRule(33); }

			DebugLocation(256, 31);
			PushFollow(Follow._ident_list_in_global_alloc916);
			ident_list56=ident_list();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_ident_list.Add(ident_list56.Tree);
			DebugLocation(256, 42);
			// SugarCpp.g:256:42: ( ( WS )* ':' ( WS )* type_name ( ( WS )* ( '=' | ':=' ) ( WS )* where_expr -> ^( Expr_Alloc_Equal ( attribute )? ( 'extern' )? type_name ident_list ^( Expr_Args where_expr ) ) | ( WS )* bracket_expr_list -> ^( Expr_Alloc_Bracket ( attribute )? ( 'extern' )? type_name ident_list bracket_expr_list ) | -> ^( Expr_Alloc_Equal ( attribute )? ( 'extern' )? type_name ident_list ^( Expr_Args ) ) ) | ( WS )* ':=' ( WS )* ( where_expr ( ( WS )* ',' ( WS )* where_expr )* ) -> ^( ':=' ( attribute )? ( 'extern' )? ident_list ^( Expr_Args ( where_expr )+ ) ) )
			int alt46=2;
			try { DebugEnterSubRule(46);
			try { DebugEnterDecision(46, false);
			try
			{
				alt46 = dfa46.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(46); }
			switch (alt46)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:256:44: ( WS )* ':' ( WS )* type_name ( ( WS )* ( '=' | ':=' ) ( WS )* where_expr -> ^( Expr_Alloc_Equal ( attribute )? ( 'extern' )? type_name ident_list ^( Expr_Args where_expr ) ) | ( WS )* bracket_expr_list -> ^( Expr_Alloc_Bracket ( attribute )? ( 'extern' )? type_name ident_list bracket_expr_list ) | -> ^( Expr_Alloc_Equal ( attribute )? ( 'extern' )? type_name ident_list ^( Expr_Args ) ) )
				{
				DebugLocation(256, 44);
				// SugarCpp.g:256:44: ( WS )*
				try { DebugEnterSubRule(34);
				while (true)
				{
					int alt34=2;
					try { DebugEnterDecision(34, false);
					int LA34_0 = input.LA(1);

					if ((LA34_0==WS))
					{
						alt34 = 1;
					}


					} finally { DebugExitDecision(34); }
					switch ( alt34 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:256:44: WS
						{
						DebugLocation(256, 44);
						WS57=(IToken)Match(input,WS,Follow._WS_in_global_alloc920); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS57);


						}
						break;

					default:
						goto loop34;
					}
				}

				loop34:
					;

				} finally { DebugExitSubRule(34); }

				DebugLocation(256, 48);
				char_literal58=(IToken)Match(input,111,Follow._111_in_global_alloc923); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_111.Add(char_literal58);

				DebugLocation(256, 52);
				// SugarCpp.g:256:52: ( WS )*
				try { DebugEnterSubRule(35);
				while (true)
				{
					int alt35=2;
					try { DebugEnterDecision(35, false);
					int LA35_0 = input.LA(1);

					if ((LA35_0==WS))
					{
						alt35 = 1;
					}


					} finally { DebugExitDecision(35); }
					switch ( alt35 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:256:52: WS
						{
						DebugLocation(256, 52);
						WS59=(IToken)Match(input,WS,Follow._WS_in_global_alloc925); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS59);


						}
						break;

					default:
						goto loop35;
					}
				}

				loop35:
					;

				} finally { DebugExitSubRule(35); }

				DebugLocation(256, 56);
				PushFollow(Follow._type_name_in_global_alloc928);
				type_name60=type_name();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_type_name.Add(type_name60.Tree);
				DebugLocation(256, 66);
				// SugarCpp.g:256:66: ( ( WS )* ( '=' | ':=' ) ( WS )* where_expr -> ^( Expr_Alloc_Equal ( attribute )? ( 'extern' )? type_name ident_list ^( Expr_Args where_expr ) ) | ( WS )* bracket_expr_list -> ^( Expr_Alloc_Bracket ( attribute )? ( 'extern' )? type_name ident_list bracket_expr_list ) | -> ^( Expr_Alloc_Equal ( attribute )? ( 'extern' )? type_name ident_list ^( Expr_Args ) ) )
				int alt40=3;
				try { DebugEnterSubRule(40);
				try { DebugEnterDecision(40, false);
				try
				{
					alt40 = dfa40.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(40); }
				switch (alt40)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:256:68: ( WS )* ( '=' | ':=' ) ( WS )* where_expr
					{
					DebugLocation(256, 68);
					// SugarCpp.g:256:68: ( WS )*
					try { DebugEnterSubRule(36);
					while (true)
					{
						int alt36=2;
						try { DebugEnterDecision(36, false);
						int LA36_0 = input.LA(1);

						if ((LA36_0==WS))
						{
							alt36 = 1;
						}


						} finally { DebugExitDecision(36); }
						switch ( alt36 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:256:68: WS
							{
							DebugLocation(256, 68);
							WS61=(IToken)Match(input,WS,Follow._WS_in_global_alloc932); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS61);


							}
							break;

						default:
							goto loop36;
						}
					}

					loop36:
						;

					} finally { DebugExitSubRule(36); }

					DebugLocation(256, 72);
					// SugarCpp.g:256:72: ( '=' | ':=' )
					int alt37=2;
					try { DebugEnterSubRule(37);
					try { DebugEnterDecision(37, false);
					int LA37_0 = input.LA(1);

					if ((LA37_0==121))
					{
						alt37 = 1;
					}
					else if ((LA37_0==113))
					{
						alt37 = 2;
					}
					else
					{
						if (state.backtracking>0) {state.failed=true; return retval;}
						NoViableAltException nvae = new NoViableAltException("", 37, 0, input);
						DebugRecognitionException(nvae);
						throw nvae;
					}
					} finally { DebugExitDecision(37); }
					switch (alt37)
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:256:73: '='
						{
						DebugLocation(256, 73);
						char_literal62=(IToken)Match(input,121,Follow._121_in_global_alloc936); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_121.Add(char_literal62);


						}
						break;
					case 2:
						DebugEnterAlt(2);
						// SugarCpp.g:256:79: ':='
						{
						DebugLocation(256, 79);
						string_literal63=(IToken)Match(input,113,Follow._113_in_global_alloc940); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_113.Add(string_literal63);


						}
						break;

					}
					} finally { DebugExitSubRule(37); }

					DebugLocation(256, 85);
					// SugarCpp.g:256:85: ( WS )*
					try { DebugEnterSubRule(38);
					while (true)
					{
						int alt38=2;
						try { DebugEnterDecision(38, false);
						int LA38_0 = input.LA(1);

						if ((LA38_0==WS))
						{
							alt38 = 1;
						}


						} finally { DebugExitDecision(38); }
						switch ( alt38 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:256:85: WS
							{
							DebugLocation(256, 85);
							WS64=(IToken)Match(input,WS,Follow._WS_in_global_alloc943); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS64);


							}
							break;

						default:
							goto loop38;
						}
					}

					loop38:
						;

					} finally { DebugExitSubRule(38); }

					DebugLocation(256, 89);
					PushFollow(Follow._where_expr_in_global_alloc946);
					where_expr65=where_expr();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_where_expr.Add(where_expr65.Tree);


					{
					// AST REWRITE
					// elements: 147, type_name, attribute, where_expr, ident_list
					// 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 = (CommonTree)adaptor.Nil();
					// 256:100: -> ^( Expr_Alloc_Equal ( attribute )? ( 'extern' )? type_name ident_list ^( Expr_Args where_expr ) )
					{
						DebugLocation(256, 103);
						// SugarCpp.g:256:103: ^( Expr_Alloc_Equal ( attribute )? ( 'extern' )? type_name ident_list ^( Expr_Args where_expr ) )
						{
						CommonTree root_1 = (CommonTree)adaptor.Nil();
						DebugLocation(256, 105);
						root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Expr_Alloc_Equal, "Expr_Alloc_Equal"), root_1);

						DebugLocation(256, 122);
						// SugarCpp.g:256:122: ( attribute )?
						if (stream_attribute.HasNext)
						{
							DebugLocation(256, 122);
							adaptor.AddChild(root_1, stream_attribute.NextTree());

						}
						stream_attribute.Reset();
						DebugLocation(256, 133);
						// SugarCpp.g:256:133: ( 'extern' )?
						if (stream_147.HasNext)
						{
							DebugLocation(256, 133);
							adaptor.AddChild(root_1, stream_147.NextNode());

						}
						stream_147.Reset();
						DebugLocation(256, 143);
						adaptor.AddChild(root_1, stream_type_name.NextTree());
						DebugLocation(256, 153);
						adaptor.AddChild(root_1, stream_ident_list.NextTree());
						DebugLocation(256, 164);
						// SugarCpp.g:256:164: ^( Expr_Args where_expr )
						{
						CommonTree root_2 = (CommonTree)adaptor.Nil();
						DebugLocation(256, 166);
						root_2 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Expr_Args, "Expr_Args"), root_2);

						DebugLocation(256, 176);
						adaptor.AddChild(root_2, stream_where_expr.NextTree());

						adaptor.AddChild(root_1, root_2);
						}

						adaptor.AddChild(root_0, root_1);
						}

					}

					retval.Tree = root_0;
					}
					}

					}
					break;
				case 2:
					DebugEnterAlt(2);
					// SugarCpp.g:257:32: ( WS )* bracket_expr_list
					{
					DebugLocation(257, 32);
					// SugarCpp.g:257:32: ( WS )*
					try { DebugEnterSubRule(39);
					while (true)
					{
						int alt39=2;
						try { DebugEnterDecision(39, false);
						int LA39_0 = input.LA(1);

						if ((LA39_0==WS))
						{
							alt39 = 1;
						}


						} finally { DebugExitDecision(39); }
						switch ( alt39 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:257:32: WS
							{
							DebugLocation(257, 32);
							WS66=(IToken)Match(input,WS,Follow._WS_in_global_alloc1001); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS66);


							}
							break;

						default:
							goto loop39;
						}
					}

					loop39:
						;

					} finally { DebugExitSubRule(39); }

					DebugLocation(257, 36);
					PushFollow(Follow._bracket_expr_list_in_global_alloc1004);
					bracket_expr_list67=bracket_expr_list();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_bracket_expr_list.Add(bracket_expr_list67.Tree);


					{
					// AST REWRITE
					// elements: type_name, bracket_expr_list, 147, attribute, ident_list
					// 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 = (CommonTree)adaptor.Nil();
					// 257:54: -> ^( Expr_Alloc_Bracket ( attribute )? ( 'extern' )? type_name ident_list bracket_expr_list )
					{
						DebugLocation(257, 57);
						// SugarCpp.g:257:57: ^( Expr_Alloc_Bracket ( attribute )? ( 'extern' )? type_name ident_list bracket_expr_list )
						{
						CommonTree root_1 = (CommonTree)adaptor.Nil();
						DebugLocation(257, 59);
						root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Expr_Alloc_Bracket, "Expr_Alloc_Bracket"), root_1);

						DebugLocation(257, 78);
						// SugarCpp.g:257:78: ( attribute )?
						if (stream_attribute.HasNext)
						{
							DebugLocation(257, 78);
							adaptor.AddChild(root_1, stream_attribute.NextTree());

						}
						stream_attribute.Reset();
						DebugLocation(257, 89);
						// SugarCpp.g:257:89: ( 'extern' )?
						if (stream_147.HasNext)
						{
							DebugLocation(257, 89);
							adaptor.AddChild(root_1, stream_147.NextNode());

						}
						stream_147.Reset();
						DebugLocation(257, 99);
						adaptor.AddChild(root_1, stream_type_name.NextTree());
						DebugLocation(257, 109);
						adaptor.AddChild(root_1, stream_ident_list.NextTree());
						DebugLocation(257, 120);
						adaptor.AddChild(root_1, stream_bracket_expr_list.NextTree());

						adaptor.AddChild(root_0, root_1);
						}

					}

					retval.Tree = root_0;
					}
					}

					}
					break;
				case 3:
					DebugEnterAlt(3);
					// SugarCpp.g:258:33: 
					{

					{
					// AST REWRITE
					// elements: type_name, 147, ident_list, attribute
					// 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 = (CommonTree)adaptor.Nil();
					// 258:33: -> ^( Expr_Alloc_Equal ( attribute )? ( 'extern' )? type_name ident_list ^( Expr_Args ) )
					{
						DebugLocation(258, 36);
						// SugarCpp.g:258:36: ^( Expr_Alloc_Equal ( attribute )? ( 'extern' )? type_name ident_list ^( Expr_Args ) )
						{
						CommonTree root_1 = (CommonTree)adaptor.Nil();
						DebugLocation(258, 38);
						root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Expr_Alloc_Equal, "Expr_Alloc_Equal"), root_1);

						DebugLocation(258, 55);
						// SugarCpp.g:258:55: ( attribute )?
						if (stream_attribute.HasNext)
						{
							DebugLocation(258, 55);
							adaptor.AddChild(root_1, stream_attribute.NextTree());

						}
						stream_attribute.Reset();
						DebugLocation(258, 66);
						// SugarCpp.g:258:66: ( 'extern' )?
						if (stream_147.HasNext)
						{
							DebugLocation(258, 66);
							adaptor.AddChild(root_1, stream_147.NextNode());

						}
						stream_147.Reset();
						DebugLocation(258, 76);
						adaptor.AddChild(root_1, stream_type_name.NextTree());
						DebugLocation(258, 86);
						adaptor.AddChild(root_1, stream_ident_list.NextTree());
						DebugLocation(258, 97);
						// SugarCpp.g:258:97: ^( Expr_Args )
						{
						CommonTree root_2 = (CommonTree)adaptor.Nil();
						DebugLocation(258, 99);
						root_2 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Expr_Args, "Expr_Args"), root_2);

						adaptor.AddChild(root_1, root_2);
						}

						adaptor.AddChild(root_0, root_1);
						}

					}

					retval.Tree = root_0;
					}
					}

					}
					break;

				}
				} finally { DebugExitSubRule(40); }


				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarCpp.g:260:20: ( WS )* ':=' ( WS )* ( where_expr ( ( WS )* ',' ( WS )* where_expr )* )
				{
				DebugLocation(260, 20);
				// SugarCpp.g:260:20: ( WS )*
				try { DebugEnterSubRule(41);
				while (true)
				{
					int alt41=2;
					try { DebugEnterDecision(41, false);
					int LA41_0 = input.LA(1);

					if ((LA41_0==WS))
					{
						alt41 = 1;
					}


					} finally { DebugExitDecision(41); }
					switch ( alt41 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:260:20: WS
						{
						DebugLocation(260, 20);
						WS68=(IToken)Match(input,WS,Follow._WS_in_global_alloc1128); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS68);


						}
						break;

					default:
						goto loop41;
					}
				}

				loop41:
					;

				} finally { DebugExitSubRule(41); }

				DebugLocation(260, 24);
				string_literal69=(IToken)Match(input,113,Follow._113_in_global_alloc1131); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_113.Add(string_literal69);

				DebugLocation(260, 29);
				// SugarCpp.g:260:29: ( WS )*
				try { DebugEnterSubRule(42);
				while (true)
				{
					int alt42=2;
					try { DebugEnterDecision(42, false);
					int LA42_0 = input.LA(1);

					if ((LA42_0==WS))
					{
						alt42 = 1;
					}


					} finally { DebugExitDecision(42); }
					switch ( alt42 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:260:29: WS
						{
						DebugLocation(260, 29);
						WS70=(IToken)Match(input,WS,Follow._WS_in_global_alloc1133); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS70);


						}
						break;

					default:
						goto loop42;
					}
				}

				loop42:
					;

				} finally { DebugExitSubRule(42); }

				DebugLocation(260, 33);
				// SugarCpp.g:260:33: ( where_expr ( ( WS )* ',' ( WS )* where_expr )* )
				DebugEnterAlt(1);
				// SugarCpp.g:260:34: where_expr ( ( WS )* ',' ( WS )* where_expr )*
				{
				DebugLocation(260, 34);
				PushFollow(Follow._where_expr_in_global_alloc1137);
				where_expr71=where_expr();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_where_expr.Add(where_expr71.Tree);
				DebugLocation(260, 45);
				// SugarCpp.g:260:45: ( ( WS )* ',' ( WS )* where_expr )*
				try { DebugEnterSubRule(45);
				while (true)
				{
					int alt45=2;
					try { DebugEnterDecision(45, false);
					try
					{
						alt45 = dfa45.Predict(input);
					}
					catch (NoViableAltException nvae)
					{
						DebugRecognitionException(nvae);
						throw;
					}
					} finally { DebugExitDecision(45); }
					switch ( alt45 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:260:46: ( WS )* ',' ( WS )* where_expr
						{
						DebugLocation(260, 46);
						// SugarCpp.g:260:46: ( WS )*
						try { DebugEnterSubRule(43);
						while (true)
						{
							int alt43=2;
							try { DebugEnterDecision(43, false);
							int LA43_0 = input.LA(1);

							if ((LA43_0==WS))
							{
								alt43 = 1;
							}


							} finally { DebugExitDecision(43); }
							switch ( alt43 )
							{
							case 1:
								DebugEnterAlt(1);
								// SugarCpp.g:260:46: WS
								{
								DebugLocation(260, 46);
								WS72=(IToken)Match(input,WS,Follow._WS_in_global_alloc1140); if (state.failed) return retval; 
								if (state.backtracking == 0) stream_WS.Add(WS72);


								}
								break;

							default:
								goto loop43;
							}
						}

						loop43:
							;

						} finally { DebugExitSubRule(43); }

						DebugLocation(260, 50);
						char_literal73=(IToken)Match(input,100,Follow._100_in_global_alloc1143); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_100.Add(char_literal73);

						DebugLocation(260, 54);
						// SugarCpp.g:260:54: ( WS )*
						try { DebugEnterSubRule(44);
						while (true)
						{
							int alt44=2;
							try { DebugEnterDecision(44, false);
							int LA44_0 = input.LA(1);

							if ((LA44_0==WS))
							{
								alt44 = 1;
							}


							} finally { DebugExitDecision(44); }
							switch ( alt44 )
							{
							case 1:
								DebugEnterAlt(1);
								// SugarCpp.g:260:54: WS
								{
								DebugLocation(260, 54);
								WS74=(IToken)Match(input,WS,Follow._WS_in_global_alloc1145); if (state.failed) return retval; 
								if (state.backtracking == 0) stream_WS.Add(WS74);


								}
								break;

							default:
								goto loop44;
							}
						}

						loop44:
							;

						} finally { DebugExitSubRule(44); }

						DebugLocation(260, 58);
						PushFollow(Follow._where_expr_in_global_alloc1148);
						where_expr75=where_expr();
						PopFollow();
						if (state.failed) return retval;
						if (state.backtracking == 0) stream_where_expr.Add(where_expr75.Tree);

						}
						break;

					default:
						goto loop45;
					}
				}

				loop45:
					;

				} finally { DebugExitSubRule(45); }


				}



				{
				// AST REWRITE
				// elements: 113, ident_list, 147, where_expr, attribute
				// 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 = (CommonTree)adaptor.Nil();
				// 260:72: -> ^( ':=' ( attribute )? ( 'extern' )? ident_list ^( Expr_Args ( where_expr )+ ) )
				{
					DebugLocation(260, 75);
					// SugarCpp.g:260:75: ^( ':=' ( attribute )? ( 'extern' )? ident_list ^( Expr_Args ( where_expr )+ ) )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(260, 77);
					root_1 = (CommonTree)adaptor.BecomeRoot(stream_113.NextNode(), root_1);

					DebugLocation(260, 82);
					// SugarCpp.g:260:82: ( attribute )?
					if (stream_attribute.HasNext)
					{
						DebugLocation(260, 82);
						adaptor.AddChild(root_1, stream_attribute.NextTree());

					}
					stream_attribute.Reset();
					DebugLocation(260, 93);
					// SugarCpp.g:260:93: ( 'extern' )?
					if (stream_147.HasNext)
					{
						DebugLocation(260, 93);
						adaptor.AddChild(root_1, stream_147.NextNode());

					}
					stream_147.Reset();
					DebugLocation(260, 103);
					adaptor.AddChild(root_1, stream_ident_list.NextTree());
					DebugLocation(260, 114);
					// SugarCpp.g:260:114: ^( Expr_Args ( where_expr )+ )
					{
					CommonTree root_2 = (CommonTree)adaptor.Nil();
					DebugLocation(260, 116);
					root_2 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Expr_Args, "Expr_Args"), root_2);

					DebugLocation(260, 126);
					if (!(stream_where_expr.HasNext))
					{
						throw new RewriteEarlyExitException();
					}
					while ( stream_where_expr.HasNext )
					{
						DebugLocation(260, 126);
						adaptor.AddChild(root_2, stream_where_expr.NextTree());

					}
					stream_where_expr.Reset();

					adaptor.AddChild(root_1, root_2);
					}

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				break;

			}
			} finally { DebugExitSubRule(46); }


			}

			retval.Stop = (IToken)input.LT(-1);

			if (state.backtracking == 0) {
			retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("global_alloc", 8);
			LeaveRule("global_alloc", 8);
			LeaveRule_global_alloc();
		}
		DebugLocation(262, 1);
		} finally { DebugExitRule(GrammarFileName, "global_alloc"); }
		return retval;

	}
コード例 #4
0
	private AstParserRuleReturnScope<CommonTree, IToken> class_def()
	{
		EnterRule_class_def();
		EnterRule("class_def", 15);
		TraceIn("class_def", 15);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken string_literal130 = default(IToken);
		IToken WS131 = default(IToken);
		IToken string_literal132 = default(IToken);
		IToken WS133 = default(IToken);
		IToken WS136 = default(IToken);
		IToken char_literal137 = default(IToken);
		IToken WS138 = default(IToken);
		IToken WS140 = default(IToken);
		IToken char_literal141 = default(IToken);
		IToken WS142 = default(IToken);
		IToken WS144 = default(IToken);
		IToken NEWLINE145 = default(IToken);
		IToken INDENT146 = default(IToken);
		IToken NEWLINE147 = default(IToken);
		IToken DEDENT149 = default(IToken);
		IToken string_literal150 = default(IToken);
		IToken WS151 = default(IToken);
		IToken string_literal152 = default(IToken);
		IToken WS153 = default(IToken);
		IToken WS156 = default(IToken);
		IToken WS158 = default(IToken);
		IToken char_literal159 = default(IToken);
		IToken WS160 = default(IToken);
		IToken WS162 = default(IToken);
		IToken char_literal163 = default(IToken);
		IToken WS164 = default(IToken);
		IToken WS166 = default(IToken);
		IToken NEWLINE167 = default(IToken);
		IToken INDENT168 = default(IToken);
		IToken NEWLINE169 = default(IToken);
		IToken DEDENT171 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> attribute129 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident134 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> generic_parameter135 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident139 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident143 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> global_block148 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident154 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> generic_parameter155 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> class_args157 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident161 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident165 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> global_block170 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal130_tree = default(CommonTree);
		CommonTree WS131_tree = default(CommonTree);
		CommonTree string_literal132_tree = default(CommonTree);
		CommonTree WS133_tree = default(CommonTree);
		CommonTree WS136_tree = default(CommonTree);
		CommonTree char_literal137_tree = default(CommonTree);
		CommonTree WS138_tree = default(CommonTree);
		CommonTree WS140_tree = default(CommonTree);
		CommonTree char_literal141_tree = default(CommonTree);
		CommonTree WS142_tree = default(CommonTree);
		CommonTree WS144_tree = default(CommonTree);
		CommonTree NEWLINE145_tree = default(CommonTree);
		CommonTree INDENT146_tree = default(CommonTree);
		CommonTree NEWLINE147_tree = default(CommonTree);
		CommonTree DEDENT149_tree = default(CommonTree);
		CommonTree string_literal150_tree = default(CommonTree);
		CommonTree WS151_tree = default(CommonTree);
		CommonTree string_literal152_tree = default(CommonTree);
		CommonTree WS153_tree = default(CommonTree);
		CommonTree WS156_tree = default(CommonTree);
		CommonTree WS158_tree = default(CommonTree);
		CommonTree char_literal159_tree = default(CommonTree);
		CommonTree WS160_tree = default(CommonTree);
		CommonTree WS162_tree = default(CommonTree);
		CommonTree char_literal163_tree = default(CommonTree);
		CommonTree WS164_tree = default(CommonTree);
		CommonTree WS166_tree = default(CommonTree);
		CommonTree NEWLINE167_tree = default(CommonTree);
		CommonTree INDENT168_tree = default(CommonTree);
		CommonTree NEWLINE169_tree = default(CommonTree);
		CommonTree DEDENT171_tree = default(CommonTree);
		RewriteRuleITokenStream stream_163=new RewriteRuleITokenStream(adaptor,"token 163");
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_DEDENT=new RewriteRuleITokenStream(adaptor,"token DEDENT");
		RewriteRuleITokenStream stream_139=new RewriteRuleITokenStream(adaptor,"token 139");
		RewriteRuleITokenStream stream_NEWLINE=new RewriteRuleITokenStream(adaptor,"token NEWLINE");
		RewriteRuleITokenStream stream_111=new RewriteRuleITokenStream(adaptor,"token 111");
		RewriteRuleITokenStream stream_INDENT=new RewriteRuleITokenStream(adaptor,"token INDENT");
		RewriteRuleITokenStream stream_100=new RewriteRuleITokenStream(adaptor,"token 100");
		RewriteRuleITokenStream stream_141=new RewriteRuleITokenStream(adaptor,"token 141");
		RewriteRuleSubtreeStream stream_class_args=new RewriteRuleSubtreeStream(adaptor,"rule class_args");
		RewriteRuleSubtreeStream stream_ident=new RewriteRuleSubtreeStream(adaptor,"rule ident");
		RewriteRuleSubtreeStream stream_attribute=new RewriteRuleSubtreeStream(adaptor,"rule attribute");
		RewriteRuleSubtreeStream stream_global_block=new RewriteRuleSubtreeStream(adaptor,"rule global_block");
		RewriteRuleSubtreeStream stream_generic_parameter=new RewriteRuleSubtreeStream(adaptor,"rule generic_parameter");
		try { DebugEnterRule(GrammarFileName, "class_def");
		DebugLocation(290, 1);
		try
		{
			// SugarCpp.g:291:2: ( ( attribute )? ( 'public' ( WS )* )? ( 'class' ( WS )* ident ( generic_parameter )? ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )? -> ^( Class ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? ) | 'case' ( WS )* 'class' ( WS )* ident ( generic_parameter )? ( ( WS )* class_args )? ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )? -> ^( Class 'case' ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? ) ) )
			DebugEnterAlt(1);
			// SugarCpp.g:291:5: ( attribute )? ( 'public' ( WS )* )? ( 'class' ( WS )* ident ( generic_parameter )? ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )? -> ^( Class ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? ) | 'case' ( WS )* 'class' ( WS )* ident ( generic_parameter )? ( ( WS )* class_args )? ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )? -> ^( Class 'case' ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? ) )
			{
			DebugLocation(291, 5);
			// SugarCpp.g:291:5: ( attribute )?
			int alt82=2;
			try { DebugEnterSubRule(82);
			try { DebugEnterDecision(82, false);
			int LA82_0 = input.LA(1);

			if ((LA82_0==132))
			{
				alt82 = 1;
			}
			} finally { DebugExitDecision(82); }
			switch (alt82)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:291:5: attribute
				{
				DebugLocation(291, 5);
				PushFollow(Follow._attribute_in_class_def1504);
				attribute129=attribute();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_attribute.Add(attribute129.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(82); }

			DebugLocation(291, 16);
			// SugarCpp.g:291:16: ( 'public' ( WS )* )?
			int alt84=2;
			try { DebugEnterSubRule(84);
			try { DebugEnterDecision(84, false);
			int LA84_0 = input.LA(1);

			if ((LA84_0==163))
			{
				alt84 = 1;
			}
			} finally { DebugExitDecision(84); }
			switch (alt84)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:291:17: 'public' ( WS )*
				{
				DebugLocation(291, 17);
				string_literal130=(IToken)Match(input,163,Follow._163_in_class_def1508); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_163.Add(string_literal130);

				DebugLocation(291, 26);
				// SugarCpp.g:291:26: ( WS )*
				try { DebugEnterSubRule(83);
				while (true)
				{
					int alt83=2;
					try { DebugEnterDecision(83, false);
					int LA83_0 = input.LA(1);

					if ((LA83_0==WS))
					{
						alt83 = 1;
					}


					} finally { DebugExitDecision(83); }
					switch ( alt83 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:291:26: WS
						{
						DebugLocation(291, 26);
						WS131=(IToken)Match(input,WS,Follow._WS_in_class_def1510); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS131);


						}
						break;

					default:
						goto loop83;
					}
				}

				loop83:
					;

				} finally { DebugExitSubRule(83); }


				}
				break;

			}
			} finally { DebugExitSubRule(84); }

			DebugLocation(291, 32);
			// SugarCpp.g:291:32: ( 'class' ( WS )* ident ( generic_parameter )? ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )? -> ^( Class ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? ) | 'case' ( WS )* 'class' ( WS )* ident ( generic_parameter )? ( ( WS )* class_args )? ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )? -> ^( Class 'case' ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? ) )
			int alt112=2;
			try { DebugEnterSubRule(112);
			try { DebugEnterDecision(112, false);
			int LA112_0 = input.LA(1);

			if ((LA112_0==141))
			{
				alt112 = 1;
			}
			else if ((LA112_0==139))
			{
				alt112 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 112, 0, input);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(112); }
			switch (alt112)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:291:34: 'class' ( WS )* ident ( generic_parameter )? ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )?
				{
				DebugLocation(291, 34);
				string_literal132=(IToken)Match(input,141,Follow._141_in_class_def1517); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_141.Add(string_literal132);

				DebugLocation(291, 42);
				// SugarCpp.g:291:42: ( WS )*
				try { DebugEnterSubRule(85);
				while (true)
				{
					int alt85=2;
					try { DebugEnterDecision(85, false);
					int LA85_0 = input.LA(1);

					if ((LA85_0==WS))
					{
						alt85 = 1;
					}


					} finally { DebugExitDecision(85); }
					switch ( alt85 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:291:42: WS
						{
						DebugLocation(291, 42);
						WS133=(IToken)Match(input,WS,Follow._WS_in_class_def1519); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS133);


						}
						break;

					default:
						goto loop85;
					}
				}

				loop85:
					;

				} finally { DebugExitSubRule(85); }

				DebugLocation(291, 46);
				PushFollow(Follow._ident_in_class_def1522);
				ident134=ident();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_ident.Add(ident134.Tree);
				DebugLocation(291, 52);
				// SugarCpp.g:291:52: ( generic_parameter )?
				int alt86=2;
				try { DebugEnterSubRule(86);
				try { DebugEnterDecision(86, false);
				int LA86_0 = input.LA(1);

				if ((LA86_0==115))
				{
					alt86 = 1;
				}
				} finally { DebugExitDecision(86); }
				switch (alt86)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:291:53: generic_parameter
					{
					DebugLocation(291, 53);
					PushFollow(Follow._generic_parameter_in_class_def1525);
					generic_parameter135=generic_parameter();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_generic_parameter.Add(generic_parameter135.Tree);

					}
					break;

				}
				} finally { DebugExitSubRule(86); }

				DebugLocation(291, 73);
				// SugarCpp.g:291:73: ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )?
				int alt92=2;
				try { DebugEnterSubRule(92);
				try { DebugEnterDecision(92, false);
				try
				{
					alt92 = dfa92.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(92); }
				switch (alt92)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:291:74: ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )*
					{
					DebugLocation(291, 74);
					// SugarCpp.g:291:74: ( WS )*
					try { DebugEnterSubRule(87);
					while (true)
					{
						int alt87=2;
						try { DebugEnterDecision(87, false);
						int LA87_0 = input.LA(1);

						if ((LA87_0==WS))
						{
							alt87 = 1;
						}


						} finally { DebugExitDecision(87); }
						switch ( alt87 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:291:74: WS
							{
							DebugLocation(291, 74);
							WS136=(IToken)Match(input,WS,Follow._WS_in_class_def1530); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS136);


							}
							break;

						default:
							goto loop87;
						}
					}

					loop87:
						;

					} finally { DebugExitSubRule(87); }

					DebugLocation(291, 78);
					char_literal137=(IToken)Match(input,111,Follow._111_in_class_def1533); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_111.Add(char_literal137);

					DebugLocation(291, 82);
					// SugarCpp.g:291:82: ( WS )*
					try { DebugEnterSubRule(88);
					while (true)
					{
						int alt88=2;
						try { DebugEnterDecision(88, false);
						int LA88_0 = input.LA(1);

						if ((LA88_0==WS))
						{
							alt88 = 1;
						}


						} finally { DebugExitDecision(88); }
						switch ( alt88 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:291:82: WS
							{
							DebugLocation(291, 82);
							WS138=(IToken)Match(input,WS,Follow._WS_in_class_def1535); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS138);


							}
							break;

						default:
							goto loop88;
						}
					}

					loop88:
						;

					} finally { DebugExitSubRule(88); }

					DebugLocation(291, 86);
					PushFollow(Follow._ident_in_class_def1538);
					ident139=ident();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_ident.Add(ident139.Tree);
					DebugLocation(291, 92);
					// SugarCpp.g:291:92: ( ( WS )* ',' ( WS )* ident )*
					try { DebugEnterSubRule(91);
					while (true)
					{
						int alt91=2;
						try { DebugEnterDecision(91, false);
						try
						{
							alt91 = dfa91.Predict(input);
						}
						catch (NoViableAltException nvae)
						{
							DebugRecognitionException(nvae);
							throw;
						}
						} finally { DebugExitDecision(91); }
						switch ( alt91 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:291:93: ( WS )* ',' ( WS )* ident
							{
							DebugLocation(291, 93);
							// SugarCpp.g:291:93: ( WS )*
							try { DebugEnterSubRule(89);
							while (true)
							{
								int alt89=2;
								try { DebugEnterDecision(89, false);
								int LA89_0 = input.LA(1);

								if ((LA89_0==WS))
								{
									alt89 = 1;
								}


								} finally { DebugExitDecision(89); }
								switch ( alt89 )
								{
								case 1:
									DebugEnterAlt(1);
									// SugarCpp.g:291:93: WS
									{
									DebugLocation(291, 93);
									WS140=(IToken)Match(input,WS,Follow._WS_in_class_def1541); if (state.failed) return retval; 
									if (state.backtracking == 0) stream_WS.Add(WS140);


									}
									break;

								default:
									goto loop89;
								}
							}

							loop89:
								;

							} finally { DebugExitSubRule(89); }

							DebugLocation(291, 97);
							char_literal141=(IToken)Match(input,100,Follow._100_in_class_def1544); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_100.Add(char_literal141);

							DebugLocation(291, 101);
							// SugarCpp.g:291:101: ( WS )*
							try { DebugEnterSubRule(90);
							while (true)
							{
								int alt90=2;
								try { DebugEnterDecision(90, false);
								int LA90_0 = input.LA(1);

								if ((LA90_0==WS))
								{
									alt90 = 1;
								}


								} finally { DebugExitDecision(90); }
								switch ( alt90 )
								{
								case 1:
									DebugEnterAlt(1);
									// SugarCpp.g:291:101: WS
									{
									DebugLocation(291, 101);
									WS142=(IToken)Match(input,WS,Follow._WS_in_class_def1546); if (state.failed) return retval; 
									if (state.backtracking == 0) stream_WS.Add(WS142);


									}
									break;

								default:
									goto loop90;
								}
							}

							loop90:
								;

							} finally { DebugExitSubRule(90); }

							DebugLocation(291, 105);
							PushFollow(Follow._ident_in_class_def1549);
							ident143=ident();
							PopFollow();
							if (state.failed) return retval;
							if (state.backtracking == 0) stream_ident.Add(ident143.Tree);

							}
							break;

						default:
							goto loop91;
						}
					}

					loop91:
						;

					} finally { DebugExitSubRule(91); }


					}
					break;

				}
				} finally { DebugExitSubRule(92); }

				DebugLocation(291, 115);
				// SugarCpp.g:291:115: ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )?
				int alt96=2;
				try { DebugEnterSubRule(96);
				try { DebugEnterDecision(96, false);
				try
				{
					alt96 = dfa96.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(96); }
				switch (alt96)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:291:116: ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT
					{
					DebugLocation(291, 116);
					// SugarCpp.g:291:116: ( WS )*
					try { DebugEnterSubRule(93);
					while (true)
					{
						int alt93=2;
						try { DebugEnterDecision(93, false);
						int LA93_0 = input.LA(1);

						if ((LA93_0==WS))
						{
							alt93 = 1;
						}


						} finally { DebugExitDecision(93); }
						switch ( alt93 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:291:116: WS
							{
							DebugLocation(291, 116);
							WS144=(IToken)Match(input,WS,Follow._WS_in_class_def1556); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS144);


							}
							break;

						default:
							goto loop93;
						}
					}

					loop93:
						;

					} finally { DebugExitSubRule(93); }

					DebugLocation(291, 120);
					// SugarCpp.g:291:120: ( NEWLINE )+
					int cnt94=0;
					try { DebugEnterSubRule(94);
					while (true)
					{
						int alt94=2;
						try { DebugEnterDecision(94, false);
						int LA94_0 = input.LA(1);

						if ((LA94_0==NEWLINE))
						{
							alt94 = 1;
						}


						} finally { DebugExitDecision(94); }
						switch (alt94)
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:291:120: NEWLINE
							{
							DebugLocation(291, 120);
							NEWLINE145=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_class_def1559); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE145);


							}
							break;

						default:
							if (cnt94 >= 1)
								goto loop94;

							if (state.backtracking>0) {state.failed=true; return retval;}
							EarlyExitException eee94 = new EarlyExitException( 94, input );
							DebugRecognitionException(eee94);
							throw eee94;
						}
						cnt94++;
					}
					loop94:
						;

					} finally { DebugExitSubRule(94); }

					DebugLocation(291, 129);
					INDENT146=(IToken)Match(input,INDENT,Follow._INDENT_in_class_def1562); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_INDENT.Add(INDENT146);

					DebugLocation(291, 136);
					// SugarCpp.g:291:136: ( NEWLINE )*
					try { DebugEnterSubRule(95);
					while (true)
					{
						int alt95=2;
						try { DebugEnterDecision(95, false);
						int LA95_0 = input.LA(1);

						if ((LA95_0==NEWLINE))
						{
							alt95 = 1;
						}


						} finally { DebugExitDecision(95); }
						switch ( alt95 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:291:136: NEWLINE
							{
							DebugLocation(291, 136);
							NEWLINE147=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_class_def1564); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE147);


							}
							break;

						default:
							goto loop95;
						}
					}

					loop95:
						;

					} finally { DebugExitSubRule(95); }

					DebugLocation(291, 145);
					PushFollow(Follow._global_block_in_class_def1567);
					global_block148=global_block();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_global_block.Add(global_block148.Tree);
					DebugLocation(291, 158);
					DEDENT149=(IToken)Match(input,DEDENT,Follow._DEDENT_in_class_def1569); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_DEDENT.Add(DEDENT149);


					}
					break;

				}
				} finally { DebugExitSubRule(96); }



				{
				// AST REWRITE
				// elements: class_args, generic_parameter, ident, 163, attribute, global_block, ident
				// 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 = (CommonTree)adaptor.Nil();
				// 291:167: -> ^( Class ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? )
				{
					DebugLocation(291, 170);
					// SugarCpp.g:291:170: ^( Class ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(291, 172);
					root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Class, "Class"), root_1);

					DebugLocation(291, 178);
					// SugarCpp.g:291:178: ( 'public' )?
					if (stream_163.HasNext)
					{
						DebugLocation(291, 178);
						adaptor.AddChild(root_1, stream_163.NextNode());

					}
					stream_163.Reset();
					DebugLocation(291, 188);
					// SugarCpp.g:291:188: ( attribute )?
					if (stream_attribute.HasNext)
					{
						DebugLocation(291, 188);
						adaptor.AddChild(root_1, stream_attribute.NextTree());

					}
					stream_attribute.Reset();
					DebugLocation(291, 199);
					adaptor.AddChild(root_1, stream_ident.NextTree());
					DebugLocation(291, 205);
					// SugarCpp.g:291:205: ( generic_parameter )?
					if (stream_generic_parameter.HasNext)
					{
						DebugLocation(291, 205);
						adaptor.AddChild(root_1, stream_generic_parameter.NextTree());

					}
					stream_generic_parameter.Reset();
					DebugLocation(291, 224);
					// SugarCpp.g:291:224: ( class_args )?
					if (stream_class_args.HasNext)
					{
						DebugLocation(291, 224);
						adaptor.AddChild(root_1, stream_class_args.NextTree());

					}
					stream_class_args.Reset();
					DebugLocation(291, 236);
					// SugarCpp.g:291:236: ( ^( Ident_List ( ident )* ) )?
					if (stream_ident.HasNext)
					{
						DebugLocation(291, 237);
						// SugarCpp.g:291:237: ^( Ident_List ( ident )* )
						{
						CommonTree root_2 = (CommonTree)adaptor.Nil();
						DebugLocation(291, 239);
						root_2 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Ident_List, "Ident_List"), root_2);

						DebugLocation(291, 250);
						// SugarCpp.g:291:250: ( ident )*
						while ( stream_ident.HasNext )
						{
							DebugLocation(291, 250);
							adaptor.AddChild(root_2, stream_ident.NextTree());

						}
						stream_ident.Reset();

						adaptor.AddChild(root_1, root_2);
						}

					}
					stream_ident.Reset();
					DebugLocation(291, 260);
					// SugarCpp.g:291:260: ( global_block )?
					if (stream_global_block.HasNext)
					{
						DebugLocation(291, 260);
						adaptor.AddChild(root_1, stream_global_block.NextTree());

					}
					stream_global_block.Reset();

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarCpp.g:292:13: 'case' ( WS )* 'class' ( WS )* ident ( generic_parameter )? ( ( WS )* class_args )? ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )?
				{
				DebugLocation(292, 13);
				string_literal150=(IToken)Match(input,139,Follow._139_in_class_def1618); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_139.Add(string_literal150);

				DebugLocation(292, 20);
				// SugarCpp.g:292:20: ( WS )*
				try { DebugEnterSubRule(97);
				while (true)
				{
					int alt97=2;
					try { DebugEnterDecision(97, false);
					int LA97_0 = input.LA(1);

					if ((LA97_0==WS))
					{
						alt97 = 1;
					}


					} finally { DebugExitDecision(97); }
					switch ( alt97 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:292:20: WS
						{
						DebugLocation(292, 20);
						WS151=(IToken)Match(input,WS,Follow._WS_in_class_def1620); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS151);


						}
						break;

					default:
						goto loop97;
					}
				}

				loop97:
					;

				} finally { DebugExitSubRule(97); }

				DebugLocation(292, 24);
				string_literal152=(IToken)Match(input,141,Follow._141_in_class_def1623); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_141.Add(string_literal152);

				DebugLocation(292, 32);
				// SugarCpp.g:292:32: ( WS )*
				try { DebugEnterSubRule(98);
				while (true)
				{
					int alt98=2;
					try { DebugEnterDecision(98, false);
					int LA98_0 = input.LA(1);

					if ((LA98_0==WS))
					{
						alt98 = 1;
					}


					} finally { DebugExitDecision(98); }
					switch ( alt98 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:292:32: WS
						{
						DebugLocation(292, 32);
						WS153=(IToken)Match(input,WS,Follow._WS_in_class_def1625); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS153);


						}
						break;

					default:
						goto loop98;
					}
				}

				loop98:
					;

				} finally { DebugExitSubRule(98); }

				DebugLocation(292, 36);
				PushFollow(Follow._ident_in_class_def1628);
				ident154=ident();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_ident.Add(ident154.Tree);
				DebugLocation(292, 42);
				// SugarCpp.g:292:42: ( generic_parameter )?
				int alt99=2;
				try { DebugEnterSubRule(99);
				try { DebugEnterDecision(99, false);
				int LA99_0 = input.LA(1);

				if ((LA99_0==115))
				{
					alt99 = 1;
				}
				} finally { DebugExitDecision(99); }
				switch (alt99)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:292:43: generic_parameter
					{
					DebugLocation(292, 43);
					PushFollow(Follow._generic_parameter_in_class_def1631);
					generic_parameter155=generic_parameter();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_generic_parameter.Add(generic_parameter155.Tree);

					}
					break;

				}
				} finally { DebugExitSubRule(99); }

				DebugLocation(292, 63);
				// SugarCpp.g:292:63: ( ( WS )* class_args )?
				int alt101=2;
				try { DebugEnterSubRule(101);
				try { DebugEnterDecision(101, false);
				try
				{
					alt101 = dfa101.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(101); }
				switch (alt101)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:292:64: ( WS )* class_args
					{
					DebugLocation(292, 64);
					// SugarCpp.g:292:64: ( WS )*
					try { DebugEnterSubRule(100);
					while (true)
					{
						int alt100=2;
						try { DebugEnterDecision(100, false);
						int LA100_0 = input.LA(1);

						if ((LA100_0==WS))
						{
							alt100 = 1;
						}


						} finally { DebugExitDecision(100); }
						switch ( alt100 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:292:64: WS
							{
							DebugLocation(292, 64);
							WS156=(IToken)Match(input,WS,Follow._WS_in_class_def1636); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS156);


							}
							break;

						default:
							goto loop100;
						}
					}

					loop100:
						;

					} finally { DebugExitSubRule(100); }

					DebugLocation(292, 68);
					PushFollow(Follow._class_args_in_class_def1639);
					class_args157=class_args();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_class_args.Add(class_args157.Tree);

					}
					break;

				}
				} finally { DebugExitSubRule(101); }

				DebugLocation(292, 81);
				// SugarCpp.g:292:81: ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )?
				int alt107=2;
				try { DebugEnterSubRule(107);
				try { DebugEnterDecision(107, false);
				try
				{
					alt107 = dfa107.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(107); }
				switch (alt107)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:292:82: ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )*
					{
					DebugLocation(292, 82);
					// SugarCpp.g:292:82: ( WS )*
					try { DebugEnterSubRule(102);
					while (true)
					{
						int alt102=2;
						try { DebugEnterDecision(102, false);
						int LA102_0 = input.LA(1);

						if ((LA102_0==WS))
						{
							alt102 = 1;
						}


						} finally { DebugExitDecision(102); }
						switch ( alt102 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:292:82: WS
							{
							DebugLocation(292, 82);
							WS158=(IToken)Match(input,WS,Follow._WS_in_class_def1644); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS158);


							}
							break;

						default:
							goto loop102;
						}
					}

					loop102:
						;

					} finally { DebugExitSubRule(102); }

					DebugLocation(292, 86);
					char_literal159=(IToken)Match(input,111,Follow._111_in_class_def1647); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_111.Add(char_literal159);

					DebugLocation(292, 90);
					// SugarCpp.g:292:90: ( WS )*
					try { DebugEnterSubRule(103);
					while (true)
					{
						int alt103=2;
						try { DebugEnterDecision(103, false);
						int LA103_0 = input.LA(1);

						if ((LA103_0==WS))
						{
							alt103 = 1;
						}


						} finally { DebugExitDecision(103); }
						switch ( alt103 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:292:90: WS
							{
							DebugLocation(292, 90);
							WS160=(IToken)Match(input,WS,Follow._WS_in_class_def1649); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS160);


							}
							break;

						default:
							goto loop103;
						}
					}

					loop103:
						;

					} finally { DebugExitSubRule(103); }

					DebugLocation(292, 94);
					PushFollow(Follow._ident_in_class_def1652);
					ident161=ident();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_ident.Add(ident161.Tree);
					DebugLocation(292, 100);
					// SugarCpp.g:292:100: ( ( WS )* ',' ( WS )* ident )*
					try { DebugEnterSubRule(106);
					while (true)
					{
						int alt106=2;
						try { DebugEnterDecision(106, false);
						try
						{
							alt106 = dfa106.Predict(input);
						}
						catch (NoViableAltException nvae)
						{
							DebugRecognitionException(nvae);
							throw;
						}
						} finally { DebugExitDecision(106); }
						switch ( alt106 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:292:101: ( WS )* ',' ( WS )* ident
							{
							DebugLocation(292, 101);
							// SugarCpp.g:292:101: ( WS )*
							try { DebugEnterSubRule(104);
							while (true)
							{
								int alt104=2;
								try { DebugEnterDecision(104, false);
								int LA104_0 = input.LA(1);

								if ((LA104_0==WS))
								{
									alt104 = 1;
								}


								} finally { DebugExitDecision(104); }
								switch ( alt104 )
								{
								case 1:
									DebugEnterAlt(1);
									// SugarCpp.g:292:101: WS
									{
									DebugLocation(292, 101);
									WS162=(IToken)Match(input,WS,Follow._WS_in_class_def1655); if (state.failed) return retval; 
									if (state.backtracking == 0) stream_WS.Add(WS162);


									}
									break;

								default:
									goto loop104;
								}
							}

							loop104:
								;

							} finally { DebugExitSubRule(104); }

							DebugLocation(292, 105);
							char_literal163=(IToken)Match(input,100,Follow._100_in_class_def1658); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_100.Add(char_literal163);

							DebugLocation(292, 109);
							// SugarCpp.g:292:109: ( WS )*
							try { DebugEnterSubRule(105);
							while (true)
							{
								int alt105=2;
								try { DebugEnterDecision(105, false);
								int LA105_0 = input.LA(1);

								if ((LA105_0==WS))
								{
									alt105 = 1;
								}


								} finally { DebugExitDecision(105); }
								switch ( alt105 )
								{
								case 1:
									DebugEnterAlt(1);
									// SugarCpp.g:292:109: WS
									{
									DebugLocation(292, 109);
									WS164=(IToken)Match(input,WS,Follow._WS_in_class_def1660); if (state.failed) return retval; 
									if (state.backtracking == 0) stream_WS.Add(WS164);


									}
									break;

								default:
									goto loop105;
								}
							}

							loop105:
								;

							} finally { DebugExitSubRule(105); }

							DebugLocation(292, 113);
							PushFollow(Follow._ident_in_class_def1663);
							ident165=ident();
							PopFollow();
							if (state.failed) return retval;
							if (state.backtracking == 0) stream_ident.Add(ident165.Tree);

							}
							break;

						default:
							goto loop106;
						}
					}

					loop106:
						;

					} finally { DebugExitSubRule(106); }


					}
					break;

				}
				} finally { DebugExitSubRule(107); }

				DebugLocation(292, 123);
				// SugarCpp.g:292:123: ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )?
				int alt111=2;
				try { DebugEnterSubRule(111);
				try { DebugEnterDecision(111, false);
				try
				{
					alt111 = dfa111.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(111); }
				switch (alt111)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:292:124: ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT
					{
					DebugLocation(292, 124);
					// SugarCpp.g:292:124: ( WS )*
					try { DebugEnterSubRule(108);
					while (true)
					{
						int alt108=2;
						try { DebugEnterDecision(108, false);
						int LA108_0 = input.LA(1);

						if ((LA108_0==WS))
						{
							alt108 = 1;
						}


						} finally { DebugExitDecision(108); }
						switch ( alt108 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:292:124: WS
							{
							DebugLocation(292, 124);
							WS166=(IToken)Match(input,WS,Follow._WS_in_class_def1670); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS166);


							}
							break;

						default:
							goto loop108;
						}
					}

					loop108:
						;

					} finally { DebugExitSubRule(108); }

					DebugLocation(292, 128);
					// SugarCpp.g:292:128: ( NEWLINE )+
					int cnt109=0;
					try { DebugEnterSubRule(109);
					while (true)
					{
						int alt109=2;
						try { DebugEnterDecision(109, false);
						int LA109_0 = input.LA(1);

						if ((LA109_0==NEWLINE))
						{
							alt109 = 1;
						}


						} finally { DebugExitDecision(109); }
						switch (alt109)
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:292:128: NEWLINE
							{
							DebugLocation(292, 128);
							NEWLINE167=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_class_def1673); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE167);


							}
							break;

						default:
							if (cnt109 >= 1)
								goto loop109;

							if (state.backtracking>0) {state.failed=true; return retval;}
							EarlyExitException eee109 = new EarlyExitException( 109, input );
							DebugRecognitionException(eee109);
							throw eee109;
						}
						cnt109++;
					}
					loop109:
						;

					} finally { DebugExitSubRule(109); }

					DebugLocation(292, 137);
					INDENT168=(IToken)Match(input,INDENT,Follow._INDENT_in_class_def1676); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_INDENT.Add(INDENT168);

					DebugLocation(292, 144);
					// SugarCpp.g:292:144: ( NEWLINE )*
					try { DebugEnterSubRule(110);
					while (true)
					{
						int alt110=2;
						try { DebugEnterDecision(110, false);
						int LA110_0 = input.LA(1);

						if ((LA110_0==NEWLINE))
						{
							alt110 = 1;
						}


						} finally { DebugExitDecision(110); }
						switch ( alt110 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:292:144: NEWLINE
							{
							DebugLocation(292, 144);
							NEWLINE169=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_class_def1678); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE169);


							}
							break;

						default:
							goto loop110;
						}
					}

					loop110:
						;

					} finally { DebugExitSubRule(110); }

					DebugLocation(292, 153);
					PushFollow(Follow._global_block_in_class_def1681);
					global_block170=global_block();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_global_block.Add(global_block170.Tree);
					DebugLocation(292, 166);
					DEDENT171=(IToken)Match(input,DEDENT,Follow._DEDENT_in_class_def1683); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_DEDENT.Add(DEDENT171);


					}
					break;

				}
				} finally { DebugExitSubRule(111); }



				{
				// AST REWRITE
				// elements: ident, attribute, generic_parameter, 163, global_block, 139, class_args, ident
				// 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 = (CommonTree)adaptor.Nil();
				// 292:175: -> ^( Class 'case' ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? )
				{
					DebugLocation(292, 178);
					// SugarCpp.g:292:178: ^( Class 'case' ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(292, 180);
					root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Class, "Class"), root_1);

					DebugLocation(292, 186);
					adaptor.AddChild(root_1, stream_139.NextNode());
					DebugLocation(292, 193);
					// SugarCpp.g:292:193: ( 'public' )?
					if (stream_163.HasNext)
					{
						DebugLocation(292, 193);
						adaptor.AddChild(root_1, stream_163.NextNode());

					}
					stream_163.Reset();
					DebugLocation(292, 203);
					// SugarCpp.g:292:203: ( attribute )?
					if (stream_attribute.HasNext)
					{
						DebugLocation(292, 203);
						adaptor.AddChild(root_1, stream_attribute.NextTree());

					}
					stream_attribute.Reset();
					DebugLocation(292, 214);
					adaptor.AddChild(root_1, stream_ident.NextTree());
					DebugLocation(292, 220);
					// SugarCpp.g:292:220: ( generic_parameter )?
					if (stream_generic_parameter.HasNext)
					{
						DebugLocation(292, 220);
						adaptor.AddChild(root_1, stream_generic_parameter.NextTree());

					}
					stream_generic_parameter.Reset();
					DebugLocation(292, 239);
					// SugarCpp.g:292:239: ( class_args )?
					if (stream_class_args.HasNext)
					{
						DebugLocation(292, 239);
						adaptor.AddChild(root_1, stream_class_args.NextTree());

					}
					stream_class_args.Reset();
					DebugLocation(292, 251);
					// SugarCpp.g:292:251: ( ^( Ident_List ( ident )* ) )?
					if (stream_ident.HasNext)
					{
						DebugLocation(292, 252);
						// SugarCpp.g:292:252: ^( Ident_List ( ident )* )
						{
						CommonTree root_2 = (CommonTree)adaptor.Nil();
						DebugLocation(292, 254);
						root_2 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Ident_List, "Ident_List"), root_2);

						DebugLocation(292, 265);
						// SugarCpp.g:292:265: ( ident )*
						while ( stream_ident.HasNext )
						{
							DebugLocation(292, 265);
							adaptor.AddChild(root_2, stream_ident.NextTree());

						}
						stream_ident.Reset();

						adaptor.AddChild(root_1, root_2);
						}

					}
					stream_ident.Reset();
					DebugLocation(292, 275);
					// SugarCpp.g:292:275: ( global_block )?
					if (stream_global_block.HasNext)
					{
						DebugLocation(292, 275);
						adaptor.AddChild(root_1, stream_global_block.NextTree());

					}
					stream_global_block.Reset();

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				break;

			}
			} finally { DebugExitSubRule(112); }


			}

			retval.Stop = (IToken)input.LT(-1);

			if (state.backtracking == 0) {
			retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("class_def", 15);
			LeaveRule("class_def", 15);
			LeaveRule_class_def();
		}
		DebugLocation(294, 1);
		} finally { DebugExitRule(GrammarFileName, "class_def"); }
		return retval;

	}
コード例 #5
0
ファイル: ASParser.cs プロジェクト: nomilogic/fdplugins
        // throws RecognitionException [1]
        // $ANTLR start basicParameterDeclaration
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:635:1: basicParameterDeclaration : ( CONST )? ide= ident (type_exp= typeExpression )? ( parameterDefault )? -> ^( PARAM ( CONST )? ident ( typeExpression )? ( parameterDefault )? ) ;
        public basicParameterDeclaration_return basicParameterDeclaration()
        {
            basicParameterDeclaration_return retval = new basicParameterDeclaration_return();
            retval.start = input.LT(1);
            int basicParameterDeclaration_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken CONST68 = null;
            ident_return ide = null;

            typeExpression_return type_exp = null;

            parameterDefault_return parameterDefault69 = null;

            CommonTree CONST68_tree=null;
            RewriteRuleTokenStream stream_CONST = new RewriteRuleTokenStream(adaptor,"token CONST");
            RewriteRuleSubtreeStream stream_parameterDefault = new RewriteRuleSubtreeStream(adaptor,"rule parameterDefault");
            RewriteRuleSubtreeStream stream_ident = new RewriteRuleSubtreeStream(adaptor,"rule ident");
            RewriteRuleSubtreeStream stream_typeExpression = new RewriteRuleSubtreeStream(adaptor,"rule typeExpression");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 31) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:636:4: ( ( CONST )? ide= ident (type_exp= typeExpression )? ( parameterDefault )? -> ^( PARAM ( CONST )? ident ( typeExpression )? ( parameterDefault )? ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:636:4: ( CONST )? ide= ident (type_exp= typeExpression )? ( parameterDefault )?
            {
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:636:4: ( CONST )?
                int alt25 = 2;
                int LA25_0 = input.LA(1);

                if ( (LA25_0 == CONST) )
                {
                    alt25 = 1;
                }
                switch (alt25)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: CONST
                        {
                            CONST68 = (CommonToken)input.LT(1);
                            Match(input,CONST,FOLLOW_CONST_in_basicParameterDeclaration1807); if (failed) return retval;
                            if ( backtracking==0 ) stream_CONST.Add(CONST68);

                        }
                        break;

                }

                PushFollow(FOLLOW_ident_in_basicParameterDeclaration1815);
                ide = ident();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_ident.Add(ide.Tree);
                if ( backtracking == 0 )
                {
                   buffer.Append(((CommonTree)ide.Tree).Text);
                }
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:638:11: (type_exp= typeExpression )?
                int alt26 = 2;
                int LA26_0 = input.LA(1);

                if ( (LA26_0 == COLON) )
                {
                    alt26 = 1;
                }
                switch (alt26)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: type_exp= typeExpression
                        {
                            PushFollow(FOLLOW_typeExpression_in_basicParameterDeclaration1827);
                            type_exp = typeExpression();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_typeExpression.Add(type_exp.Tree);

                        }
                        break;

                }

                if ( backtracking == 0 )
                {

                }
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:639:3: ( parameterDefault )?
                int alt27 = 2;
                int LA27_0 = input.LA(1);

                if ( (LA27_0 == ASSIGN) )
                {
                    alt27 = 1;
                }
                switch (alt27)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: parameterDefault
                        {
                            PushFollow(FOLLOW_parameterDefault_in_basicParameterDeclaration1834);
                            parameterDefault69 = parameterDefault();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_parameterDefault.Add(parameterDefault69.Tree);

                        }
                        break;

                }

                // AST REWRITE
                // elements:          ident, CONST, parameterDefault, typeExpression
                // token labels:
                // rule labels:       retval
                // token list labels:
                // rule list labels:
                if ( backtracking==0 ) {
                retval.tree = root_0;
                RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "token retval", (retval!=null ? retval.Tree : null));

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 640:3: -> ^( PARAM ( CONST )? ident ( typeExpression )? ( parameterDefault )? )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:640:6: ^( PARAM ( CONST )? ident ( typeExpression )? ( parameterDefault )? )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(PARAM, "PARAM"), root_1);

                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:640:14: ( CONST )?
                    if ( stream_CONST.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_CONST.Next());

                    }
                    stream_CONST.Reset();
                    adaptor.AddChild(root_1, stream_ident.Next());
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:640:27: ( typeExpression )?
                    if ( stream_typeExpression.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_typeExpression.Next());

                    }
                    stream_typeExpression.Reset();
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:640:43: ( parameterDefault )?
                    if ( stream_parameterDefault.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_parameterDefault.Next());

                    }
                    stream_parameterDefault.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

            retval.stop = input.LT(-1);

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 31, basicParameterDeclaration_StartIndex);
            }
            }
            return retval;
        }
コード例 #6
0
	private AstParserRuleReturnScope<CommonTree, IToken> type_ident()
	{
		EnterRule_type_ident();
		EnterRule("type_ident", 22);
		TraceIn("type_ident", 22);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken string_literal230 = default(IToken);
		IToken WS231 = default(IToken);
		IToken string_literal232 = default(IToken);
		IToken WS233 = default(IToken);
		IToken string_literal234 = default(IToken);
		IToken WS235 = default(IToken);
		IToken string_literal236 = default(IToken);
		IToken WS237 = default(IToken);
		IToken string_literal238 = default(IToken);
		IToken WS239 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> ident240 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal230_tree = default(CommonTree);
		CommonTree WS231_tree = default(CommonTree);
		CommonTree string_literal232_tree = default(CommonTree);
		CommonTree WS233_tree = default(CommonTree);
		CommonTree string_literal234_tree = default(CommonTree);
		CommonTree WS235_tree = default(CommonTree);
		CommonTree string_literal236_tree = default(CommonTree);
		CommonTree WS237_tree = default(CommonTree);
		CommonTree string_literal238_tree = default(CommonTree);
		CommonTree WS239_tree = default(CommonTree);
		RewriteRuleITokenStream stream_170=new RewriteRuleITokenStream(adaptor,"token 170");
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_166=new RewriteRuleITokenStream(adaptor,"token 166");
		RewriteRuleITokenStream stream_156=new RewriteRuleITokenStream(adaptor,"token 156");
		RewriteRuleITokenStream stream_142=new RewriteRuleITokenStream(adaptor,"token 142");
		RewriteRuleITokenStream stream_167=new RewriteRuleITokenStream(adaptor,"token 167");
		RewriteRuleSubtreeStream stream_ident=new RewriteRuleSubtreeStream(adaptor,"rule ident");
		try { DebugEnterRule(GrammarFileName, "type_ident");
		DebugLocation(334, 1);
		try
		{
			// SugarCpp.g:335:2: ( ( 'static' ( WS )* )? ( 'const' ( WS )* )? ( 'struct' ( WS )* )? ( 'long' ( WS )* )? ( 'thread_local' ( WS )* )? ident -> ^( Type_Ident ( 'static' )? ( 'const' )? ( 'struct' )? ( 'long' )? ( 'thread_local' )? ident ) )
			DebugEnterAlt(1);
			// SugarCpp.g:335:4: ( 'static' ( WS )* )? ( 'const' ( WS )* )? ( 'struct' ( WS )* )? ( 'long' ( WS )* )? ( 'thread_local' ( WS )* )? ident
			{
			DebugLocation(335, 4);
			// SugarCpp.g:335:4: ( 'static' ( WS )* )?
			int alt154=2;
			try { DebugEnterSubRule(154);
			try { DebugEnterDecision(154, false);
			int LA154_0 = input.LA(1);

			if ((LA154_0==166))
			{
				alt154 = 1;
			}
			} finally { DebugExitDecision(154); }
			switch (alt154)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:335:5: 'static' ( WS )*
				{
				DebugLocation(335, 5);
				string_literal230=(IToken)Match(input,166,Follow._166_in_type_ident2206); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_166.Add(string_literal230);

				DebugLocation(335, 14);
				// SugarCpp.g:335:14: ( WS )*
				try { DebugEnterSubRule(153);
				while (true)
				{
					int alt153=2;
					try { DebugEnterDecision(153, false);
					int LA153_0 = input.LA(1);

					if ((LA153_0==WS))
					{
						alt153 = 1;
					}


					} finally { DebugExitDecision(153); }
					switch ( alt153 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:335:14: WS
						{
						DebugLocation(335, 14);
						WS231=(IToken)Match(input,WS,Follow._WS_in_type_ident2208); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS231);


						}
						break;

					default:
						goto loop153;
					}
				}

				loop153:
					;

				} finally { DebugExitSubRule(153); }


				}
				break;

			}
			} finally { DebugExitSubRule(154); }

			DebugLocation(335, 20);
			// SugarCpp.g:335:20: ( 'const' ( WS )* )?
			int alt156=2;
			try { DebugEnterSubRule(156);
			try { DebugEnterDecision(156, false);
			int LA156_0 = input.LA(1);

			if ((LA156_0==142))
			{
				alt156 = 1;
			}
			} finally { DebugExitDecision(156); }
			switch (alt156)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:335:21: 'const' ( WS )*
				{
				DebugLocation(335, 21);
				string_literal232=(IToken)Match(input,142,Follow._142_in_type_ident2214); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_142.Add(string_literal232);

				DebugLocation(335, 29);
				// SugarCpp.g:335:29: ( WS )*
				try { DebugEnterSubRule(155);
				while (true)
				{
					int alt155=2;
					try { DebugEnterDecision(155, false);
					int LA155_0 = input.LA(1);

					if ((LA155_0==WS))
					{
						alt155 = 1;
					}


					} finally { DebugExitDecision(155); }
					switch ( alt155 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:335:29: WS
						{
						DebugLocation(335, 29);
						WS233=(IToken)Match(input,WS,Follow._WS_in_type_ident2216); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS233);


						}
						break;

					default:
						goto loop155;
					}
				}

				loop155:
					;

				} finally { DebugExitSubRule(155); }


				}
				break;

			}
			} finally { DebugExitSubRule(156); }

			DebugLocation(335, 35);
			// SugarCpp.g:335:35: ( 'struct' ( WS )* )?
			int alt158=2;
			try { DebugEnterSubRule(158);
			try { DebugEnterDecision(158, false);
			int LA158_0 = input.LA(1);

			if ((LA158_0==167))
			{
				alt158 = 1;
			}
			} finally { DebugExitDecision(158); }
			switch (alt158)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:335:36: 'struct' ( WS )*
				{
				DebugLocation(335, 36);
				string_literal234=(IToken)Match(input,167,Follow._167_in_type_ident2222); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_167.Add(string_literal234);

				DebugLocation(335, 45);
				// SugarCpp.g:335:45: ( WS )*
				try { DebugEnterSubRule(157);
				while (true)
				{
					int alt157=2;
					try { DebugEnterDecision(157, false);
					int LA157_0 = input.LA(1);

					if ((LA157_0==WS))
					{
						alt157 = 1;
					}


					} finally { DebugExitDecision(157); }
					switch ( alt157 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:335:45: WS
						{
						DebugLocation(335, 45);
						WS235=(IToken)Match(input,WS,Follow._WS_in_type_ident2224); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS235);


						}
						break;

					default:
						goto loop157;
					}
				}

				loop157:
					;

				} finally { DebugExitSubRule(157); }


				}
				break;

			}
			} finally { DebugExitSubRule(158); }

			DebugLocation(335, 51);
			// SugarCpp.g:335:51: ( 'long' ( WS )* )?
			int alt160=2;
			try { DebugEnterSubRule(160);
			try { DebugEnterDecision(160, false);
			int LA160_0 = input.LA(1);

			if ((LA160_0==156))
			{
				alt160 = 1;
			}
			} finally { DebugExitDecision(160); }
			switch (alt160)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:335:52: 'long' ( WS )*
				{
				DebugLocation(335, 52);
				string_literal236=(IToken)Match(input,156,Follow._156_in_type_ident2230); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_156.Add(string_literal236);

				DebugLocation(335, 59);
				// SugarCpp.g:335:59: ( WS )*
				try { DebugEnterSubRule(159);
				while (true)
				{
					int alt159=2;
					try { DebugEnterDecision(159, false);
					int LA159_0 = input.LA(1);

					if ((LA159_0==WS))
					{
						alt159 = 1;
					}


					} finally { DebugExitDecision(159); }
					switch ( alt159 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:335:59: WS
						{
						DebugLocation(335, 59);
						WS237=(IToken)Match(input,WS,Follow._WS_in_type_ident2232); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS237);


						}
						break;

					default:
						goto loop159;
					}
				}

				loop159:
					;

				} finally { DebugExitSubRule(159); }


				}
				break;

			}
			} finally { DebugExitSubRule(160); }

			DebugLocation(335, 65);
			// SugarCpp.g:335:65: ( 'thread_local' ( WS )* )?
			int alt162=2;
			try { DebugEnterSubRule(162);
			try { DebugEnterDecision(162, false);
			int LA162_0 = input.LA(1);

			if ((LA162_0==170))
			{
				alt162 = 1;
			}
			} finally { DebugExitDecision(162); }
			switch (alt162)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:335:66: 'thread_local' ( WS )*
				{
				DebugLocation(335, 66);
				string_literal238=(IToken)Match(input,170,Follow._170_in_type_ident2238); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_170.Add(string_literal238);

				DebugLocation(335, 81);
				// SugarCpp.g:335:81: ( WS )*
				try { DebugEnterSubRule(161);
				while (true)
				{
					int alt161=2;
					try { DebugEnterDecision(161, false);
					int LA161_0 = input.LA(1);

					if ((LA161_0==WS))
					{
						alt161 = 1;
					}


					} finally { DebugExitDecision(161); }
					switch ( alt161 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:335:81: WS
						{
						DebugLocation(335, 81);
						WS239=(IToken)Match(input,WS,Follow._WS_in_type_ident2240); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS239);


						}
						break;

					default:
						goto loop161;
					}
				}

				loop161:
					;

				} finally { DebugExitSubRule(161); }


				}
				break;

			}
			} finally { DebugExitSubRule(162); }

			DebugLocation(335, 87);
			PushFollow(Follow._ident_in_type_ident2245);
			ident240=ident();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_ident.Add(ident240.Tree);


			{
			// AST REWRITE
			// elements: ident, 142, 167, 170, 156, 166
			// 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 = (CommonTree)adaptor.Nil();
			// 335:93: -> ^( Type_Ident ( 'static' )? ( 'const' )? ( 'struct' )? ( 'long' )? ( 'thread_local' )? ident )
			{
				DebugLocation(335, 96);
				// SugarCpp.g:335:96: ^( Type_Ident ( 'static' )? ( 'const' )? ( 'struct' )? ( 'long' )? ( 'thread_local' )? ident )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(335, 98);
				root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Type_Ident, "Type_Ident"), root_1);

				DebugLocation(335, 109);
				// SugarCpp.g:335:109: ( 'static' )?
				if (stream_166.HasNext)
				{
					DebugLocation(335, 109);
					adaptor.AddChild(root_1, stream_166.NextNode());

				}
				stream_166.Reset();
				DebugLocation(335, 119);
				// SugarCpp.g:335:119: ( 'const' )?
				if (stream_142.HasNext)
				{
					DebugLocation(335, 119);
					adaptor.AddChild(root_1, stream_142.NextNode());

				}
				stream_142.Reset();
				DebugLocation(335, 128);
				// SugarCpp.g:335:128: ( 'struct' )?
				if (stream_167.HasNext)
				{
					DebugLocation(335, 128);
					adaptor.AddChild(root_1, stream_167.NextNode());

				}
				stream_167.Reset();
				DebugLocation(335, 138);
				// SugarCpp.g:335:138: ( 'long' )?
				if (stream_156.HasNext)
				{
					DebugLocation(335, 138);
					adaptor.AddChild(root_1, stream_156.NextNode());

				}
				stream_156.Reset();
				DebugLocation(335, 146);
				// SugarCpp.g:335:146: ( 'thread_local' )?
				if (stream_170.HasNext)
				{
					DebugLocation(335, 146);
					adaptor.AddChild(root_1, stream_170.NextNode());

				}
				stream_170.Reset();
				DebugLocation(335, 162);
				adaptor.AddChild(root_1, stream_ident.NextTree());

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			if (state.backtracking == 0) {
			retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("type_ident", 22);
			LeaveRule("type_ident", 22);
			LeaveRule_type_ident();
		}
		DebugLocation(336, 1);
		} finally { DebugExitRule(GrammarFileName, "type_ident"); }
		return retval;

	}
コード例 #7
0
ファイル: PsimulexParser.cs プロジェクト: hunpody/psimulex
    // $ANTLR start "functionDeclaration"
    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:177:1: functionDeclaration : type ( Reference )? Identifier formalParameterList block -> ^( FUNCDEC type ( Reference )? Identifier ( formalParameterList )? block ) ;
    public PsimulexParser.functionDeclaration_return functionDeclaration() // throws RecognitionException [1]
    {   
        PsimulexParser.functionDeclaration_return retval = new PsimulexParser.functionDeclaration_return();
        retval.Start = input.LT(1);
        int functionDeclaration_StartIndex = input.Index();
        CommonTree root_0 = null;

        IToken Reference32 = null;
        IToken Identifier33 = null;
        PsimulexParser.type_return type31 = default(PsimulexParser.type_return);

        PsimulexParser.formalParameterList_return formalParameterList34 = default(PsimulexParser.formalParameterList_return);

        PsimulexParser.block_return block35 = default(PsimulexParser.block_return);


        CommonTree Reference32_tree=null;
        CommonTree Identifier33_tree=null;
        RewriteRuleTokenStream stream_Reference = new RewriteRuleTokenStream(adaptor,"token Reference");
        RewriteRuleTokenStream stream_Identifier = new RewriteRuleTokenStream(adaptor,"token Identifier");
        RewriteRuleSubtreeStream stream_block = new RewriteRuleSubtreeStream(adaptor,"rule block");
        RewriteRuleSubtreeStream stream_type = new RewriteRuleSubtreeStream(adaptor,"rule type");
        RewriteRuleSubtreeStream stream_formalParameterList = new RewriteRuleSubtreeStream(adaptor,"rule formalParameterList");
        try 
    	{
    	    if ( (state.backtracking > 0) && AlreadyParsedRule(input, 12) ) 
    	    {
    	    	return retval; 
    	    }
            // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:178:5: ( type ( Reference )? Identifier formalParameterList block -> ^( FUNCDEC type ( Reference )? Identifier ( formalParameterList )? block ) )
            // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:178:7: type ( Reference )? Identifier formalParameterList block
            {
            	PushFollow(FOLLOW_type_in_functionDeclaration769);
            	type31 = type();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( (state.backtracking==0) ) stream_type.Add(type31.Tree);
            	// C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:178:12: ( Reference )?
            	int alt10 = 2;
            	int LA10_0 = input.LA(1);

            	if ( (LA10_0 == Reference) )
            	{
            	    alt10 = 1;
            	}
            	switch (alt10) 
            	{
            	    case 1 :
            	        // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:0:0: Reference
            	        {
            	        	Reference32=(IToken)Match(input,Reference,FOLLOW_Reference_in_functionDeclaration771); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_Reference.Add(Reference32);


            	        }
            	        break;

            	}

            	Identifier33=(IToken)Match(input,Identifier,FOLLOW_Identifier_in_functionDeclaration774); if (state.failed) return retval; 
            	if ( (state.backtracking==0) ) stream_Identifier.Add(Identifier33);

            	PushFollow(FOLLOW_formalParameterList_in_functionDeclaration776);
            	formalParameterList34 = formalParameterList();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( (state.backtracking==0) ) stream_formalParameterList.Add(formalParameterList34.Tree);
            	PushFollow(FOLLOW_block_in_functionDeclaration779);
            	block35 = block();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( (state.backtracking==0) ) stream_block.Add(block35.Tree);


            	// AST REWRITE
            	// elements:          block, Identifier, type, formalParameterList, Reference
            	// 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 = (CommonTree)adaptor.GetNilNode();
            	// 178:61: -> ^( FUNCDEC type ( Reference )? Identifier ( formalParameterList )? block )
            	{
            	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:178:64: ^( FUNCDEC type ( Reference )? Identifier ( formalParameterList )? block )
            	    {
            	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
            	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(FUNCDEC, "FUNCDEC"), root_1);

            	    adaptor.AddChild(root_1, stream_type.NextTree());
            	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:178:80: ( Reference )?
            	    if ( stream_Reference.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_Reference.NextNode());

            	    }
            	    stream_Reference.Reset();
            	    adaptor.AddChild(root_1, stream_Identifier.NextNode());
            	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:178:102: ( formalParameterList )?
            	    if ( stream_formalParameterList.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_formalParameterList.NextTree());

            	    }
            	    stream_formalParameterList.Reset();
            	    adaptor.AddChild(root_1, stream_block.NextTree());

            	    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 = (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 
    	{
            if ( state.backtracking > 0 ) 
            {
            	Memoize(input, 12, functionDeclaration_StartIndex); 
            }
        }
        return retval;
    }
コード例 #8
0
ファイル: ASParser.cs プロジェクト: nomilogic/fdplugins
        // throws RecognitionException [1]
        // $ANTLR start identifierStar
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1049:1: identifierStar : ide= ident ( options {greedy=true; } : DOT ide2= ident )* ( DOT STAR )? -> ^( IDENTIFIER ( ident )+ ( STAR )? ) ;
        public identifierStar_return identifierStar()
        {
            identifierStar_return retval = new identifierStar_return();
            retval.start = input.LT(1);
            int identifierStar_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken DOT178 = null;
            CommonToken DOT179 = null;
            CommonToken STAR180 = null;
            ident_return ide = null;

            ident_return ide2 = null;

            CommonTree DOT178_tree=null;
            CommonTree DOT179_tree=null;
            CommonTree STAR180_tree=null;
            RewriteRuleTokenStream stream_STAR = new RewriteRuleTokenStream(adaptor,"token STAR");
            RewriteRuleTokenStream stream_DOT = new RewriteRuleTokenStream(adaptor,"token DOT");
            RewriteRuleSubtreeStream stream_ident = new RewriteRuleSubtreeStream(adaptor,"rule ident");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 69) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1050:4: (ide= ident ( options {greedy=true; } : DOT ide2= ident )* ( DOT STAR )? -> ^( IDENTIFIER ( ident )+ ( STAR )? ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1050:4: ide= ident ( options {greedy=true; } : DOT ide2= ident )* ( DOT STAR )?
            {
                PushFollow(FOLLOW_ident_in_identifierStar3335);
                ide = ident();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_ident.Add(ide.Tree);
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1051:3: ( options {greedy=true; } : DOT ide2= ident )*
                do
                {
                    int alt48 = 2;
                    int LA48_0 = input.LA(1);

                    if ( (LA48_0 == DOT) )
                    {
                        int LA48_1 = input.LA(2);

                        if ( ((LA48_1 >= GET && LA48_1 <= SET) || LA48_1 == IDENT || LA48_1 == DYNAMIC || (LA48_1 >= IS && LA48_1 <= AS) || (LA48_1 >= USE && LA48_1 <= XML)) )
                        {
                            alt48 = 1;
                        }

                    }

                    switch (alt48)
                    {
                        case 1 :
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1052:5: DOT ide2= ident
                            {
                                DOT178 = (CommonToken)input.LT(1);
                                Match(input,DOT,FOLLOW_DOT_in_identifierStar3357); if (failed) return retval;
                                if ( backtracking==0 ) stream_DOT.Add(DOT178);

                                PushFollow(FOLLOW_ident_in_identifierStar3361);
                                ide2 = ident();
                                followingStackPointer_--;
                                if (failed) return retval;
                                if ( backtracking==0 ) stream_ident.Add(ide2.Tree);

                            }
                            break;

                        default:
                            goto loop48;
                    }
                } while (true);

                loop48:
                    ;	// Stops C# compiler whinging that label 'loop48' has no statements

                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1054:3: ( DOT STAR )?
                int alt49 = 2;
                int LA49_0 = input.LA(1);

                if ( (LA49_0 == DOT) )
                {
                    alt49 = 1;
                }
                switch (alt49)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1054:5: DOT STAR
                        {
                            DOT179 = (CommonToken)input.LT(1);
                            Match(input,DOT,FOLLOW_DOT_in_identifierStar3376); if (failed) return retval;
                            if ( backtracking==0 ) stream_DOT.Add(DOT179);

                            STAR180 = (CommonToken)input.LT(1);
                            Match(input,STAR,FOLLOW_STAR_in_identifierStar3378); if (failed) return retval;
                            if ( backtracking==0 ) stream_STAR.Add(STAR180);

                        }
                        break;

                }

                // AST REWRITE
                // elements:          STAR, ident
                // token labels:
                // rule labels:       retval
                // token list labels:
                // rule list labels:
                if ( backtracking==0 ) {
                retval.tree = root_0;
                RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "token retval", (retval!=null ? retval.Tree : null));

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 1056:3: -> ^( IDENTIFIER ( ident )+ ( STAR )? )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1056:6: ^( IDENTIFIER ( ident )+ ( STAR )? )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(IDENTIFIER, "IDENTIFIER"), root_1);

                    if ( !(stream_ident.HasNext()) ) {
                        throw new RewriteEarlyExitException();
                    }
                    while ( stream_ident.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_ident.Next());

                    }
                    stream_ident.Reset();
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1056:26: ( STAR )?
                    if ( stream_STAR.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_STAR.Next());

                    }
                    stream_STAR.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

            retval.stop = input.LT(-1);

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 69, identifierStar_StartIndex);
            }
            }
            return retval;
        }
コード例 #9
0
    // $ANTLR start "id_list"
    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:586:1: id_list : a= ID ( ',' b+= ID )* -> ^( ID_LIST $a ( $b)* ) ;
    public BlaiseParser.id_list_return id_list() // throws RecognitionException [1]
    {   
        BlaiseParser.id_list_return retval = new BlaiseParser.id_list_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken a = null;
        IToken char_literal2 = null;
        IToken b = null;
        IList list_b = null;

        object a_tree=null;
        object char_literal2_tree=null;
        object b_tree=null;
        RewriteRuleTokenStream stream_ID = new RewriteRuleTokenStream(adaptor,"token ID");
        RewriteRuleTokenStream stream_COMMA = new RewriteRuleTokenStream(adaptor,"token COMMA");

        try 
    	{
            // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:586:9: (a= ID ( ',' b+= ID )* -> ^( ID_LIST $a ( $b)* ) )
            // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:586:11: a= ID ( ',' b+= ID )*
            {
            	a=(IToken)Match(input,ID,FOLLOW_ID_in_id_list3375); if (state.failed) return retval; 
            	if ( (state.backtracking==0) ) stream_ID.Add(a);

            	// C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:586:16: ( ',' b+= ID )*
            	do 
            	{
            	    int alt2 = 2;
            	    int LA2_0 = input.LA(1);

            	    if ( (LA2_0 == COMMA) )
            	    {
            	        alt2 = 1;
            	    }


            	    switch (alt2) 
            		{
            			case 1 :
            			    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:586:17: ',' b+= ID
            			    {
            			    	char_literal2=(IToken)Match(input,COMMA,FOLLOW_COMMA_in_id_list3378); if (state.failed) return retval; 
            			    	if ( (state.backtracking==0) ) stream_COMMA.Add(char_literal2);

            			    	b=(IToken)Match(input,ID,FOLLOW_ID_in_id_list3382); if (state.failed) return retval; 
            			    	if ( (state.backtracking==0) ) stream_ID.Add(b);

            			    	if (list_b == null) list_b = new ArrayList();
            			    	list_b.Add(b);


            			    }
            			    break;

            			default:
            			    goto loop2;
            	    }
            	} while (true);

            	loop2:
            		;	// Stops C# compiler whining that label 'loop2' has no statements



            	// AST REWRITE
            	// elements:          b, a
            	// token labels:      a
            	// rule labels:       retval
            	// token list labels: b
            	// rule list labels:  
            	// wildcard labels: 
            	if ( (state.backtracking==0) ) {
            	retval.Tree = root_0;
            	RewriteRuleTokenStream stream_a = new RewriteRuleTokenStream(adaptor, "token a", a);
            	RewriteRuleTokenStream stream_b = new RewriteRuleTokenStream(adaptor,"token b", list_b);
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

            	root_0 = (object)adaptor.GetNilNode();
            	// 586:29: -> ^( ID_LIST $a ( $b)* )
            	{
            	    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:586:32: ^( ID_LIST $a ( $b)* )
            	    {
            	    object root_1 = (object)adaptor.GetNilNode();
            	    root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(ID_LIST, "ID_LIST"), root_1);

            	    adaptor.AddChild(root_1, stream_a.NextNode());
            	    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:586:45: ( $b)*
            	    while ( stream_b.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_b.NextNode());

            	    }
            	    stream_b.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 
    	{
        }
        return retval;
    }
コード例 #10
0
ファイル: PsimulexParser.cs プロジェクト: hunpody/psimulex
    // $ANTLR start "arrayType"
    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:156:1: arrayType : '[' ( ',' )* ']' -> ^( DIMMARKER '[' ( ',' )* ']' ) ;
    public PsimulexParser.arrayType_return arrayType() // throws RecognitionException [1]
    {   
        PsimulexParser.arrayType_return retval = new PsimulexParser.arrayType_return();
        retval.Start = input.LT(1);
        int arrayType_StartIndex = input.Index();
        CommonTree root_0 = null;

        IToken char_literal27 = null;
        IToken char_literal28 = null;
        IToken char_literal29 = null;

        CommonTree char_literal27_tree=null;
        CommonTree char_literal28_tree=null;
        CommonTree char_literal29_tree=null;
        RewriteRuleTokenStream stream_146 = new RewriteRuleTokenStream(adaptor,"token 146");
        RewriteRuleTokenStream stream_147 = new RewriteRuleTokenStream(adaptor,"token 147");
        RewriteRuleTokenStream stream_148 = new RewriteRuleTokenStream(adaptor,"token 148");

        try 
    	{
    	    if ( (state.backtracking > 0) && AlreadyParsedRule(input, 10) ) 
    	    {
    	    	return retval; 
    	    }
            // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:157:2: ( '[' ( ',' )* ']' -> ^( DIMMARKER '[' ( ',' )* ']' ) )
            // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:157:4: '[' ( ',' )* ']'
            {
            	char_literal27=(IToken)Match(input,146,FOLLOW_146_in_arrayType688); if (state.failed) return retval; 
            	if ( (state.backtracking==0) ) stream_146.Add(char_literal27);

            	// C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:157:8: ( ',' )*
            	do 
            	{
            	    int alt8 = 2;
            	    int LA8_0 = input.LA(1);

            	    if ( (LA8_0 == 147) )
            	    {
            	        alt8 = 1;
            	    }


            	    switch (alt8) 
            		{
            			case 1 :
            			    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:157:10: ','
            			    {
            			    	char_literal28=(IToken)Match(input,147,FOLLOW_147_in_arrayType692); if (state.failed) return retval; 
            			    	if ( (state.backtracking==0) ) stream_147.Add(char_literal28);


            			    }
            			    break;

            			default:
            			    goto loop8;
            	    }
            	} while (true);

            	loop8:
            		;	// Stops C# compiler whining that label 'loop8' has no statements

            	char_literal29=(IToken)Match(input,148,FOLLOW_148_in_arrayType697); if (state.failed) return retval; 
            	if ( (state.backtracking==0) ) stream_148.Add(char_literal29);



            	// AST REWRITE
            	// elements:          147, 148, 146
            	// 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 = (CommonTree)adaptor.GetNilNode();
            	// 157:21: -> ^( DIMMARKER '[' ( ',' )* ']' )
            	{
            	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:157:24: ^( DIMMARKER '[' ( ',' )* ']' )
            	    {
            	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
            	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(DIMMARKER, "DIMMARKER"), root_1);

            	    adaptor.AddChild(root_1, stream_146.NextNode());
            	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:157:41: ( ',' )*
            	    while ( stream_147.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_147.NextNode());

            	    }
            	    stream_147.Reset();
            	    adaptor.AddChild(root_1, stream_148.NextNode());

            	    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 = (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 
    	{
            if ( state.backtracking > 0 ) 
            {
            	Memoize(input, 10, arrayType_StartIndex); 
            }
        }
        return retval;
    }
コード例 #11
0
    // $ANTLR start "table"
    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:697:1: table : ( EMBEDDED )? TABLE a= ID (b= QSTRING )? ( block_settings )? submodel ( ENDTABLE | ENDBLOCK ) -> ^( BLOCK ^( LABEL $a ( $b)? ) submodel ) ;
    public BlaiseParser.table_return table() // throws RecognitionException [1]
    {   
        BlaiseParser.table_return retval = new BlaiseParser.table_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken a = null;
        IToken b = null;
        IToken EMBEDDED88 = null;
        IToken TABLE89 = null;
        IToken ENDTABLE92 = null;
        IToken ENDBLOCK93 = null;
        BlaiseParser.block_settings_return block_settings90 = default(BlaiseParser.block_settings_return);

        BlaiseParser.submodel_return submodel91 = default(BlaiseParser.submodel_return);


        object a_tree=null;
        object b_tree=null;
        object EMBEDDED88_tree=null;
        object TABLE89_tree=null;
        object ENDTABLE92_tree=null;
        object ENDBLOCK93_tree=null;
        RewriteRuleTokenStream stream_TABLE = new RewriteRuleTokenStream(adaptor,"token TABLE");
        RewriteRuleTokenStream stream_EMBEDDED = new RewriteRuleTokenStream(adaptor,"token EMBEDDED");
        RewriteRuleTokenStream stream_QSTRING = new RewriteRuleTokenStream(adaptor,"token QSTRING");
        RewriteRuleTokenStream stream_ENDTABLE = new RewriteRuleTokenStream(adaptor,"token ENDTABLE");
        RewriteRuleTokenStream stream_ID = new RewriteRuleTokenStream(adaptor,"token ID");
        RewriteRuleTokenStream stream_ENDBLOCK = new RewriteRuleTokenStream(adaptor,"token ENDBLOCK");
        RewriteRuleSubtreeStream stream_submodel = new RewriteRuleSubtreeStream(adaptor,"rule submodel");
        RewriteRuleSubtreeStream stream_block_settings = new RewriteRuleSubtreeStream(adaptor,"rule block_settings");
        try 
    	{
            // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:697:7: ( ( EMBEDDED )? TABLE a= ID (b= QSTRING )? ( block_settings )? submodel ( ENDTABLE | ENDBLOCK ) -> ^( BLOCK ^( LABEL $a ( $b)? ) submodel ) )
            // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:697:9: ( EMBEDDED )? TABLE a= ID (b= QSTRING )? ( block_settings )? submodel ( ENDTABLE | ENDBLOCK )
            {
            	// C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:697:9: ( EMBEDDED )?
            	int alt31 = 2;
            	int LA31_0 = input.LA(1);

            	if ( (LA31_0 == EMBEDDED) )
            	{
            	    alt31 = 1;
            	}
            	switch (alt31) 
            	{
            	    case 1 :
            	        // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:0:0: EMBEDDED
            	        {
            	        	EMBEDDED88=(IToken)Match(input,EMBEDDED,FOLLOW_EMBEDDED_in_table4325); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_EMBEDDED.Add(EMBEDDED88);


            	        }
            	        break;

            	}

            	TABLE89=(IToken)Match(input,TABLE,FOLLOW_TABLE_in_table4328); if (state.failed) return retval; 
            	if ( (state.backtracking==0) ) stream_TABLE.Add(TABLE89);

            	a=(IToken)Match(input,ID,FOLLOW_ID_in_table4332); if (state.failed) return retval; 
            	if ( (state.backtracking==0) ) stream_ID.Add(a);

            	// C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:697:31: (b= QSTRING )?
            	int alt32 = 2;
            	int LA32_0 = input.LA(1);

            	if ( (LA32_0 == QSTRING) )
            	{
            	    alt32 = 1;
            	}
            	switch (alt32) 
            	{
            	    case 1 :
            	        // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:0:0: b= QSTRING
            	        {
            	        	b=(IToken)Match(input,QSTRING,FOLLOW_QSTRING_in_table4336); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_QSTRING.Add(b);


            	        }
            	        break;

            	}

            	// C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:698:4: ( block_settings )?
            	int alt33 = 2;
            	int LA33_0 = input.LA(1);

            	if ( (LA33_0 == SETTINGS) )
            	{
            	    alt33 = 1;
            	}
            	switch (alt33) 
            	{
            	    case 1 :
            	        // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:0:0: block_settings
            	        {
            	        	PushFollow(FOLLOW_block_settings_in_table4342);
            	        	block_settings90 = block_settings();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return retval;
            	        	if ( (state.backtracking==0) ) stream_block_settings.Add(block_settings90.Tree);

            	        }
            	        break;

            	}

            	PushFollow(FOLLOW_submodel_in_table4348);
            	submodel91 = submodel();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( (state.backtracking==0) ) stream_submodel.Add(submodel91.Tree);
            	// C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:700:3: ( ENDTABLE | ENDBLOCK )
            	int alt34 = 2;
            	int LA34_0 = input.LA(1);

            	if ( (LA34_0 == ENDTABLE) )
            	{
            	    alt34 = 1;
            	}
            	else if ( (LA34_0 == ENDBLOCK) )
            	{
            	    alt34 = 2;
            	}
            	else 
            	{
            	    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	    NoViableAltException nvae_d34s0 =
            	        new NoViableAltException("", 34, 0, input);

            	    throw nvae_d34s0;
            	}
            	switch (alt34) 
            	{
            	    case 1 :
            	        // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:700:4: ENDTABLE
            	        {
            	        	ENDTABLE92=(IToken)Match(input,ENDTABLE,FOLLOW_ENDTABLE_in_table4353); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_ENDTABLE.Add(ENDTABLE92);


            	        }
            	        break;
            	    case 2 :
            	        // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:700:15: ENDBLOCK
            	        {
            	        	ENDBLOCK93=(IToken)Match(input,ENDBLOCK,FOLLOW_ENDBLOCK_in_table4357); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_ENDBLOCK.Add(ENDBLOCK93);


            	        }
            	        break;

            	}



            	// AST REWRITE
            	// elements:          a, submodel, b
            	// token labels:      b, a
            	// rule labels:       retval
            	// token list labels: 
            	// rule list labels:  
            	// wildcard labels: 
            	if ( (state.backtracking==0) ) {
            	retval.Tree = root_0;
            	RewriteRuleTokenStream stream_b = new RewriteRuleTokenStream(adaptor, "token b", b);
            	RewriteRuleTokenStream stream_a = new RewriteRuleTokenStream(adaptor, "token a", a);
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

            	root_0 = (object)adaptor.GetNilNode();
            	// 700:25: -> ^( BLOCK ^( LABEL $a ( $b)? ) submodel )
            	{
            	    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:700:28: ^( BLOCK ^( LABEL $a ( $b)? ) submodel )
            	    {
            	    object root_1 = (object)adaptor.GetNilNode();
            	    root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(BLOCK, "BLOCK"), root_1);

            	    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:700:36: ^( LABEL $a ( $b)? )
            	    {
            	    object root_2 = (object)adaptor.GetNilNode();
            	    root_2 = (object)adaptor.BecomeRoot((object)adaptor.Create(LABEL, "LABEL"), root_2);

            	    adaptor.AddChild(root_2, stream_a.NextNode());
            	    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:700:47: ( $b)?
            	    if ( stream_b.HasNext() )
            	    {
            	        adaptor.AddChild(root_2, stream_b.NextNode());

            	    }
            	    stream_b.Reset();

            	    adaptor.AddChild(root_1, root_2);
            	    }
            	    adaptor.AddChild(root_1, stream_submodel.NextTree());

            	    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 
    	{
        }
        return retval;
    }
コード例 #12
0
    // $ANTLR start "block"
    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:692:1: block : ( EMBEDDED )? BLOCK a= ID (b= QSTRING )? ( block_settings )? submodel ( ENDBLOCK | ENDTABLE ) -> ^( BLOCK ^( LABEL $a ( $b)? ) submodel ) ;
    public BlaiseParser.block_return block() // throws RecognitionException [1]
    {   
        BlaiseParser.block_return retval = new BlaiseParser.block_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken a = null;
        IToken b = null;
        IToken EMBEDDED82 = null;
        IToken BLOCK83 = null;
        IToken ENDBLOCK86 = null;
        IToken ENDTABLE87 = null;
        BlaiseParser.block_settings_return block_settings84 = default(BlaiseParser.block_settings_return);

        BlaiseParser.submodel_return submodel85 = default(BlaiseParser.submodel_return);


        object a_tree=null;
        object b_tree=null;
        object EMBEDDED82_tree=null;
        object BLOCK83_tree=null;
        object ENDBLOCK86_tree=null;
        object ENDTABLE87_tree=null;
        RewriteRuleTokenStream stream_EMBEDDED = new RewriteRuleTokenStream(adaptor,"token EMBEDDED");
        RewriteRuleTokenStream stream_QSTRING = new RewriteRuleTokenStream(adaptor,"token QSTRING");
        RewriteRuleTokenStream stream_ENDTABLE = new RewriteRuleTokenStream(adaptor,"token ENDTABLE");
        RewriteRuleTokenStream stream_ID = new RewriteRuleTokenStream(adaptor,"token ID");
        RewriteRuleTokenStream stream_ENDBLOCK = new RewriteRuleTokenStream(adaptor,"token ENDBLOCK");
        RewriteRuleTokenStream stream_BLOCK = new RewriteRuleTokenStream(adaptor,"token BLOCK");
        RewriteRuleSubtreeStream stream_submodel = new RewriteRuleSubtreeStream(adaptor,"rule submodel");
        RewriteRuleSubtreeStream stream_block_settings = new RewriteRuleSubtreeStream(adaptor,"rule block_settings");
        try 
    	{
            // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:692:7: ( ( EMBEDDED )? BLOCK a= ID (b= QSTRING )? ( block_settings )? submodel ( ENDBLOCK | ENDTABLE ) -> ^( BLOCK ^( LABEL $a ( $b)? ) submodel ) )
            // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:692:9: ( EMBEDDED )? BLOCK a= ID (b= QSTRING )? ( block_settings )? submodel ( ENDBLOCK | ENDTABLE )
            {
            	// C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:692:9: ( EMBEDDED )?
            	int alt27 = 2;
            	int LA27_0 = input.LA(1);

            	if ( (LA27_0 == EMBEDDED) )
            	{
            	    alt27 = 1;
            	}
            	switch (alt27) 
            	{
            	    case 1 :
            	        // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:0:0: EMBEDDED
            	        {
            	        	EMBEDDED82=(IToken)Match(input,EMBEDDED,FOLLOW_EMBEDDED_in_block4265); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_EMBEDDED.Add(EMBEDDED82);


            	        }
            	        break;

            	}

            	BLOCK83=(IToken)Match(input,BLOCK,FOLLOW_BLOCK_in_block4268); if (state.failed) return retval; 
            	if ( (state.backtracking==0) ) stream_BLOCK.Add(BLOCK83);

            	a=(IToken)Match(input,ID,FOLLOW_ID_in_block4272); if (state.failed) return retval; 
            	if ( (state.backtracking==0) ) stream_ID.Add(a);

            	// C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:692:31: (b= QSTRING )?
            	int alt28 = 2;
            	int LA28_0 = input.LA(1);

            	if ( (LA28_0 == QSTRING) )
            	{
            	    alt28 = 1;
            	}
            	switch (alt28) 
            	{
            	    case 1 :
            	        // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:0:0: b= QSTRING
            	        {
            	        	b=(IToken)Match(input,QSTRING,FOLLOW_QSTRING_in_block4276); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_QSTRING.Add(b);


            	        }
            	        break;

            	}

            	// C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:693:4: ( block_settings )?
            	int alt29 = 2;
            	int LA29_0 = input.LA(1);

            	if ( (LA29_0 == SETTINGS) )
            	{
            	    alt29 = 1;
            	}
            	switch (alt29) 
            	{
            	    case 1 :
            	        // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:0:0: block_settings
            	        {
            	        	PushFollow(FOLLOW_block_settings_in_block4282);
            	        	block_settings84 = block_settings();
            	        	state.followingStackPointer--;
            	        	if (state.failed) return retval;
            	        	if ( (state.backtracking==0) ) stream_block_settings.Add(block_settings84.Tree);

            	        }
            	        break;

            	}

            	PushFollow(FOLLOW_submodel_in_block4288);
            	submodel85 = submodel();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( (state.backtracking==0) ) stream_submodel.Add(submodel85.Tree);
            	// C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:695:3: ( ENDBLOCK | ENDTABLE )
            	int alt30 = 2;
            	int LA30_0 = input.LA(1);

            	if ( (LA30_0 == ENDBLOCK) )
            	{
            	    alt30 = 1;
            	}
            	else if ( (LA30_0 == ENDTABLE) )
            	{
            	    alt30 = 2;
            	}
            	else 
            	{
            	    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	    NoViableAltException nvae_d30s0 =
            	        new NoViableAltException("", 30, 0, input);

            	    throw nvae_d30s0;
            	}
            	switch (alt30) 
            	{
            	    case 1 :
            	        // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:695:4: ENDBLOCK
            	        {
            	        	ENDBLOCK86=(IToken)Match(input,ENDBLOCK,FOLLOW_ENDBLOCK_in_block4293); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_ENDBLOCK.Add(ENDBLOCK86);


            	        }
            	        break;
            	    case 2 :
            	        // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:695:15: ENDTABLE
            	        {
            	        	ENDTABLE87=(IToken)Match(input,ENDTABLE,FOLLOW_ENDTABLE_in_block4297); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_ENDTABLE.Add(ENDTABLE87);


            	        }
            	        break;

            	}



            	// AST REWRITE
            	// elements:          a, BLOCK, b, submodel
            	// token labels:      b, a
            	// rule labels:       retval
            	// token list labels: 
            	// rule list labels:  
            	// wildcard labels: 
            	if ( (state.backtracking==0) ) {
            	retval.Tree = root_0;
            	RewriteRuleTokenStream stream_b = new RewriteRuleTokenStream(adaptor, "token b", b);
            	RewriteRuleTokenStream stream_a = new RewriteRuleTokenStream(adaptor, "token a", a);
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

            	root_0 = (object)adaptor.GetNilNode();
            	// 695:25: -> ^( BLOCK ^( LABEL $a ( $b)? ) submodel )
            	{
            	    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:695:28: ^( BLOCK ^( LABEL $a ( $b)? ) submodel )
            	    {
            	    object root_1 = (object)adaptor.GetNilNode();
            	    root_1 = (object)adaptor.BecomeRoot(stream_BLOCK.NextNode(), root_1);

            	    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:695:36: ^( LABEL $a ( $b)? )
            	    {
            	    object root_2 = (object)adaptor.GetNilNode();
            	    root_2 = (object)adaptor.BecomeRoot((object)adaptor.Create(LABEL, "LABEL"), root_2);

            	    adaptor.AddChild(root_2, stream_a.NextNode());
            	    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:695:47: ( $b)?
            	    if ( stream_b.HasNext() )
            	    {
            	        adaptor.AddChild(root_2, stream_b.NextNode());

            	    }
            	    stream_b.Reset();

            	    adaptor.AddChild(root_1, root_2);
            	    }
            	    adaptor.AddChild(root_1, stream_submodel.NextTree());

            	    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 
    	{
        }
        return retval;
    }
コード例 #13
0
    // $ANTLR start "secondary_key"
    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:666:1: secondary_key : (b= ID '=' )? a= var_list ( '(' c= ( ALPHA | TRIGRAM ) ')' )? -> ^( SECONDARY_KEY $a ( $b)? ( $c)? ) ;
    public BlaiseParser.secondary_key_return secondary_key() // throws RecognitionException [1]
    {   
        BlaiseParser.secondary_key_return retval = new BlaiseParser.secondary_key_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken b = null;
        IToken c = null;
        IToken char_literal53 = null;
        IToken char_literal54 = null;
        IToken ALPHA55 = null;
        IToken TRIGRAM56 = null;
        IToken char_literal57 = null;
        BlaiseParser.var_list_return a = default(BlaiseParser.var_list_return);


        object b_tree=null;
        object c_tree=null;
        object char_literal53_tree=null;
        object char_literal54_tree=null;
        object ALPHA55_tree=null;
        object TRIGRAM56_tree=null;
        object char_literal57_tree=null;
        RewriteRuleTokenStream stream_RPAREN = new RewriteRuleTokenStream(adaptor,"token RPAREN");
        RewriteRuleTokenStream stream_TRIGRAM = new RewriteRuleTokenStream(adaptor,"token TRIGRAM");
        RewriteRuleTokenStream stream_ID = new RewriteRuleTokenStream(adaptor,"token ID");
        RewriteRuleTokenStream stream_ALPHA = new RewriteRuleTokenStream(adaptor,"token ALPHA");
        RewriteRuleTokenStream stream_LPAREN = new RewriteRuleTokenStream(adaptor,"token LPAREN");
        RewriteRuleTokenStream stream_EQUAL = new RewriteRuleTokenStream(adaptor,"token EQUAL");
        RewriteRuleSubtreeStream stream_var_list = new RewriteRuleSubtreeStream(adaptor,"rule var_list");
        try 
    	{
            // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:667:2: ( (b= ID '=' )? a= var_list ( '(' c= ( ALPHA | TRIGRAM ) ')' )? -> ^( SECONDARY_KEY $a ( $b)? ( $c)? ) )
            // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:667:4: (b= ID '=' )? a= var_list ( '(' c= ( ALPHA | TRIGRAM ) ')' )?
            {
            	// C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:667:4: (b= ID '=' )?
            	int alt18 = 2;
            	int LA18_0 = input.LA(1);

            	if ( (LA18_0 == ID) )
            	{
            	    int LA18_1 = input.LA(2);

            	    if ( (LA18_1 == EQUAL) )
            	    {
            	        alt18 = 1;
            	    }
            	}
            	switch (alt18) 
            	{
            	    case 1 :
            	        // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:667:5: b= ID '='
            	        {
            	        	b=(IToken)Match(input,ID,FOLLOW_ID_in_secondary_key4042); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_ID.Add(b);

            	        	char_literal53=(IToken)Match(input,EQUAL,FOLLOW_EQUAL_in_secondary_key4044); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_EQUAL.Add(char_literal53);


            	        }
            	        break;

            	}

            	PushFollow(FOLLOW_var_list_in_secondary_key4050);
            	a = var_list();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( (state.backtracking==0) ) stream_var_list.Add(a.Tree);
            	// C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:667:27: ( '(' c= ( ALPHA | TRIGRAM ) ')' )?
            	int alt20 = 2;
            	int LA20_0 = input.LA(1);

            	if ( (LA20_0 == LPAREN) )
            	{
            	    alt20 = 1;
            	}
            	switch (alt20) 
            	{
            	    case 1 :
            	        // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:667:28: '(' c= ( ALPHA | TRIGRAM ) ')'
            	        {
            	        	char_literal54=(IToken)Match(input,LPAREN,FOLLOW_LPAREN_in_secondary_key4053); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_LPAREN.Add(char_literal54);

            	        	// C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:667:34: ( ALPHA | TRIGRAM )
            	        	int alt19 = 2;
            	        	int LA19_0 = input.LA(1);

            	        	if ( (LA19_0 == ALPHA) )
            	        	{
            	        	    alt19 = 1;
            	        	}
            	        	else if ( (LA19_0 == TRIGRAM) )
            	        	{
            	        	    alt19 = 2;
            	        	}
            	        	else 
            	        	{
            	        	    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            	        	    NoViableAltException nvae_d19s0 =
            	        	        new NoViableAltException("", 19, 0, input);

            	        	    throw nvae_d19s0;
            	        	}
            	        	switch (alt19) 
            	        	{
            	        	    case 1 :
            	        	        // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:667:35: ALPHA
            	        	        {
            	        	        	ALPHA55=(IToken)Match(input,ALPHA,FOLLOW_ALPHA_in_secondary_key4058); if (state.failed) return retval; 
            	        	        	if ( (state.backtracking==0) ) stream_ALPHA.Add(ALPHA55);


            	        	        }
            	        	        break;
            	        	    case 2 :
            	        	        // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:667:43: TRIGRAM
            	        	        {
            	        	        	TRIGRAM56=(IToken)Match(input,TRIGRAM,FOLLOW_TRIGRAM_in_secondary_key4062); if (state.failed) return retval; 
            	        	        	if ( (state.backtracking==0) ) stream_TRIGRAM.Add(TRIGRAM56);


            	        	        }
            	        	        break;

            	        	}

            	        	char_literal57=(IToken)Match(input,RPAREN,FOLLOW_RPAREN_in_secondary_key4065); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_RPAREN.Add(char_literal57);


            	        }
            	        break;

            	}



            	// AST REWRITE
            	// elements:          b, a, c
            	// token labels:      b, c
            	// rule labels:       retval, a
            	// token list labels: 
            	// rule list labels:  
            	// wildcard labels: 
            	if ( (state.backtracking==0) ) {
            	retval.Tree = root_0;
            	RewriteRuleTokenStream stream_b = new RewriteRuleTokenStream(adaptor, "token b", b);
            	RewriteRuleTokenStream stream_c = new RewriteRuleTokenStream(adaptor, "token c", c);
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);
            	RewriteRuleSubtreeStream stream_a = new RewriteRuleSubtreeStream(adaptor, "rule a", a!=null ? a.Tree : null);

            	root_0 = (object)adaptor.GetNilNode();
            	// 667:58: -> ^( SECONDARY_KEY $a ( $b)? ( $c)? )
            	{
            	    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:667:61: ^( SECONDARY_KEY $a ( $b)? ( $c)? )
            	    {
            	    object root_1 = (object)adaptor.GetNilNode();
            	    root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(SECONDARY_KEY, "SECONDARY_KEY"), root_1);

            	    adaptor.AddChild(root_1, stream_a.NextTree());
            	    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:667:80: ( $b)?
            	    if ( stream_b.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_b.NextNode());

            	    }
            	    stream_b.Reset();
            	    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:667:84: ( $c)?
            	    if ( stream_c.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_c.NextNode());

            	    }
            	    stream_c.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 
    	{
        }
        return retval;
    }
コード例 #14
0
    // $ANTLR start "language"
    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:658:1: language : a= ID (b= QSTRING )? -> ^( LANGUAGE $a ( $b)? ) ;
    public BlaiseParser.language_return language() // throws RecognitionException [1]
    {   
        BlaiseParser.language_return retval = new BlaiseParser.language_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken a = null;
        IToken b = null;

        object a_tree=null;
        object b_tree=null;
        RewriteRuleTokenStream stream_QSTRING = new RewriteRuleTokenStream(adaptor,"token QSTRING");
        RewriteRuleTokenStream stream_ID = new RewriteRuleTokenStream(adaptor,"token ID");

        try 
    	{
            // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:659:2: (a= ID (b= QSTRING )? -> ^( LANGUAGE $a ( $b)? ) )
            // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:659:5: a= ID (b= QSTRING )?
            {
            	a=(IToken)Match(input,ID,FOLLOW_ID_in_language3951); if (state.failed) return retval; 
            	if ( (state.backtracking==0) ) stream_ID.Add(a);

            	// C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:659:11: (b= QSTRING )?
            	int alt14 = 2;
            	int LA14_0 = input.LA(1);

            	if ( (LA14_0 == QSTRING) )
            	{
            	    alt14 = 1;
            	}
            	switch (alt14) 
            	{
            	    case 1 :
            	        // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:0:0: b= QSTRING
            	        {
            	        	b=(IToken)Match(input,QSTRING,FOLLOW_QSTRING_in_language3955); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_QSTRING.Add(b);


            	        }
            	        break;

            	}



            	// AST REWRITE
            	// elements:          b, a
            	// token labels:      b, a
            	// rule labels:       retval
            	// token list labels: 
            	// rule list labels:  
            	// wildcard labels: 
            	if ( (state.backtracking==0) ) {
            	retval.Tree = root_0;
            	RewriteRuleTokenStream stream_b = new RewriteRuleTokenStream(adaptor, "token b", b);
            	RewriteRuleTokenStream stream_a = new RewriteRuleTokenStream(adaptor, "token a", a);
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

            	root_0 = (object)adaptor.GetNilNode();
            	// 659:21: -> ^( LANGUAGE $a ( $b)? )
            	{
            	    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:659:24: ^( LANGUAGE $a ( $b)? )
            	    {
            	    object root_1 = (object)adaptor.GetNilNode();
            	    root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(LANGUAGE, "LANGUAGE"), root_1);

            	    adaptor.AddChild(root_1, stream_a.NextNode());
            	    // C:\\Users\\jeremy\\svn\\algenta\\Algenta.Data.Parsing.Blaise\\Blaise.g:659:38: ( $b)?
            	    if ( stream_b.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_b.NextNode());

            	    }
            	    stream_b.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 
    	{
        }
        return retval;
    }
コード例 #15
0
ファイル: PsimulexParser.cs プロジェクト: hunpody/psimulex
    // $ANTLR start "formalParameter"
    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:185:1: formalParameter : type ( Reference )? Identifier -> ^( FORMAL_PARAMETER type ( Reference )? Identifier ) ;
    public PsimulexParser.formalParameter_return formalParameter() // throws RecognitionException [1]
    {   
        PsimulexParser.formalParameter_return retval = new PsimulexParser.formalParameter_return();
        retval.Start = input.LT(1);
        int formalParameter_StartIndex = input.Index();
        CommonTree root_0 = null;

        IToken Reference42 = null;
        IToken Identifier43 = null;
        PsimulexParser.type_return type41 = default(PsimulexParser.type_return);


        CommonTree Reference42_tree=null;
        CommonTree Identifier43_tree=null;
        RewriteRuleTokenStream stream_Reference = new RewriteRuleTokenStream(adaptor,"token Reference");
        RewriteRuleTokenStream stream_Identifier = new RewriteRuleTokenStream(adaptor,"token Identifier");
        RewriteRuleSubtreeStream stream_type = new RewriteRuleSubtreeStream(adaptor,"rule type");
        try 
    	{
    	    if ( (state.backtracking > 0) && AlreadyParsedRule(input, 14) ) 
    	    {
    	    	return retval; 
    	    }
            // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:186:5: ( type ( Reference )? Identifier -> ^( FORMAL_PARAMETER type ( Reference )? Identifier ) )
            // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:186:9: type ( Reference )? Identifier
            {
            	PushFollow(FOLLOW_type_in_formalParameter871);
            	type41 = type();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( (state.backtracking==0) ) stream_type.Add(type41.Tree);
            	// C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:186:14: ( Reference )?
            	int alt13 = 2;
            	int LA13_0 = input.LA(1);

            	if ( (LA13_0 == Reference) )
            	{
            	    alt13 = 1;
            	}
            	switch (alt13) 
            	{
            	    case 1 :
            	        // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:0:0: Reference
            	        {
            	        	Reference42=(IToken)Match(input,Reference,FOLLOW_Reference_in_formalParameter873); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_Reference.Add(Reference42);


            	        }
            	        break;

            	}

            	Identifier43=(IToken)Match(input,Identifier,FOLLOW_Identifier_in_formalParameter876); if (state.failed) return retval; 
            	if ( (state.backtracking==0) ) stream_Identifier.Add(Identifier43);



            	// AST REWRITE
            	// elements:          Identifier, Reference, type
            	// 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 = (CommonTree)adaptor.GetNilNode();
            	// 186:36: -> ^( FORMAL_PARAMETER type ( Reference )? Identifier )
            	{
            	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:186:39: ^( FORMAL_PARAMETER type ( Reference )? Identifier )
            	    {
            	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
            	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(FORMAL_PARAMETER, "FORMAL_PARAMETER"), root_1);

            	    adaptor.AddChild(root_1, stream_type.NextTree());
            	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:186:64: ( Reference )?
            	    if ( stream_Reference.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_Reference.NextNode());

            	    }
            	    stream_Reference.Reset();
            	    adaptor.AddChild(root_1, stream_Identifier.NextNode());

            	    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 = (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 
    	{
            if ( state.backtracking > 0 ) 
            {
            	Memoize(input, 14, formalParameter_StartIndex); 
            }
        }
        return retval;
    }
コード例 #16
0
	private AstParserRuleReturnScope<object, IToken> functionExpression()
	{
		EnterRule_functionExpression();
		EnterRule("functionExpression", 37);
		TraceIn("functionExpression", 37);
		AstParserRuleReturnScope<object, IToken> retval = new AstParserRuleReturnScope<object, IToken>();
		retval.Start = (IToken)input.LT(1);
		int functionExpression_StartIndex = input.Index;

		object root_0 = default(object);

		IToken string_literal234 = default(IToken);
		IToken LT235 = default(IToken);
		IToken Identifier236 = default(IToken);
		IToken LT237 = default(IToken);
		IToken LT239 = default(IToken);
		AstParserRuleReturnScope<object, IToken> formalParameterList238 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> functionBody240 = default(AstParserRuleReturnScope<object, IToken>);

		object string_literal234_tree = default(object);
		object LT235_tree = default(object);
		object Identifier236_tree = default(object);
		object LT237_tree = default(object);
		object LT239_tree = default(object);
		RewriteRuleITokenStream stream_133=new RewriteRuleITokenStream(adaptor,"token 133");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_Identifier=new RewriteRuleITokenStream(adaptor,"token Identifier");
		RewriteRuleSubtreeStream stream_formalParameterList=new RewriteRuleSubtreeStream(adaptor,"rule formalParameterList");
		RewriteRuleSubtreeStream stream_functionBody=new RewriteRuleSubtreeStream(adaptor,"rule functionBody");
		try { DebugEnterRule(GrammarFileName, "functionExpression");
		DebugLocation(250, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 37)) { return retval; }

			// JavaScript.g3:251:2: ( 'function' ( LT )* ( Identifier )? ( LT )* formalParameterList ( LT )* functionBody -> ^( FUNCTION ( ^( IDENTIFIER Identifier ) )? ( formalParameterList )? functionBody ) )
			DebugEnterAlt(1);
			// JavaScript.g3:251:4: 'function' ( LT )* ( Identifier )? ( LT )* formalParameterList ( LT )* functionBody
			{
			DebugLocation(251, 4);
			string_literal234=(IToken)Match(input,133,Follow._133_in_functionExpression1678); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_133.Add(string_literal234);

			DebugLocation(251, 15);
			// JavaScript.g3:251:15: ( LT )*
			try { DebugEnterSubRule(112);
			while (true)
			{
				int alt112=2;
				try { DebugEnterDecision(112, false);
				int LA112_1 = input.LA(1);

				if ((LA112_1==LT))
				{
					int LA112_2 = input.LA(2);

					if ((EvaluatePredicate(synpred129_JavaScript_fragment)))
					{
						alt112 = 1;
					}


				}


				} finally { DebugExitDecision(112); }
				switch ( alt112 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g3:251:15: LT
					{
					DebugLocation(251, 15);
					LT235=(IToken)Match(input,LT,Follow._LT_in_functionExpression1680); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT235);


					}
					break;

				default:
					goto loop112;
				}
			}

			loop112:
				;

			} finally { DebugExitSubRule(112); }

			DebugLocation(251, 19);
			// JavaScript.g3:251:19: ( Identifier )?
			int alt113=2;
			try { DebugEnterSubRule(113);
			try { DebugEnterDecision(113, false);
			int LA113_1 = input.LA(1);

			if ((LA113_1==Identifier))
			{
				alt113 = 1;
			}
			} finally { DebugExitDecision(113); }
			switch (alt113)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g3:251:19: Identifier
				{
				DebugLocation(251, 19);
				Identifier236=(IToken)Match(input,Identifier,Follow._Identifier_in_functionExpression1683); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_Identifier.Add(Identifier236);


				}
				break;

			}
			} finally { DebugExitSubRule(113); }

			DebugLocation(251, 31);
			// JavaScript.g3:251:31: ( LT )*
			try { DebugEnterSubRule(114);
			while (true)
			{
				int alt114=2;
				try { DebugEnterDecision(114, false);
				int LA114_1 = input.LA(1);

				if ((LA114_1==LT))
				{
					alt114 = 1;
				}


				} finally { DebugExitDecision(114); }
				switch ( alt114 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g3:251:31: LT
					{
					DebugLocation(251, 31);
					LT237=(IToken)Match(input,LT,Follow._LT_in_functionExpression1686); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT237);


					}
					break;

				default:
					goto loop114;
				}
			}

			loop114:
				;

			} finally { DebugExitSubRule(114); }

			DebugLocation(251, 35);
			PushFollow(Follow._formalParameterList_in_functionExpression1689);
			formalParameterList238=formalParameterList();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_formalParameterList.Add(formalParameterList238.Tree);
			DebugLocation(251, 55);
			// JavaScript.g3:251:55: ( LT )*
			try { DebugEnterSubRule(115);
			while (true)
			{
				int alt115=2;
				try { DebugEnterDecision(115, false);
				int LA115_1 = input.LA(1);

				if ((LA115_1==LT))
				{
					alt115 = 1;
				}


				} finally { DebugExitDecision(115); }
				switch ( alt115 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g3:251:55: LT
					{
					DebugLocation(251, 55);
					LT239=(IToken)Match(input,LT,Follow._LT_in_functionExpression1691); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT239);


					}
					break;

				default:
					goto loop115;
				}
			}

			loop115:
				;

			} finally { DebugExitSubRule(115); }

			DebugLocation(251, 59);
			PushFollow(Follow._functionBody_in_functionExpression1694);
			functionBody240=functionBody();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_functionBody.Add(functionBody240.Tree);


			{
			// AST REWRITE
			// elements: Identifier, formalParameterList, functionBody
			// 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.Nil();
			// 251:72: -> ^( FUNCTION ( ^( IDENTIFIER Identifier ) )? ( formalParameterList )? functionBody )
			{
				DebugLocation(251, 75);
				// JavaScript.g3:251:75: ^( FUNCTION ( ^( IDENTIFIER Identifier ) )? ( formalParameterList )? functionBody )
				{
				object root_1 = (object)adaptor.Nil();
				DebugLocation(251, 77);
				root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(FUNCTION, "FUNCTION"), root_1);

				DebugLocation(251, 86);
				// JavaScript.g3:251:86: ( ^( IDENTIFIER Identifier ) )?
				if (stream_Identifier.HasNext)
				{
					DebugLocation(251, 86);
					// JavaScript.g3:251:86: ^( IDENTIFIER Identifier )
					{
					object root_2 = (object)adaptor.Nil();
					DebugLocation(251, 88);
					root_2 = (object)adaptor.BecomeRoot((object)adaptor.Create(IDENTIFIER, "IDENTIFIER"), root_2);

					DebugLocation(251, 99);
					adaptor.AddChild(root_2, stream_Identifier.NextNode());

					adaptor.AddChild(root_1, root_2);
					}

				}
				stream_Identifier.Reset();
				DebugLocation(251, 112);
				// JavaScript.g3:251:112: ( formalParameterList )?
				if (stream_formalParameterList.HasNext)
				{
					DebugLocation(251, 112);
					adaptor.AddChild(root_1, stream_formalParameterList.NextTree());

				}
				stream_formalParameterList.Reset();
				DebugLocation(251, 133);
				adaptor.AddChild(root_1, stream_functionBody.NextTree());

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			if (state.backtracking == 0) {
			retval.Tree = (object)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("functionExpression", 37);
			LeaveRule("functionExpression", 37);
			LeaveRule_functionExpression();
			if (state.backtracking > 0) { Memoize(input, 37, functionExpression_StartIndex); }

		}
		DebugLocation(252, 1);
		} finally { DebugExitRule(GrammarFileName, "functionExpression"); }
		return retval;

	}
コード例 #17
0
ファイル: PsimulexParser.cs プロジェクト: hunpody/psimulex
    // $ANTLR start "variable"
    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:373:1: variable : ( Reference )? Identifier -> ^( Identifier ( Reference )? ) ;
    public PsimulexParser.variable_return variable() // throws RecognitionException [1]
    {   
        PsimulexParser.variable_return retval = new PsimulexParser.variable_return();
        retval.Start = input.LT(1);
        int variable_StartIndex = input.Index();
        CommonTree root_0 = null;

        IToken Reference110 = null;
        IToken Identifier111 = null;

        CommonTree Reference110_tree=null;
        CommonTree Identifier111_tree=null;
        RewriteRuleTokenStream stream_Reference = new RewriteRuleTokenStream(adaptor,"token Reference");
        RewriteRuleTokenStream stream_Identifier = new RewriteRuleTokenStream(adaptor,"token Identifier");

        try 
    	{
    	    if ( (state.backtracking > 0) && AlreadyParsedRule(input, 46) ) 
    	    {
    	    	return retval; 
    	    }
            // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:374:2: ( ( Reference )? Identifier -> ^( Identifier ( Reference )? ) )
            // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:374:4: ( Reference )? Identifier
            {
            	// C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:374:4: ( Reference )?
            	int alt29 = 2;
            	int LA29_0 = input.LA(1);

            	if ( (LA29_0 == Reference) )
            	{
            	    alt29 = 1;
            	}
            	switch (alt29) 
            	{
            	    case 1 :
            	        // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:0:0: Reference
            	        {
            	        	Reference110=(IToken)Match(input,Reference,FOLLOW_Reference_in_variable1767); if (state.failed) return retval; 
            	        	if ( (state.backtracking==0) ) stream_Reference.Add(Reference110);


            	        }
            	        break;

            	}

            	Identifier111=(IToken)Match(input,Identifier,FOLLOW_Identifier_in_variable1770); if (state.failed) return retval; 
            	if ( (state.backtracking==0) ) stream_Identifier.Add(Identifier111);



            	// AST REWRITE
            	// elements:          Reference, Identifier
            	// 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 = (CommonTree)adaptor.GetNilNode();
            	// 374:26: -> ^( Identifier ( Reference )? )
            	{
            	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:374:29: ^( Identifier ( Reference )? )
            	    {
            	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
            	    root_1 = (CommonTree)adaptor.BecomeRoot(stream_Identifier.NextNode(), root_1);

            	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:374:43: ( Reference )?
            	    if ( stream_Reference.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_Reference.NextNode());

            	    }
            	    stream_Reference.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 = (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 
    	{
            if ( state.backtracking > 0 ) 
            {
            	Memoize(input, 46, variable_StartIndex); 
            }
        }
        return retval;
    }
コード例 #18
0
ファイル: ASParser.cs プロジェクト: nomilogic/fdplugins
        // throws RecognitionException [1]
        // $ANTLR start typeExpression
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1015:1: typeExpression : c= COLON ( identifier | VOID | STAR ) -> ^( TYPE_SPEC[$c] ( identifier )? ( VOID )? ( STAR )? ) ;
        public typeExpression_return typeExpression()
        {
            typeExpression_return retval = new typeExpression_return();
            retval.start = input.LT(1);
            int typeExpression_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken c = null;
            CommonToken VOID170 = null;
            CommonToken STAR171 = null;
            identifier_return identifier169 = null;

            CommonTree c_tree=null;
            CommonTree VOID170_tree=null;
            CommonTree STAR171_tree=null;
            RewriteRuleTokenStream stream_STAR = new RewriteRuleTokenStream(adaptor,"token STAR");
            RewriteRuleTokenStream stream_COLON = new RewriteRuleTokenStream(adaptor,"token COLON");
            RewriteRuleTokenStream stream_VOID = new RewriteRuleTokenStream(adaptor,"token VOID");
            RewriteRuleSubtreeStream stream_identifier = new RewriteRuleSubtreeStream(adaptor,"rule identifier");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 64) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1017:3: (c= COLON ( identifier | VOID | STAR ) -> ^( TYPE_SPEC[$c] ( identifier )? ( VOID )? ( STAR )? ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1017:3: c= COLON ( identifier | VOID | STAR )
            {
                c = (CommonToken)input.LT(1);
                Match(input,COLON,FOLLOW_COLON_in_typeExpression3152); if (failed) return retval;
                if ( backtracking==0 ) stream_COLON.Add(c);

                if ( backtracking == 0 )
                {
                   buffer.Append(options.SpaceBetweenType ? " : " : ":");
                }
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1018:3: ( identifier | VOID | STAR )
                int alt45 = 3;
                switch ( input.LA(1) )
                {
                case GET:
                case SET:
                case IDENT:
                case DYNAMIC:
                case IS:
                case AS:
                case USE:
                case XML:
                    {
                    alt45 = 1;
                    }
                    break;
                case VOID:
                    {
                    alt45 = 2;
                    }
                    break;
                case STAR:
                    {
                    alt45 = 3;
                    }
                    break;
                    default:
                        if ( backtracking > 0 ) {failed = true; return retval;}
                        NoViableAltException nvae_d45s0 =
                            new NoViableAltException("1018:3: ( identifier | VOID | STAR )", 45, 0, input);

                        throw nvae_d45s0;
                }

                switch (alt45)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1019:4: identifier
                        {
                            PushFollow(FOLLOW_identifier_in_typeExpression3165);
                            identifier169 = identifier();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_identifier.Add(identifier169.Tree);

                        }
                        break;
                    case 2 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1020:6: VOID
                        {
                            VOID170 = (CommonToken)input.LT(1);
                            Match(input,VOID,FOLLOW_VOID_in_typeExpression3173); if (failed) return retval;
                            if ( backtracking==0 ) stream_VOID.Add(VOID170);

                            if ( backtracking == 0 )
                            {
                               buffer.Append("Void");
                            }

                        }
                        break;
                    case 3 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1021:6: STAR
                        {
                            STAR171 = (CommonToken)input.LT(1);
                            Match(input,STAR,FOLLOW_STAR_in_typeExpression3183); if (failed) return retval;
                            if ( backtracking==0 ) stream_STAR.Add(STAR171);

                            if ( backtracking == 0 )
                            {
                               buffer.Append("*");
                            }

                        }
                        break;

                }

                // AST REWRITE
                // elements:          STAR, VOID, identifier
                // token labels:
                // rule labels:       retval
                // token list labels:
                // rule list labels:
                if ( backtracking==0 ) {
                retval.tree = root_0;
                RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "token retval", (retval!=null ? retval.Tree : null));

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 1023:3: -> ^( TYPE_SPEC[$c] ( identifier )? ( VOID )? ( STAR )? )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1023:6: ^( TYPE_SPEC[$c] ( identifier )? ( VOID )? ( STAR )? )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(TYPE_SPEC, c), root_1);

                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1023:22: ( identifier )?
                    if ( stream_identifier.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_identifier.Next());

                    }
                    stream_identifier.Reset();
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1023:34: ( VOID )?
                    if ( stream_VOID.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_VOID.Next());

                    }
                    stream_VOID.Reset();
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1023:40: ( STAR )?
                    if ( stream_STAR.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_STAR.Next());

                    }
                    stream_STAR.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

            retval.stop = input.LT(-1);

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 64, typeExpression_StartIndex);
            }
            }
            return retval;
        }
コード例 #19
0
ファイル: PsimulexParser.cs プロジェクト: hunpody/psimulex
    // $ANTLR start "importDeclarations"
    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:128:1: importDeclarations : ( Import StringLiteral ';' )* -> ^( IMPORT_DECLARATIONS ( StringLiteral )* ) ;
    public PsimulexParser.importDeclarations_return importDeclarations() // throws RecognitionException [1]
    {   
        PsimulexParser.importDeclarations_return retval = new PsimulexParser.importDeclarations_return();
        retval.Start = input.LT(1);
        int importDeclarations_StartIndex = input.Index();
        CommonTree root_0 = null;

        IToken Import9 = null;
        IToken StringLiteral10 = null;
        IToken char_literal11 = null;

        CommonTree Import9_tree=null;
        CommonTree StringLiteral10_tree=null;
        CommonTree char_literal11_tree=null;
        RewriteRuleTokenStream stream_143 = new RewriteRuleTokenStream(adaptor,"token 143");
        RewriteRuleTokenStream stream_StringLiteral = new RewriteRuleTokenStream(adaptor,"token StringLiteral");
        RewriteRuleTokenStream stream_Import = new RewriteRuleTokenStream(adaptor,"token Import");

        try 
    	{
    	    if ( (state.backtracking > 0) && AlreadyParsedRule(input, 5) ) 
    	    {
    	    	return retval; 
    	    }
            // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:129:5: ( ( Import StringLiteral ';' )* -> ^( IMPORT_DECLARATIONS ( StringLiteral )* ) )
            // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:129:9: ( Import StringLiteral ';' )*
            {
            	// C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:129:9: ( Import StringLiteral ';' )*
            	do 
            	{
            	    int alt4 = 2;
            	    int LA4_0 = input.LA(1);

            	    if ( (LA4_0 == Import) )
            	    {
            	        alt4 = 1;
            	    }


            	    switch (alt4) 
            		{
            			case 1 :
            			    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:129:11: Import StringLiteral ';'
            			    {
            			    	Import9=(IToken)Match(input,Import,FOLLOW_Import_in_importDeclarations482); if (state.failed) return retval; 
            			    	if ( (state.backtracking==0) ) stream_Import.Add(Import9);

            			    	StringLiteral10=(IToken)Match(input,StringLiteral,FOLLOW_StringLiteral_in_importDeclarations484); if (state.failed) return retval; 
            			    	if ( (state.backtracking==0) ) stream_StringLiteral.Add(StringLiteral10);

            			    	char_literal11=(IToken)Match(input,143,FOLLOW_143_in_importDeclarations486); if (state.failed) return retval; 
            			    	if ( (state.backtracking==0) ) stream_143.Add(char_literal11);


            			    }
            			    break;

            			default:
            			    goto loop4;
            	    }
            	} while (true);

            	loop4:
            		;	// Stops C# compiler whining that label 'loop4' has no statements



            	// AST REWRITE
            	// elements:          StringLiteral
            	// 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 = (CommonTree)adaptor.GetNilNode();
            	// 129:39: -> ^( IMPORT_DECLARATIONS ( StringLiteral )* )
            	{
            	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:129:42: ^( IMPORT_DECLARATIONS ( StringLiteral )* )
            	    {
            	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
            	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(IMPORT_DECLARATIONS, "IMPORT_DECLARATIONS"), root_1);

            	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:129:65: ( StringLiteral )*
            	    while ( stream_StringLiteral.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_StringLiteral.NextNode());

            	    }
            	    stream_StringLiteral.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 = (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 
    	{
            if ( state.backtracking > 0 ) 
            {
            	Memoize(input, 5, importDeclarations_StartIndex); 
            }
        }
        return retval;
    }
コード例 #20
0
ファイル: ASParser.cs プロジェクト: nomilogic/fdplugins
        // throws RecognitionException [1]
        // $ANTLR start expressionList
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1222:1: expressionList : assignmentExpression ( COMMA assignmentExpression )* -> ^( ELIST assignmentExpression ( COMMA assignmentExpression )* ) ;
        public expressionList_return expressionList()
        {
            expressionList_return retval = new expressionList_return();
            retval.start = input.LT(1);
            int expressionList_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken COMMA227 = null;
            assignmentExpression_return assignmentExpression226 = null;

            assignmentExpression_return assignmentExpression228 = null;

            CommonTree COMMA227_tree=null;
            RewriteRuleTokenStream stream_COMMA = new RewriteRuleTokenStream(adaptor,"token COMMA");
            RewriteRuleSubtreeStream stream_assignmentExpression = new RewriteRuleSubtreeStream(adaptor,"rule assignmentExpression");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 86) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1223:4: ( assignmentExpression ( COMMA assignmentExpression )* -> ^( ELIST assignmentExpression ( COMMA assignmentExpression )* ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1223:4: assignmentExpression ( COMMA assignmentExpression )*
            {
                PushFollow(FOLLOW_assignmentExpression_in_expressionList4132);
                assignmentExpression226 = assignmentExpression();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_assignmentExpression.Add(assignmentExpression226.Tree);
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1224:3: ( COMMA assignmentExpression )*
                do
                {
                    int alt66 = 2;
                    int LA66_0 = input.LA(1);

                    if ( (LA66_0 == COMMA) )
                    {
                        alt66 = 1;
                    }

                    switch (alt66)
                    {
                        case 1 :
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1225:4: COMMA assignmentExpression
                            {
                                COMMA227 = (CommonToken)input.LT(1);
                                Match(input,COMMA,FOLLOW_COMMA_in_expressionList4142); if (failed) return retval;
                                if ( backtracking==0 ) stream_COMMA.Add(COMMA227);

                                if ( backtracking == 0 )
                                {
                                  buffer.Append(options.SpaceBetweenArguments ? ", " : ",");
                                }
                                PushFollow(FOLLOW_assignmentExpression_in_expressionList4154);
                                assignmentExpression228 = assignmentExpression();
                                followingStackPointer_--;
                                if (failed) return retval;
                                if ( backtracking==0 ) stream_assignmentExpression.Add(assignmentExpression228.Tree);

                            }
                            break;

                        default:
                            goto loop66;
                    }
                } while (true);

                loop66:
                    ;	// Stops C# compiler whinging that label 'loop66' has no statements

                // AST REWRITE
                // elements:          assignmentExpression, assignmentExpression, COMMA
                // token labels:
                // rule labels:       retval
                // token list labels:
                // rule list labels:
                if ( backtracking==0 ) {
                retval.tree = root_0;
                RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "token retval", (retval!=null ? retval.Tree : null));

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 1227:6: -> ^( ELIST assignmentExpression ( COMMA assignmentExpression )* )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1227:9: ^( ELIST assignmentExpression ( COMMA assignmentExpression )* )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(ELIST, "ELIST"), root_1);

                    adaptor.AddChild(root_1, stream_assignmentExpression.Next());
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1227:38: ( COMMA assignmentExpression )*
                    while ( stream_assignmentExpression.HasNext() || stream_COMMA.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_COMMA.Next());
                        adaptor.AddChild(root_1, stream_assignmentExpression.Next());

                    }
                    stream_assignmentExpression.Reset();
                    stream_COMMA.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

            retval.stop = input.LT(-1);

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 86, expressionList_StartIndex);
            }
            }
            return retval;
        }
コード例 #21
0
ファイル: PsimulexParser.cs プロジェクト: hunpody/psimulex
    // $ANTLR start "localVariableDeclaration"
    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:522:1: localVariableDeclaration options {k=5; } : ( type Identifier -> ^( VARDECLARE type Identifier ) | type ( Reference )? Identifier Assign expression -> ^( VARINIT type ( Reference )? Identifier expression ) );
    public PsimulexParser.localVariableDeclaration_return localVariableDeclaration() // throws RecognitionException [1]
    {   
        PsimulexParser.localVariableDeclaration_return retval = new PsimulexParser.localVariableDeclaration_return();
        retval.Start = input.LT(1);
        int localVariableDeclaration_StartIndex = input.Index();
        CommonTree root_0 = null;

        IToken Identifier205 = null;
        IToken Reference207 = null;
        IToken Identifier208 = null;
        IToken Assign209 = null;
        PsimulexParser.type_return type204 = default(PsimulexParser.type_return);

        PsimulexParser.type_return type206 = default(PsimulexParser.type_return);

        PsimulexParser.expression_return expression210 = default(PsimulexParser.expression_return);


        CommonTree Identifier205_tree=null;
        CommonTree Reference207_tree=null;
        CommonTree Identifier208_tree=null;
        CommonTree Assign209_tree=null;
        RewriteRuleTokenStream stream_Assign = new RewriteRuleTokenStream(adaptor,"token Assign");
        RewriteRuleTokenStream stream_Reference = new RewriteRuleTokenStream(adaptor,"token Reference");
        RewriteRuleTokenStream stream_Identifier = new RewriteRuleTokenStream(adaptor,"token Identifier");
        RewriteRuleSubtreeStream stream_expression = new RewriteRuleSubtreeStream(adaptor,"rule expression");
        RewriteRuleSubtreeStream stream_type = new RewriteRuleSubtreeStream(adaptor,"rule type");
        try 
    	{
    	    if ( (state.backtracking > 0) && AlreadyParsedRule(input, 66) ) 
    	    {
    	    	return retval; 
    	    }
            // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:524:2: ( type Identifier -> ^( VARDECLARE type Identifier ) | type ( Reference )? Identifier Assign expression -> ^( VARINIT type ( Reference )? Identifier expression ) )
            int alt49 = 2;
            alt49 = dfa49.Predict(input);
            switch (alt49) 
            {
                case 1 :
                    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:524:6: type Identifier
                    {
                    	PushFollow(FOLLOW_type_in_localVariableDeclaration2753);
                    	type204 = type();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) ) stream_type.Add(type204.Tree);
                    	Identifier205=(IToken)Match(input,Identifier,FOLLOW_Identifier_in_localVariableDeclaration2755); if (state.failed) return retval; 
                    	if ( (state.backtracking==0) ) stream_Identifier.Add(Identifier205);



                    	// AST REWRITE
                    	// elements:          type, Identifier
                    	// 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 = (CommonTree)adaptor.GetNilNode();
                    	// 524:22: -> ^( VARDECLARE type Identifier )
                    	{
                    	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:524:25: ^( VARDECLARE type Identifier )
                    	    {
                    	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(VARDECLARE, "VARDECLARE"), root_1);

                    	    adaptor.AddChild(root_1, stream_type.NextTree());
                    	    adaptor.AddChild(root_1, stream_Identifier.NextNode());

                    	    adaptor.AddChild(root_0, root_1);
                    	    }

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;}
                    }
                    break;
                case 2 :
                    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:526:6: type ( Reference )? Identifier Assign expression
                    {
                    	PushFollow(FOLLOW_type_in_localVariableDeclaration2779);
                    	type206 = type();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) ) stream_type.Add(type206.Tree);
                    	// C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:526:11: ( Reference )?
                    	int alt48 = 2;
                    	int LA48_0 = input.LA(1);

                    	if ( (LA48_0 == Reference) )
                    	{
                    	    alt48 = 1;
                    	}
                    	switch (alt48) 
                    	{
                    	    case 1 :
                    	        // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:0:0: Reference
                    	        {
                    	        	Reference207=(IToken)Match(input,Reference,FOLLOW_Reference_in_localVariableDeclaration2781); if (state.failed) return retval; 
                    	        	if ( (state.backtracking==0) ) stream_Reference.Add(Reference207);


                    	        }
                    	        break;

                    	}

                    	Identifier208=(IToken)Match(input,Identifier,FOLLOW_Identifier_in_localVariableDeclaration2784); if (state.failed) return retval; 
                    	if ( (state.backtracking==0) ) stream_Identifier.Add(Identifier208);

                    	Assign209=(IToken)Match(input,Assign,FOLLOW_Assign_in_localVariableDeclaration2786); if (state.failed) return retval; 
                    	if ( (state.backtracking==0) ) stream_Assign.Add(Assign209);

                    	PushFollow(FOLLOW_expression_in_localVariableDeclaration2788);
                    	expression210 = expression();
                    	state.followingStackPointer--;
                    	if (state.failed) return retval;
                    	if ( (state.backtracking==0) ) stream_expression.Add(expression210.Tree);


                    	// AST REWRITE
                    	// elements:          type, Identifier, expression, Reference
                    	// 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 = (CommonTree)adaptor.GetNilNode();
                    	// 526:51: -> ^( VARINIT type ( Reference )? Identifier expression )
                    	{
                    	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:526:54: ^( VARINIT type ( Reference )? Identifier expression )
                    	    {
                    	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(VARINIT, "VARINIT"), root_1);

                    	    adaptor.AddChild(root_1, stream_type.NextTree());
                    	    // C:\\Works\\Psimulex\\VapeTeam.Psimulex\\VapeTeam.Psimulex.Compiler.Antlr\\Grammar\\Psimulex.g:526:70: ( Reference )?
                    	    if ( stream_Reference.HasNext() )
                    	    {
                    	        adaptor.AddChild(root_1, stream_Reference.NextNode());

                    	    }
                    	    stream_Reference.Reset();
                    	    adaptor.AddChild(root_1, stream_Identifier.NextNode());
                    	    adaptor.AddChild(root_1, stream_expression.NextTree());

                    	    adaptor.AddChild(root_0, root_1);
                    	    }

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;}
                    }
                    break;

            }
            retval.Stop = input.LT(-1);

            if ( (state.backtracking==0) )
            {	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 
    	{
            if ( state.backtracking > 0 ) 
            {
            	Memoize(input, 66, localVariableDeclaration_StartIndex); 
            }
        }
        return retval;
    }
コード例 #22
0
	private AstParserRuleReturnScope<CommonTree, IToken> func_def()
	{
		EnterRule_func_def();
		EnterRule("func_def", 31);
		TraceIn("func_def", 31);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken string_literal286 = default(IToken);
		IToken WS287 = default(IToken);
		IToken string_literal288 = default(IToken);
		IToken WS289 = default(IToken);
		IToken WS291 = default(IToken);
		IToken char_literal292 = default(IToken);
		IToken WS293 = default(IToken);
		IToken WS295 = default(IToken);
		IToken WS297 = default(IToken);
		IToken char_literal298 = default(IToken);
		IToken WS299 = default(IToken);
		IToken WS301 = default(IToken);
		IToken char_literal302 = default(IToken);
		IToken WS303 = default(IToken);
		IToken NEWLINE304 = default(IToken);
		IToken WS306 = default(IToken);
		IToken char_literal307 = default(IToken);
		IToken WS308 = default(IToken);
		IToken WS310 = default(IToken);
		IToken NEWLINE311 = default(IToken);
		IToken INDENT312 = default(IToken);
		IToken NEWLINE313 = default(IToken);
		IToken WS315 = default(IToken);
		IToken NEWLINE316 = default(IToken);
		IToken DEDENT317 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> attribute285 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> func_type290 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> func_name294 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> generic_parameter_ident296 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> func_args300 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> stmt_block305 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> where_expr309 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> match_item314 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal286_tree = default(CommonTree);
		CommonTree WS287_tree = default(CommonTree);
		CommonTree string_literal288_tree = default(CommonTree);
		CommonTree WS289_tree = default(CommonTree);
		CommonTree WS291_tree = default(CommonTree);
		CommonTree char_literal292_tree = default(CommonTree);
		CommonTree WS293_tree = default(CommonTree);
		CommonTree WS295_tree = default(CommonTree);
		CommonTree WS297_tree = default(CommonTree);
		CommonTree char_literal298_tree = default(CommonTree);
		CommonTree WS299_tree = default(CommonTree);
		CommonTree WS301_tree = default(CommonTree);
		CommonTree char_literal302_tree = default(CommonTree);
		CommonTree WS303_tree = default(CommonTree);
		CommonTree NEWLINE304_tree = default(CommonTree);
		CommonTree WS306_tree = default(CommonTree);
		CommonTree char_literal307_tree = default(CommonTree);
		CommonTree WS308_tree = default(CommonTree);
		CommonTree WS310_tree = default(CommonTree);
		CommonTree NEWLINE311_tree = default(CommonTree);
		CommonTree INDENT312_tree = default(CommonTree);
		CommonTree NEWLINE313_tree = default(CommonTree);
		CommonTree WS315_tree = default(CommonTree);
		CommonTree NEWLINE316_tree = default(CommonTree);
		CommonTree DEDENT317_tree = default(CommonTree);
		RewriteRuleITokenStream stream_163=new RewriteRuleITokenStream(adaptor,"token 163");
		RewriteRuleITokenStream stream_94=new RewriteRuleITokenStream(adaptor,"token 94");
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_121=new RewriteRuleITokenStream(adaptor,"token 121");
		RewriteRuleITokenStream stream_DEDENT=new RewriteRuleITokenStream(adaptor,"token DEDENT");
		RewriteRuleITokenStream stream_93=new RewriteRuleITokenStream(adaptor,"token 93");
		RewriteRuleITokenStream stream_NEWLINE=new RewriteRuleITokenStream(adaptor,"token NEWLINE");
		RewriteRuleITokenStream stream_186=new RewriteRuleITokenStream(adaptor,"token 186");
		RewriteRuleITokenStream stream_178=new RewriteRuleITokenStream(adaptor,"token 178");
		RewriteRuleITokenStream stream_INDENT=new RewriteRuleITokenStream(adaptor,"token INDENT");
		RewriteRuleSubtreeStream stream_match_item=new RewriteRuleSubtreeStream(adaptor,"rule match_item");
		RewriteRuleSubtreeStream stream_func_args=new RewriteRuleSubtreeStream(adaptor,"rule func_args");
		RewriteRuleSubtreeStream stream_func_type=new RewriteRuleSubtreeStream(adaptor,"rule func_type");
		RewriteRuleSubtreeStream stream_attribute=new RewriteRuleSubtreeStream(adaptor,"rule attribute");
		RewriteRuleSubtreeStream stream_func_name=new RewriteRuleSubtreeStream(adaptor,"rule func_name");
		RewriteRuleSubtreeStream stream_stmt_block=new RewriteRuleSubtreeStream(adaptor,"rule stmt_block");
		RewriteRuleSubtreeStream stream_where_expr=new RewriteRuleSubtreeStream(adaptor,"rule where_expr");
		RewriteRuleSubtreeStream stream_generic_parameter_ident=new RewriteRuleSubtreeStream(adaptor,"rule generic_parameter_ident");
		try { DebugEnterRule(GrammarFileName, "func_def");
		DebugLocation(375, 4);
		try
		{
			// SugarCpp.g:376:2: ( ( attribute )? ( 'public' ( WS )* )? ( 'virtual' ( WS )* )? ( func_type ( WS )* )? ( '~' ( WS )* )? func_name ( ( WS )* generic_parameter_ident )? ( WS )* '(' ( ( WS )* func_args )? ( WS )* ')' ( ( WS )* ( NEWLINE )+ stmt_block -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? stmt_block ) | ( WS )* '=' ( ( WS )* where_expr -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? where_expr ) | ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* ( match_item ( WS )* ( NEWLINE )+ )+ DEDENT -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? ^( Match_Expr ( match_item )+ ) ) ) | -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? Func_Declare ) ) )
			DebugEnterAlt(1);
			// SugarCpp.g:376:4: ( attribute )? ( 'public' ( WS )* )? ( 'virtual' ( WS )* )? ( func_type ( WS )* )? ( '~' ( WS )* )? func_name ( ( WS )* generic_parameter_ident )? ( WS )* '(' ( ( WS )* func_args )? ( WS )* ')' ( ( WS )* ( NEWLINE )+ stmt_block -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? stmt_block ) | ( WS )* '=' ( ( WS )* where_expr -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? where_expr ) | ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* ( match_item ( WS )* ( NEWLINE )+ )+ DEDENT -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? ^( Match_Expr ( match_item )+ ) ) ) | -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? Func_Declare ) )
			{
			DebugLocation(376, 4);
			// SugarCpp.g:376:4: ( attribute )?
			int alt186=2;
			try { DebugEnterSubRule(186);
			try { DebugEnterDecision(186, false);
			int LA186_0 = input.LA(1);

			if ((LA186_0==132))
			{
				alt186 = 1;
			}
			} finally { DebugExitDecision(186); }
			switch (alt186)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:376:4: attribute
				{
				DebugLocation(376, 4);
				PushFollow(Follow._attribute_in_func_def2648);
				attribute285=attribute();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_attribute.Add(attribute285.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(186); }

			DebugLocation(376, 15);
			// SugarCpp.g:376:15: ( 'public' ( WS )* )?
			int alt188=2;
			try { DebugEnterSubRule(188);
			try { DebugEnterDecision(188, false);
			int LA188_0 = input.LA(1);

			if ((LA188_0==163))
			{
				alt188 = 1;
			}
			} finally { DebugExitDecision(188); }
			switch (alt188)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:376:16: 'public' ( WS )*
				{
				DebugLocation(376, 16);
				string_literal286=(IToken)Match(input,163,Follow._163_in_func_def2652); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_163.Add(string_literal286);

				DebugLocation(376, 25);
				// SugarCpp.g:376:25: ( WS )*
				try { DebugEnterSubRule(187);
				while (true)
				{
					int alt187=2;
					try { DebugEnterDecision(187, false);
					int LA187_0 = input.LA(1);

					if ((LA187_0==WS))
					{
						alt187 = 1;
					}


					} finally { DebugExitDecision(187); }
					switch ( alt187 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:376:25: WS
						{
						DebugLocation(376, 25);
						WS287=(IToken)Match(input,WS,Follow._WS_in_func_def2654); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS287);


						}
						break;

					default:
						goto loop187;
					}
				}

				loop187:
					;

				} finally { DebugExitSubRule(187); }


				}
				break;

			}
			} finally { DebugExitSubRule(188); }

			DebugLocation(376, 31);
			// SugarCpp.g:376:31: ( 'virtual' ( WS )* )?
			int alt190=2;
			try { DebugEnterSubRule(190);
			try { DebugEnterDecision(190, false);
			int LA190_0 = input.LA(1);

			if ((LA190_0==178))
			{
				alt190 = 1;
			}
			} finally { DebugExitDecision(190); }
			switch (alt190)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:376:32: 'virtual' ( WS )*
				{
				DebugLocation(376, 32);
				string_literal288=(IToken)Match(input,178,Follow._178_in_func_def2660); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_178.Add(string_literal288);

				DebugLocation(376, 42);
				// SugarCpp.g:376:42: ( WS )*
				try { DebugEnterSubRule(189);
				while (true)
				{
					int alt189=2;
					try { DebugEnterDecision(189, false);
					int LA189_0 = input.LA(1);

					if ((LA189_0==WS))
					{
						alt189 = 1;
					}


					} finally { DebugExitDecision(189); }
					switch ( alt189 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:376:42: WS
						{
						DebugLocation(376, 42);
						WS289=(IToken)Match(input,WS,Follow._WS_in_func_def2662); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS289);


						}
						break;

					default:
						goto loop189;
					}
				}

				loop189:
					;

				} finally { DebugExitSubRule(189); }


				}
				break;

			}
			} finally { DebugExitSubRule(190); }

			DebugLocation(376, 48);
			// SugarCpp.g:376:48: ( func_type ( WS )* )?
			int alt192=2;
			try { DebugEnterSubRule(192);
			try { DebugEnterDecision(192, false);
			try
			{
				alt192 = dfa192.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(192); }
			switch (alt192)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:376:49: func_type ( WS )*
				{
				DebugLocation(376, 49);
				PushFollow(Follow._func_type_in_func_def2668);
				func_type290=func_type();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_func_type.Add(func_type290.Tree);
				DebugLocation(376, 59);
				// SugarCpp.g:376:59: ( WS )*
				try { DebugEnterSubRule(191);
				while (true)
				{
					int alt191=2;
					try { DebugEnterDecision(191, false);
					int LA191_0 = input.LA(1);

					if ((LA191_0==WS))
					{
						alt191 = 1;
					}


					} finally { DebugExitDecision(191); }
					switch ( alt191 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:376:59: WS
						{
						DebugLocation(376, 59);
						WS291=(IToken)Match(input,WS,Follow._WS_in_func_def2670); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS291);


						}
						break;

					default:
						goto loop191;
					}
				}

				loop191:
					;

				} finally { DebugExitSubRule(191); }


				}
				break;

			}
			} finally { DebugExitSubRule(192); }

			DebugLocation(376, 65);
			// SugarCpp.g:376:65: ( '~' ( WS )* )?
			int alt194=2;
			try { DebugEnterSubRule(194);
			try { DebugEnterDecision(194, false);
			int LA194_0 = input.LA(1);

			if ((LA194_0==186))
			{
				alt194 = 1;
			}
			} finally { DebugExitDecision(194); }
			switch (alt194)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:376:66: '~' ( WS )*
				{
				DebugLocation(376, 66);
				char_literal292=(IToken)Match(input,186,Follow._186_in_func_def2676); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_186.Add(char_literal292);

				DebugLocation(376, 70);
				// SugarCpp.g:376:70: ( WS )*
				try { DebugEnterSubRule(193);
				while (true)
				{
					int alt193=2;
					try { DebugEnterDecision(193, false);
					int LA193_0 = input.LA(1);

					if ((LA193_0==WS))
					{
						alt193 = 1;
					}


					} finally { DebugExitDecision(193); }
					switch ( alt193 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:376:70: WS
						{
						DebugLocation(376, 70);
						WS293=(IToken)Match(input,WS,Follow._WS_in_func_def2678); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS293);


						}
						break;

					default:
						goto loop193;
					}
				}

				loop193:
					;

				} finally { DebugExitSubRule(193); }


				}
				break;

			}
			} finally { DebugExitSubRule(194); }

			DebugLocation(376, 76);
			PushFollow(Follow._func_name_in_func_def2683);
			func_name294=func_name();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_func_name.Add(func_name294.Tree);
			DebugLocation(376, 86);
			// SugarCpp.g:376:86: ( ( WS )* generic_parameter_ident )?
			int alt196=2;
			try { DebugEnterSubRule(196);
			try { DebugEnterDecision(196, false);
			try
			{
				alt196 = dfa196.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(196); }
			switch (alt196)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:376:87: ( WS )* generic_parameter_ident
				{
				DebugLocation(376, 87);
				// SugarCpp.g:376:87: ( WS )*
				try { DebugEnterSubRule(195);
				while (true)
				{
					int alt195=2;
					try { DebugEnterDecision(195, false);
					int LA195_0 = input.LA(1);

					if ((LA195_0==WS))
					{
						alt195 = 1;
					}


					} finally { DebugExitDecision(195); }
					switch ( alt195 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:376:87: WS
						{
						DebugLocation(376, 87);
						WS295=(IToken)Match(input,WS,Follow._WS_in_func_def2686); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS295);


						}
						break;

					default:
						goto loop195;
					}
				}

				loop195:
					;

				} finally { DebugExitSubRule(195); }

				DebugLocation(376, 91);
				PushFollow(Follow._generic_parameter_ident_in_func_def2689);
				generic_parameter_ident296=generic_parameter_ident();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_generic_parameter_ident.Add(generic_parameter_ident296.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(196); }

			DebugLocation(376, 117);
			// SugarCpp.g:376:117: ( WS )*
			try { DebugEnterSubRule(197);
			while (true)
			{
				int alt197=2;
				try { DebugEnterDecision(197, false);
				int LA197_0 = input.LA(1);

				if ((LA197_0==WS))
				{
					alt197 = 1;
				}


				} finally { DebugExitDecision(197); }
				switch ( alt197 )
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:376:117: WS
					{
					DebugLocation(376, 117);
					WS297=(IToken)Match(input,WS,Follow._WS_in_func_def2693); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_WS.Add(WS297);


					}
					break;

				default:
					goto loop197;
				}
			}

			loop197:
				;

			} finally { DebugExitSubRule(197); }

			DebugLocation(376, 121);
			char_literal298=(IToken)Match(input,93,Follow._93_in_func_def2696); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_93.Add(char_literal298);

			DebugLocation(376, 125);
			// SugarCpp.g:376:125: ( ( WS )* func_args )?
			int alt199=2;
			try { DebugEnterSubRule(199);
			try { DebugEnterDecision(199, false);
			try
			{
				alt199 = dfa199.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(199); }
			switch (alt199)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:376:126: ( WS )* func_args
				{
				DebugLocation(376, 126);
				// SugarCpp.g:376:126: ( WS )*
				try { DebugEnterSubRule(198);
				while (true)
				{
					int alt198=2;
					try { DebugEnterDecision(198, false);
					int LA198_0 = input.LA(1);

					if ((LA198_0==WS))
					{
						alt198 = 1;
					}


					} finally { DebugExitDecision(198); }
					switch ( alt198 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:376:126: WS
						{
						DebugLocation(376, 126);
						WS299=(IToken)Match(input,WS,Follow._WS_in_func_def2699); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS299);


						}
						break;

					default:
						goto loop198;
					}
				}

				loop198:
					;

				} finally { DebugExitSubRule(198); }

				DebugLocation(376, 130);
				PushFollow(Follow._func_args_in_func_def2702);
				func_args300=func_args();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_func_args.Add(func_args300.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(199); }

			DebugLocation(376, 142);
			// SugarCpp.g:376:142: ( WS )*
			try { DebugEnterSubRule(200);
			while (true)
			{
				int alt200=2;
				try { DebugEnterDecision(200, false);
				int LA200_0 = input.LA(1);

				if ((LA200_0==WS))
				{
					alt200 = 1;
				}


				} finally { DebugExitDecision(200); }
				switch ( alt200 )
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:376:142: WS
					{
					DebugLocation(376, 142);
					WS301=(IToken)Match(input,WS,Follow._WS_in_func_def2706); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_WS.Add(WS301);


					}
					break;

				default:
					goto loop200;
				}
			}

			loop200:
				;

			} finally { DebugExitSubRule(200); }

			DebugLocation(376, 146);
			char_literal302=(IToken)Match(input,94,Follow._94_in_func_def2709); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_94.Add(char_literal302);

			DebugLocation(376, 150);
			// SugarCpp.g:376:150: ( ( WS )* ( NEWLINE )+ stmt_block -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? stmt_block ) | ( WS )* '=' ( ( WS )* where_expr -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? where_expr ) | ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* ( match_item ( WS )* ( NEWLINE )+ )+ DEDENT -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? ^( Match_Expr ( match_item )+ ) ) ) | -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? Func_Declare ) )
			int alt212=3;
			try { DebugEnterSubRule(212);
			try { DebugEnterDecision(212, false);
			try
			{
				alt212 = dfa212.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(212); }
			switch (alt212)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:376:152: ( WS )* ( NEWLINE )+ stmt_block
				{
				DebugLocation(376, 152);
				// SugarCpp.g:376:152: ( WS )*
				try { DebugEnterSubRule(201);
				while (true)
				{
					int alt201=2;
					try { DebugEnterDecision(201, false);
					int LA201_0 = input.LA(1);

					if ((LA201_0==WS))
					{
						alt201 = 1;
					}


					} finally { DebugExitDecision(201); }
					switch ( alt201 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:376:152: WS
						{
						DebugLocation(376, 152);
						WS303=(IToken)Match(input,WS,Follow._WS_in_func_def2713); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS303);


						}
						break;

					default:
						goto loop201;
					}
				}

				loop201:
					;

				} finally { DebugExitSubRule(201); }

				DebugLocation(376, 156);
				// SugarCpp.g:376:156: ( NEWLINE )+
				int cnt202=0;
				try { DebugEnterSubRule(202);
				while (true)
				{
					int alt202=2;
					try { DebugEnterDecision(202, false);
					int LA202_0 = input.LA(1);

					if ((LA202_0==NEWLINE))
					{
						alt202 = 1;
					}


					} finally { DebugExitDecision(202); }
					switch (alt202)
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:376:156: NEWLINE
						{
						DebugLocation(376, 156);
						NEWLINE304=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_func_def2716); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE304);


						}
						break;

					default:
						if (cnt202 >= 1)
							goto loop202;

						if (state.backtracking>0) {state.failed=true; return retval;}
						EarlyExitException eee202 = new EarlyExitException( 202, input );
						DebugRecognitionException(eee202);
						throw eee202;
					}
					cnt202++;
				}
				loop202:
					;

				} finally { DebugExitSubRule(202); }

				DebugLocation(376, 165);
				PushFollow(Follow._stmt_block_in_func_def2719);
				stmt_block305=stmt_block();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_stmt_block.Add(stmt_block305.Tree);


				{
				// AST REWRITE
				// elements: func_args, 186, stmt_block, func_type, 178, generic_parameter_ident, func_name, attribute, 163
				// 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 = (CommonTree)adaptor.Nil();
				// 376:176: -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? stmt_block )
				{
					DebugLocation(376, 179);
					// SugarCpp.g:376:179: ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? stmt_block )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(376, 181);
					root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Func_Def, "Func_Def"), root_1);

					DebugLocation(376, 190);
					// SugarCpp.g:376:190: ( 'public' )?
					if (stream_163.HasNext)
					{
						DebugLocation(376, 190);
						adaptor.AddChild(root_1, stream_163.NextNode());

					}
					stream_163.Reset();
					DebugLocation(376, 200);
					// SugarCpp.g:376:200: ( 'virtual' )?
					if (stream_178.HasNext)
					{
						DebugLocation(376, 200);
						adaptor.AddChild(root_1, stream_178.NextNode());

					}
					stream_178.Reset();
					DebugLocation(376, 211);
					// SugarCpp.g:376:211: ( attribute )?
					if (stream_attribute.HasNext)
					{
						DebugLocation(376, 211);
						adaptor.AddChild(root_1, stream_attribute.NextTree());

					}
					stream_attribute.Reset();
					DebugLocation(376, 222);
					// SugarCpp.g:376:222: ( func_type )?
					if (stream_func_type.HasNext)
					{
						DebugLocation(376, 222);
						adaptor.AddChild(root_1, stream_func_type.NextTree());

					}
					stream_func_type.Reset();
					DebugLocation(376, 233);
					// SugarCpp.g:376:233: ( '~' )?
					if (stream_186.HasNext)
					{
						DebugLocation(376, 233);
						adaptor.AddChild(root_1, stream_186.NextNode());

					}
					stream_186.Reset();
					DebugLocation(376, 238);
					adaptor.AddChild(root_1, stream_func_name.NextTree());
					DebugLocation(376, 248);
					// SugarCpp.g:376:248: ( generic_parameter_ident )?
					if (stream_generic_parameter_ident.HasNext)
					{
						DebugLocation(376, 248);
						adaptor.AddChild(root_1, stream_generic_parameter_ident.NextTree());

					}
					stream_generic_parameter_ident.Reset();
					DebugLocation(376, 273);
					// SugarCpp.g:376:273: ( func_args )?
					if (stream_func_args.HasNext)
					{
						DebugLocation(376, 273);
						adaptor.AddChild(root_1, stream_func_args.NextTree());

					}
					stream_func_args.Reset();
					DebugLocation(376, 284);
					adaptor.AddChild(root_1, stream_stmt_block.NextTree());

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarCpp.g:377:80: ( WS )* '=' ( ( WS )* where_expr -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? where_expr ) | ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* ( match_item ( WS )* ( NEWLINE )+ )+ DEDENT -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? ^( Match_Expr ( match_item )+ ) ) )
				{
				DebugLocation(377, 80);
				// SugarCpp.g:377:80: ( WS )*
				try { DebugEnterSubRule(203);
				while (true)
				{
					int alt203=2;
					try { DebugEnterDecision(203, false);
					int LA203_0 = input.LA(1);

					if ((LA203_0==WS))
					{
						alt203 = 1;
					}


					} finally { DebugExitDecision(203); }
					switch ( alt203 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:377:80: WS
						{
						DebugLocation(377, 80);
						WS306=(IToken)Match(input,WS,Follow._WS_in_func_def2831); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS306);


						}
						break;

					default:
						goto loop203;
					}
				}

				loop203:
					;

				} finally { DebugExitSubRule(203); }

				DebugLocation(377, 84);
				char_literal307=(IToken)Match(input,121,Follow._121_in_func_def2834); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_121.Add(char_literal307);

				DebugLocation(377, 88);
				// SugarCpp.g:377:88: ( ( WS )* where_expr -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? where_expr ) | ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* ( match_item ( WS )* ( NEWLINE )+ )+ DEDENT -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? ^( Match_Expr ( match_item )+ ) ) )
				int alt211=2;
				try { DebugEnterSubRule(211);
				try { DebugEnterDecision(211, false);
				try
				{
					alt211 = dfa211.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(211); }
				switch (alt211)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:377:90: ( WS )* where_expr
					{
					DebugLocation(377, 90);
					// SugarCpp.g:377:90: ( WS )*
					try { DebugEnterSubRule(204);
					while (true)
					{
						int alt204=2;
						try { DebugEnterDecision(204, false);
						int LA204_0 = input.LA(1);

						if ((LA204_0==WS))
						{
							alt204 = 1;
						}


						} finally { DebugExitDecision(204); }
						switch ( alt204 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:377:90: WS
							{
							DebugLocation(377, 90);
							WS308=(IToken)Match(input,WS,Follow._WS_in_func_def2838); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS308);


							}
							break;

						default:
							goto loop204;
						}
					}

					loop204:
						;

					} finally { DebugExitSubRule(204); }

					DebugLocation(377, 94);
					PushFollow(Follow._where_expr_in_func_def2841);
					where_expr309=where_expr();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_where_expr.Add(where_expr309.Tree);


					{
					// AST REWRITE
					// elements: where_expr, 186, 163, generic_parameter_ident, func_args, func_name, 178, func_type, attribute
					// 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 = (CommonTree)adaptor.Nil();
					// 377:105: -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? where_expr )
					{
						DebugLocation(377, 108);
						// SugarCpp.g:377:108: ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? where_expr )
						{
						CommonTree root_1 = (CommonTree)adaptor.Nil();
						DebugLocation(377, 110);
						root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Func_Def, "Func_Def"), root_1);

						DebugLocation(377, 119);
						// SugarCpp.g:377:119: ( 'public' )?
						if (stream_163.HasNext)
						{
							DebugLocation(377, 119);
							adaptor.AddChild(root_1, stream_163.NextNode());

						}
						stream_163.Reset();
						DebugLocation(377, 129);
						// SugarCpp.g:377:129: ( 'virtual' )?
						if (stream_178.HasNext)
						{
							DebugLocation(377, 129);
							adaptor.AddChild(root_1, stream_178.NextNode());

						}
						stream_178.Reset();
						DebugLocation(377, 140);
						// SugarCpp.g:377:140: ( attribute )?
						if (stream_attribute.HasNext)
						{
							DebugLocation(377, 140);
							adaptor.AddChild(root_1, stream_attribute.NextTree());

						}
						stream_attribute.Reset();
						DebugLocation(377, 151);
						// SugarCpp.g:377:151: ( func_type )?
						if (stream_func_type.HasNext)
						{
							DebugLocation(377, 151);
							adaptor.AddChild(root_1, stream_func_type.NextTree());

						}
						stream_func_type.Reset();
						DebugLocation(377, 162);
						// SugarCpp.g:377:162: ( '~' )?
						if (stream_186.HasNext)
						{
							DebugLocation(377, 162);
							adaptor.AddChild(root_1, stream_186.NextNode());

						}
						stream_186.Reset();
						DebugLocation(377, 167);
						adaptor.AddChild(root_1, stream_func_name.NextTree());
						DebugLocation(377, 177);
						// SugarCpp.g:377:177: ( generic_parameter_ident )?
						if (stream_generic_parameter_ident.HasNext)
						{
							DebugLocation(377, 177);
							adaptor.AddChild(root_1, stream_generic_parameter_ident.NextTree());

						}
						stream_generic_parameter_ident.Reset();
						DebugLocation(377, 202);
						// SugarCpp.g:377:202: ( func_args )?
						if (stream_func_args.HasNext)
						{
							DebugLocation(377, 202);
							adaptor.AddChild(root_1, stream_func_args.NextTree());

						}
						stream_func_args.Reset();
						DebugLocation(377, 213);
						adaptor.AddChild(root_1, stream_where_expr.NextTree());

						adaptor.AddChild(root_0, root_1);
						}

					}

					retval.Tree = root_0;
					}
					}

					}
					break;
				case 2:
					DebugEnterAlt(2);
					// SugarCpp.g:378:84: ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* ( match_item ( WS )* ( NEWLINE )+ )+ DEDENT
					{
					DebugLocation(378, 84);
					// SugarCpp.g:378:84: ( WS )*
					try { DebugEnterSubRule(205);
					while (true)
					{
						int alt205=2;
						try { DebugEnterDecision(205, false);
						int LA205_0 = input.LA(1);

						if ((LA205_0==WS))
						{
							alt205 = 1;
						}


						} finally { DebugExitDecision(205); }
						switch ( alt205 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:378:84: WS
							{
							DebugLocation(378, 84);
							WS310=(IToken)Match(input,WS,Follow._WS_in_func_def2957); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS310);


							}
							break;

						default:
							goto loop205;
						}
					}

					loop205:
						;

					} finally { DebugExitSubRule(205); }

					DebugLocation(378, 88);
					// SugarCpp.g:378:88: ( NEWLINE )+
					int cnt206=0;
					try { DebugEnterSubRule(206);
					while (true)
					{
						int alt206=2;
						try { DebugEnterDecision(206, false);
						int LA206_0 = input.LA(1);

						if ((LA206_0==NEWLINE))
						{
							alt206 = 1;
						}


						} finally { DebugExitDecision(206); }
						switch (alt206)
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:378:88: NEWLINE
							{
							DebugLocation(378, 88);
							NEWLINE311=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_func_def2960); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE311);


							}
							break;

						default:
							if (cnt206 >= 1)
								goto loop206;

							if (state.backtracking>0) {state.failed=true; return retval;}
							EarlyExitException eee206 = new EarlyExitException( 206, input );
							DebugRecognitionException(eee206);
							throw eee206;
						}
						cnt206++;
					}
					loop206:
						;

					} finally { DebugExitSubRule(206); }

					DebugLocation(378, 97);
					INDENT312=(IToken)Match(input,INDENT,Follow._INDENT_in_func_def2963); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_INDENT.Add(INDENT312);

					DebugLocation(378, 104);
					// SugarCpp.g:378:104: ( NEWLINE )*
					try { DebugEnterSubRule(207);
					while (true)
					{
						int alt207=2;
						try { DebugEnterDecision(207, false);
						int LA207_0 = input.LA(1);

						if ((LA207_0==NEWLINE))
						{
							alt207 = 1;
						}


						} finally { DebugExitDecision(207); }
						switch ( alt207 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:378:104: NEWLINE
							{
							DebugLocation(378, 104);
							NEWLINE313=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_func_def2965); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE313);


							}
							break;

						default:
							goto loop207;
						}
					}

					loop207:
						;

					} finally { DebugExitSubRule(207); }

					DebugLocation(378, 113);
					// SugarCpp.g:378:113: ( match_item ( WS )* ( NEWLINE )+ )+
					int cnt210=0;
					try { DebugEnterSubRule(210);
					while (true)
					{
						int alt210=2;
						try { DebugEnterDecision(210, false);
						int LA210_0 = input.LA(1);

						if ((LA210_0==182))
						{
							alt210 = 1;
						}


						} finally { DebugExitDecision(210); }
						switch (alt210)
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:378:114: match_item ( WS )* ( NEWLINE )+
							{
							DebugLocation(378, 114);
							PushFollow(Follow._match_item_in_func_def2969);
							match_item314=match_item();
							PopFollow();
							if (state.failed) return retval;
							if (state.backtracking == 0) stream_match_item.Add(match_item314.Tree);
							DebugLocation(378, 125);
							// SugarCpp.g:378:125: ( WS )*
							try { DebugEnterSubRule(208);
							while (true)
							{
								int alt208=2;
								try { DebugEnterDecision(208, false);
								int LA208_0 = input.LA(1);

								if ((LA208_0==WS))
								{
									alt208 = 1;
								}


								} finally { DebugExitDecision(208); }
								switch ( alt208 )
								{
								case 1:
									DebugEnterAlt(1);
									// SugarCpp.g:378:125: WS
									{
									DebugLocation(378, 125);
									WS315=(IToken)Match(input,WS,Follow._WS_in_func_def2971); if (state.failed) return retval; 
									if (state.backtracking == 0) stream_WS.Add(WS315);


									}
									break;

								default:
									goto loop208;
								}
							}

							loop208:
								;

							} finally { DebugExitSubRule(208); }

							DebugLocation(378, 129);
							// SugarCpp.g:378:129: ( NEWLINE )+
							int cnt209=0;
							try { DebugEnterSubRule(209);
							while (true)
							{
								int alt209=2;
								try { DebugEnterDecision(209, false);
								int LA209_0 = input.LA(1);

								if ((LA209_0==NEWLINE))
								{
									alt209 = 1;
								}


								} finally { DebugExitDecision(209); }
								switch (alt209)
								{
								case 1:
									DebugEnterAlt(1);
									// SugarCpp.g:378:129: NEWLINE
									{
									DebugLocation(378, 129);
									NEWLINE316=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_func_def2974); if (state.failed) return retval; 
									if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE316);


									}
									break;

								default:
									if (cnt209 >= 1)
										goto loop209;

									if (state.backtracking>0) {state.failed=true; return retval;}
									EarlyExitException eee209 = new EarlyExitException( 209, input );
									DebugRecognitionException(eee209);
									throw eee209;
								}
								cnt209++;
							}
							loop209:
								;

							} finally { DebugExitSubRule(209); }


							}
							break;

						default:
							if (cnt210 >= 1)
								goto loop210;

							if (state.backtracking>0) {state.failed=true; return retval;}
							EarlyExitException eee210 = new EarlyExitException( 210, input );
							DebugRecognitionException(eee210);
							throw eee210;
						}
						cnt210++;
					}
					loop210:
						;

					} finally { DebugExitSubRule(210); }

					DebugLocation(378, 140);
					DEDENT317=(IToken)Match(input,DEDENT,Follow._DEDENT_in_func_def2979); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_DEDENT.Add(DEDENT317);



					{
					// AST REWRITE
					// elements: func_args, generic_parameter_ident, 163, func_type, attribute, 178, 186, func_name, match_item
					// 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 = (CommonTree)adaptor.Nil();
					// 378:147: -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? ^( Match_Expr ( match_item )+ ) )
					{
						DebugLocation(378, 150);
						// SugarCpp.g:378:150: ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? ^( Match_Expr ( match_item )+ ) )
						{
						CommonTree root_1 = (CommonTree)adaptor.Nil();
						DebugLocation(378, 152);
						root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Func_Def, "Func_Def"), root_1);

						DebugLocation(378, 161);
						// SugarCpp.g:378:161: ( 'public' )?
						if (stream_163.HasNext)
						{
							DebugLocation(378, 161);
							adaptor.AddChild(root_1, stream_163.NextNode());

						}
						stream_163.Reset();
						DebugLocation(378, 171);
						// SugarCpp.g:378:171: ( 'virtual' )?
						if (stream_178.HasNext)
						{
							DebugLocation(378, 171);
							adaptor.AddChild(root_1, stream_178.NextNode());

						}
						stream_178.Reset();
						DebugLocation(378, 182);
						// SugarCpp.g:378:182: ( attribute )?
						if (stream_attribute.HasNext)
						{
							DebugLocation(378, 182);
							adaptor.AddChild(root_1, stream_attribute.NextTree());

						}
						stream_attribute.Reset();
						DebugLocation(378, 193);
						// SugarCpp.g:378:193: ( func_type )?
						if (stream_func_type.HasNext)
						{
							DebugLocation(378, 193);
							adaptor.AddChild(root_1, stream_func_type.NextTree());

						}
						stream_func_type.Reset();
						DebugLocation(378, 204);
						// SugarCpp.g:378:204: ( '~' )?
						if (stream_186.HasNext)
						{
							DebugLocation(378, 204);
							adaptor.AddChild(root_1, stream_186.NextNode());

						}
						stream_186.Reset();
						DebugLocation(378, 209);
						adaptor.AddChild(root_1, stream_func_name.NextTree());
						DebugLocation(378, 219);
						// SugarCpp.g:378:219: ( generic_parameter_ident )?
						if (stream_generic_parameter_ident.HasNext)
						{
							DebugLocation(378, 219);
							adaptor.AddChild(root_1, stream_generic_parameter_ident.NextTree());

						}
						stream_generic_parameter_ident.Reset();
						DebugLocation(378, 244);
						// SugarCpp.g:378:244: ( func_args )?
						if (stream_func_args.HasNext)
						{
							DebugLocation(378, 244);
							adaptor.AddChild(root_1, stream_func_args.NextTree());

						}
						stream_func_args.Reset();
						DebugLocation(378, 255);
						// SugarCpp.g:378:255: ^( Match_Expr ( match_item )+ )
						{
						CommonTree root_2 = (CommonTree)adaptor.Nil();
						DebugLocation(378, 257);
						root_2 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Match_Expr, "Match_Expr"), root_2);

						DebugLocation(378, 268);
						if (!(stream_match_item.HasNext))
						{
							throw new RewriteEarlyExitException();
						}
						while ( stream_match_item.HasNext )
						{
							DebugLocation(378, 268);
							adaptor.AddChild(root_2, stream_match_item.NextTree());

						}
						stream_match_item.Reset();

						adaptor.AddChild(root_1, root_2);
						}

						adaptor.AddChild(root_0, root_1);
						}

					}

					retval.Tree = root_0;
					}
					}

					}
					break;

				}
				} finally { DebugExitSubRule(211); }


				}
				break;
			case 3:
				DebugEnterAlt(3);
				// SugarCpp.g:380:80: 
				{

				{
				// AST REWRITE
				// elements: 178, func_type, func_name, func_args, attribute, 163, generic_parameter_ident, 186
				// 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 = (CommonTree)adaptor.Nil();
				// 380:80: -> ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? Func_Declare )
				{
					DebugLocation(380, 83);
					// SugarCpp.g:380:83: ^( Func_Def ( 'public' )? ( 'virtual' )? ( attribute )? ( func_type )? ( '~' )? func_name ( generic_parameter_ident )? ( func_args )? Func_Declare )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(380, 85);
					root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Func_Def, "Func_Def"), root_1);

					DebugLocation(380, 94);
					// SugarCpp.g:380:94: ( 'public' )?
					if (stream_163.HasNext)
					{
						DebugLocation(380, 94);
						adaptor.AddChild(root_1, stream_163.NextNode());

					}
					stream_163.Reset();
					DebugLocation(380, 104);
					// SugarCpp.g:380:104: ( 'virtual' )?
					if (stream_178.HasNext)
					{
						DebugLocation(380, 104);
						adaptor.AddChild(root_1, stream_178.NextNode());

					}
					stream_178.Reset();
					DebugLocation(380, 115);
					// SugarCpp.g:380:115: ( attribute )?
					if (stream_attribute.HasNext)
					{
						DebugLocation(380, 115);
						adaptor.AddChild(root_1, stream_attribute.NextTree());

					}
					stream_attribute.Reset();
					DebugLocation(380, 126);
					// SugarCpp.g:380:126: ( func_type )?
					if (stream_func_type.HasNext)
					{
						DebugLocation(380, 126);
						adaptor.AddChild(root_1, stream_func_type.NextTree());

					}
					stream_func_type.Reset();
					DebugLocation(380, 137);
					// SugarCpp.g:380:137: ( '~' )?
					if (stream_186.HasNext)
					{
						DebugLocation(380, 137);
						adaptor.AddChild(root_1, stream_186.NextNode());

					}
					stream_186.Reset();
					DebugLocation(380, 142);
					adaptor.AddChild(root_1, stream_func_name.NextTree());
					DebugLocation(380, 152);
					// SugarCpp.g:380:152: ( generic_parameter_ident )?
					if (stream_generic_parameter_ident.HasNext)
					{
						DebugLocation(380, 152);
						adaptor.AddChild(root_1, stream_generic_parameter_ident.NextTree());

					}
					stream_generic_parameter_ident.Reset();
					DebugLocation(380, 177);
					// SugarCpp.g:380:177: ( func_args )?
					if (stream_func_args.HasNext)
					{
						DebugLocation(380, 177);
						adaptor.AddChild(root_1, stream_func_args.NextTree());

					}
					stream_func_args.Reset();
					DebugLocation(380, 188);
					adaptor.AddChild(root_1, (CommonTree)adaptor.Create(Func_Declare, "Func_Declare"));

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				break;

			}
			} finally { DebugExitSubRule(212); }


			}

			retval.Stop = (IToken)input.LT(-1);

			if (state.backtracking == 0) {
			retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("func_def", 31);
			LeaveRule("func_def", 31);
			LeaveRule_func_def();
		}
		DebugLocation(382, 4);
		} finally { DebugExitRule(GrammarFileName, "func_def"); }
		return retval;

	}
コード例 #23
0
ファイル: cParser.cs プロジェクト: greenflame/vsu_compiler
	private AstParserRuleReturnScope<object, IToken> var_declaration()
	{
		EnterRule_var_declaration();
		EnterRule("var_declaration", 12);
		TraceIn("var_declaration", 12);
		AstParserRuleReturnScope<object, IToken> retval = new AstParserRuleReturnScope<object, IToken>();
		retval.Start = (IToken)input.LT(1);

		object root_0 = default(object);

		IToken ID37 = default(IToken);
		IToken char_literal39 = default(IToken);
		IToken ID40 = default(IToken);
		AstParserRuleReturnScope<object, IToken> type36 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> assign38 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> assign41 = default(AstParserRuleReturnScope<object, IToken>);

		object ID37_tree = default(object);
		object char_literal39_tree = default(object);
		object ID40_tree = default(object);
		RewriteRuleITokenStream stream_57=new RewriteRuleITokenStream(adaptor,"token 57");
		RewriteRuleITokenStream stream_ID=new RewriteRuleITokenStream(adaptor,"token ID");
		RewriteRuleSubtreeStream stream_type=new RewriteRuleSubtreeStream(adaptor,"rule type");
		RewriteRuleSubtreeStream stream_assign=new RewriteRuleSubtreeStream(adaptor,"rule assign");
		try { DebugEnterRule(GrammarFileName, "var_declaration");
		DebugLocation(162, 1);
		try
		{
			// c.g:163:2: ( type ( ID | assign ) ( ',' ( ID | assign ) )* -> ^( VAR_DEC ^( VAR_TYPE type ) ^( DEC_NOT_INITED ( ID )* ) ^( DEC_INITED ( assign )* ) ) )
			DebugEnterAlt(1);
			// c.g:163:4: type ( ID | assign ) ( ',' ( ID | assign ) )*
			{
			DebugLocation(163, 4);
			PushFollow(Follow._type_in_var_declaration901);
			type36=type();
			PopFollow();

			stream_type.Add(type36.Tree);
			DebugLocation(163, 9);
			// c.g:163:9: ( ID | assign )
			int alt10=2;
			try { DebugEnterSubRule(10);
			try { DebugEnterDecision(10, false);
			int LA10_1 = input.LA(1);

			if ((LA10_1==ID))
			{
				int LA10_2 = input.LA(2);

				if ((LA10_2==ASSIGN))
				{
					alt10 = 2;
				}
				else if (((LA10_2>=56 && LA10_2<=58)))
				{
					alt10 = 1;
				}
				else
				{
					NoViableAltException nvae = new NoViableAltException("", 10, 1, input, 2);
					DebugRecognitionException(nvae);
					throw nvae;
				}
			}
			else
			{
				NoViableAltException nvae = new NoViableAltException("", 10, 0, input, 1);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(10); }
			switch (alt10)
			{
			case 1:
				DebugEnterAlt(1);
				// c.g:163:11: ID
				{
				DebugLocation(163, 11);
				ID37=(IToken)Match(input,ID,Follow._ID_in_var_declaration905);  
				stream_ID.Add(ID37);


				}
				break;
			case 2:
				DebugEnterAlt(2);
				// c.g:163:16: assign
				{
				DebugLocation(163, 16);
				PushFollow(Follow._assign_in_var_declaration909);
				assign38=assign();
				PopFollow();

				stream_assign.Add(assign38.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(10); }

			DebugLocation(163, 25);
			// c.g:163:25: ( ',' ( ID | assign ) )*
			try { DebugEnterSubRule(12);
			while (true)
			{
				int alt12=2;
				try { DebugEnterDecision(12, false);
				int LA12_1 = input.LA(1);

				if ((LA12_1==57))
				{
					alt12 = 1;
				}


				} finally { DebugExitDecision(12); }
				switch ( alt12 )
				{
				case 1:
					DebugEnterAlt(1);
					// c.g:163:27: ',' ( ID | assign )
					{
					DebugLocation(163, 27);
					char_literal39=(IToken)Match(input,57,Follow._57_in_var_declaration915);  
					stream_57.Add(char_literal39);

					DebugLocation(163, 31);
					// c.g:163:31: ( ID | assign )
					int alt11=2;
					try { DebugEnterSubRule(11);
					try { DebugEnterDecision(11, false);
					int LA11_1 = input.LA(1);

					if ((LA11_1==ID))
					{
						int LA11_2 = input.LA(2);

						if ((LA11_2==ASSIGN))
						{
							alt11 = 2;
						}
						else if (((LA11_2>=56 && LA11_2<=58)))
						{
							alt11 = 1;
						}
						else
						{
							NoViableAltException nvae = new NoViableAltException("", 11, 1, input, 2);
							DebugRecognitionException(nvae);
							throw nvae;
						}
					}
					else
					{
						NoViableAltException nvae = new NoViableAltException("", 11, 0, input, 1);
						DebugRecognitionException(nvae);
						throw nvae;
					}
					} finally { DebugExitDecision(11); }
					switch (alt11)
					{
					case 1:
						DebugEnterAlt(1);
						// c.g:163:33: ID
						{
						DebugLocation(163, 33);
						ID40=(IToken)Match(input,ID,Follow._ID_in_var_declaration919);  
						stream_ID.Add(ID40);


						}
						break;
					case 2:
						DebugEnterAlt(2);
						// c.g:163:38: assign
						{
						DebugLocation(163, 38);
						PushFollow(Follow._assign_in_var_declaration923);
						assign41=assign();
						PopFollow();

						stream_assign.Add(assign41.Tree);

						}
						break;

					}
					} finally { DebugExitSubRule(11); }


					}
					break;

				default:
					goto loop12;
				}
			}

			loop12:
				;

			} finally { DebugExitSubRule(12); }



			{
			// AST REWRITE
			// elements: assign, type, ID
			// 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.Nil();
			// 163:50: -> ^( VAR_DEC ^( VAR_TYPE type ) ^( DEC_NOT_INITED ( ID )* ) ^( DEC_INITED ( assign )* ) )
			{
				DebugLocation(163, 53);
				// c.g:163:53: ^( VAR_DEC ^( VAR_TYPE type ) ^( DEC_NOT_INITED ( ID )* ) ^( DEC_INITED ( assign )* ) )
				{
				object root_1 = (object)adaptor.Nil();
				DebugLocation(163, 55);
				root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(VAR_DEC, "VAR_DEC"), root_1);

				DebugLocation(163, 63);
				// c.g:163:63: ^( VAR_TYPE type )
				{
				object root_2 = (object)adaptor.Nil();
				DebugLocation(163, 66);
				root_2 = (object)adaptor.BecomeRoot((object)adaptor.Create(VAR_TYPE, "VAR_TYPE"), root_2);

				DebugLocation(163, 75);
				adaptor.AddChild(root_2, stream_type.NextTree());

				adaptor.AddChild(root_1, root_2);
				}
				DebugLocation(163, 82);
				// c.g:163:82: ^( DEC_NOT_INITED ( ID )* )
				{
				object root_2 = (object)adaptor.Nil();
				DebugLocation(163, 85);
				root_2 = (object)adaptor.BecomeRoot((object)adaptor.Create(DEC_NOT_INITED, "DEC_NOT_INITED"), root_2);

				DebugLocation(163, 100);
				// c.g:163:100: ( ID )*
				while ( stream_ID.HasNext )
				{
					DebugLocation(163, 100);
					adaptor.AddChild(root_2, stream_ID.NextNode());

				}
				stream_ID.Reset();

				adaptor.AddChild(root_1, root_2);
				}
				DebugLocation(163, 106);
				// c.g:163:106: ^( DEC_INITED ( assign )* )
				{
				object root_2 = (object)adaptor.Nil();
				DebugLocation(163, 109);
				root_2 = (object)adaptor.BecomeRoot((object)adaptor.Create(DEC_INITED, "DEC_INITED"), root_2);

				DebugLocation(163, 120);
				// c.g:163:120: ( assign )*
				while ( stream_assign.HasNext )
				{
					DebugLocation(163, 120);
					adaptor.AddChild(root_2, stream_assign.NextTree());

				}
				stream_assign.Reset();

				adaptor.AddChild(root_1, root_2);
				}

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (object)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
			retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("var_declaration", 12);
			LeaveRule("var_declaration", 12);
			LeaveRule_var_declaration();
		}
		DebugLocation(164, 1);
		} finally { DebugExitRule(GrammarFileName, "var_declaration"); }
		return retval;

	}
コード例 #24
0
	private AstParserRuleReturnScope<CommonTree, IToken> import_def()
	{
		EnterRule_import_def();
		EnterRule("import_def", 11);
		TraceIn("import_def", 11);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken string_literal89 = default(IToken);
		IToken WS90 = default(IToken);
		IToken STRING91 = default(IToken);
		IToken WS92 = default(IToken);
		IToken NEWLINE93 = default(IToken);
		IToken INDENT94 = default(IToken);
		IToken NEWLINE95 = default(IToken);
		IToken STRING96 = default(IToken);
		IToken WS97 = default(IToken);
		IToken NEWLINE98 = default(IToken);
		IToken DEDENT99 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> attribute88 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal89_tree = default(CommonTree);
		CommonTree WS90_tree = default(CommonTree);
		CommonTree STRING91_tree = default(CommonTree);
		CommonTree WS92_tree = default(CommonTree);
		CommonTree NEWLINE93_tree = default(CommonTree);
		CommonTree INDENT94_tree = default(CommonTree);
		CommonTree NEWLINE95_tree = default(CommonTree);
		CommonTree STRING96_tree = default(CommonTree);
		CommonTree WS97_tree = default(CommonTree);
		CommonTree NEWLINE98_tree = default(CommonTree);
		CommonTree DEDENT99_tree = default(CommonTree);
		RewriteRuleITokenStream stream_151=new RewriteRuleITokenStream(adaptor,"token 151");
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_DEDENT=new RewriteRuleITokenStream(adaptor,"token DEDENT");
		RewriteRuleITokenStream stream_NEWLINE=new RewriteRuleITokenStream(adaptor,"token NEWLINE");
		RewriteRuleITokenStream stream_INDENT=new RewriteRuleITokenStream(adaptor,"token INDENT");
		RewriteRuleITokenStream stream_STRING=new RewriteRuleITokenStream(adaptor,"token STRING");
		RewriteRuleSubtreeStream stream_attribute=new RewriteRuleSubtreeStream(adaptor,"rule attribute");
		try { DebugEnterRule(GrammarFileName, "import_def");
		DebugLocation(272, 1);
		try
		{
			// SugarCpp.g:273:2: ( ( attribute )? 'import' ( ( WS )* STRING )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* ( STRING ( WS )* ( NEWLINE )+ )* DEDENT )? -> ^( Import ( attribute )? ( STRING )* ) )
			DebugEnterAlt(1);
			// SugarCpp.g:273:4: ( attribute )? 'import' ( ( WS )* STRING )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* ( STRING ( WS )* ( NEWLINE )+ )* DEDENT )?
			{
			DebugLocation(273, 4);
			// SugarCpp.g:273:4: ( attribute )?
			int alt54=2;
			try { DebugEnterSubRule(54);
			try { DebugEnterDecision(54, false);
			int LA54_0 = input.LA(1);

			if ((LA54_0==132))
			{
				alt54 = 1;
			}
			} finally { DebugExitDecision(54); }
			switch (alt54)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:273:4: attribute
				{
				DebugLocation(273, 4);
				PushFollow(Follow._attribute_in_import_def1278);
				attribute88=attribute();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_attribute.Add(attribute88.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(54); }

			DebugLocation(273, 15);
			string_literal89=(IToken)Match(input,151,Follow._151_in_import_def1281); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_151.Add(string_literal89);

			DebugLocation(273, 24);
			// SugarCpp.g:273:24: ( ( WS )* STRING )?
			int alt56=2;
			try { DebugEnterSubRule(56);
			try { DebugEnterDecision(56, false);
			try
			{
				alt56 = dfa56.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(56); }
			switch (alt56)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:273:25: ( WS )* STRING
				{
				DebugLocation(273, 25);
				// SugarCpp.g:273:25: ( WS )*
				try { DebugEnterSubRule(55);
				while (true)
				{
					int alt55=2;
					try { DebugEnterDecision(55, false);
					int LA55_0 = input.LA(1);

					if ((LA55_0==WS))
					{
						alt55 = 1;
					}


					} finally { DebugExitDecision(55); }
					switch ( alt55 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:273:25: WS
						{
						DebugLocation(273, 25);
						WS90=(IToken)Match(input,WS,Follow._WS_in_import_def1284); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS90);


						}
						break;

					default:
						goto loop55;
					}
				}

				loop55:
					;

				} finally { DebugExitSubRule(55); }

				DebugLocation(273, 29);
				STRING91=(IToken)Match(input,STRING,Follow._STRING_in_import_def1287); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_STRING.Add(STRING91);


				}
				break;

			}
			} finally { DebugExitSubRule(56); }

			DebugLocation(273, 38);
			// SugarCpp.g:273:38: ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* ( STRING ( WS )* ( NEWLINE )+ )* DEDENT )?
			int alt63=2;
			try { DebugEnterSubRule(63);
			try { DebugEnterDecision(63, false);
			try
			{
				alt63 = dfa63.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(63); }
			switch (alt63)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:273:39: ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* ( STRING ( WS )* ( NEWLINE )+ )* DEDENT
				{
				DebugLocation(273, 39);
				// SugarCpp.g:273:39: ( WS )*
				try { DebugEnterSubRule(57);
				while (true)
				{
					int alt57=2;
					try { DebugEnterDecision(57, false);
					int LA57_0 = input.LA(1);

					if ((LA57_0==WS))
					{
						alt57 = 1;
					}


					} finally { DebugExitDecision(57); }
					switch ( alt57 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:273:39: WS
						{
						DebugLocation(273, 39);
						WS92=(IToken)Match(input,WS,Follow._WS_in_import_def1292); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS92);


						}
						break;

					default:
						goto loop57;
					}
				}

				loop57:
					;

				} finally { DebugExitSubRule(57); }

				DebugLocation(273, 43);
				// SugarCpp.g:273:43: ( NEWLINE )+
				int cnt58=0;
				try { DebugEnterSubRule(58);
				while (true)
				{
					int alt58=2;
					try { DebugEnterDecision(58, false);
					int LA58_0 = input.LA(1);

					if ((LA58_0==NEWLINE))
					{
						alt58 = 1;
					}


					} finally { DebugExitDecision(58); }
					switch (alt58)
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:273:43: NEWLINE
						{
						DebugLocation(273, 43);
						NEWLINE93=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_import_def1295); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE93);


						}
						break;

					default:
						if (cnt58 >= 1)
							goto loop58;

						if (state.backtracking>0) {state.failed=true; return retval;}
						EarlyExitException eee58 = new EarlyExitException( 58, input );
						DebugRecognitionException(eee58);
						throw eee58;
					}
					cnt58++;
				}
				loop58:
					;

				} finally { DebugExitSubRule(58); }

				DebugLocation(273, 52);
				INDENT94=(IToken)Match(input,INDENT,Follow._INDENT_in_import_def1298); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_INDENT.Add(INDENT94);

				DebugLocation(273, 59);
				// SugarCpp.g:273:59: ( NEWLINE )*
				try { DebugEnterSubRule(59);
				while (true)
				{
					int alt59=2;
					try { DebugEnterDecision(59, false);
					int LA59_0 = input.LA(1);

					if ((LA59_0==NEWLINE))
					{
						alt59 = 1;
					}


					} finally { DebugExitDecision(59); }
					switch ( alt59 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:273:59: NEWLINE
						{
						DebugLocation(273, 59);
						NEWLINE95=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_import_def1300); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE95);


						}
						break;

					default:
						goto loop59;
					}
				}

				loop59:
					;

				} finally { DebugExitSubRule(59); }

				DebugLocation(273, 68);
				// SugarCpp.g:273:68: ( STRING ( WS )* ( NEWLINE )+ )*
				try { DebugEnterSubRule(62);
				while (true)
				{
					int alt62=2;
					try { DebugEnterDecision(62, false);
					int LA62_0 = input.LA(1);

					if ((LA62_0==STRING))
					{
						alt62 = 1;
					}


					} finally { DebugExitDecision(62); }
					switch ( alt62 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:273:69: STRING ( WS )* ( NEWLINE )+
						{
						DebugLocation(273, 69);
						STRING96=(IToken)Match(input,STRING,Follow._STRING_in_import_def1304); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_STRING.Add(STRING96);

						DebugLocation(273, 76);
						// SugarCpp.g:273:76: ( WS )*
						try { DebugEnterSubRule(60);
						while (true)
						{
							int alt60=2;
							try { DebugEnterDecision(60, false);
							int LA60_0 = input.LA(1);

							if ((LA60_0==WS))
							{
								alt60 = 1;
							}


							} finally { DebugExitDecision(60); }
							switch ( alt60 )
							{
							case 1:
								DebugEnterAlt(1);
								// SugarCpp.g:273:76: WS
								{
								DebugLocation(273, 76);
								WS97=(IToken)Match(input,WS,Follow._WS_in_import_def1306); if (state.failed) return retval; 
								if (state.backtracking == 0) stream_WS.Add(WS97);


								}
								break;

							default:
								goto loop60;
							}
						}

						loop60:
							;

						} finally { DebugExitSubRule(60); }

						DebugLocation(273, 80);
						// SugarCpp.g:273:80: ( NEWLINE )+
						int cnt61=0;
						try { DebugEnterSubRule(61);
						while (true)
						{
							int alt61=2;
							try { DebugEnterDecision(61, false);
							int LA61_0 = input.LA(1);

							if ((LA61_0==NEWLINE))
							{
								alt61 = 1;
							}


							} finally { DebugExitDecision(61); }
							switch (alt61)
							{
							case 1:
								DebugEnterAlt(1);
								// SugarCpp.g:273:80: NEWLINE
								{
								DebugLocation(273, 80);
								NEWLINE98=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_import_def1309); if (state.failed) return retval; 
								if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE98);


								}
								break;

							default:
								if (cnt61 >= 1)
									goto loop61;

								if (state.backtracking>0) {state.failed=true; return retval;}
								EarlyExitException eee61 = new EarlyExitException( 61, input );
								DebugRecognitionException(eee61);
								throw eee61;
							}
							cnt61++;
						}
						loop61:
							;

						} finally { DebugExitSubRule(61); }


						}
						break;

					default:
						goto loop62;
					}
				}

				loop62:
					;

				} finally { DebugExitSubRule(62); }

				DebugLocation(273, 91);
				DEDENT99=(IToken)Match(input,DEDENT,Follow._DEDENT_in_import_def1314); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_DEDENT.Add(DEDENT99);


				}
				break;

			}
			} finally { DebugExitSubRule(63); }



			{
			// AST REWRITE
			// elements: STRING, attribute
			// 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 = (CommonTree)adaptor.Nil();
			// 273:100: -> ^( Import ( attribute )? ( STRING )* )
			{
				DebugLocation(273, 103);
				// SugarCpp.g:273:103: ^( Import ( attribute )? ( STRING )* )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(273, 105);
				root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Import, "Import"), root_1);

				DebugLocation(273, 112);
				// SugarCpp.g:273:112: ( attribute )?
				if (stream_attribute.HasNext)
				{
					DebugLocation(273, 112);
					adaptor.AddChild(root_1, stream_attribute.NextTree());

				}
				stream_attribute.Reset();
				DebugLocation(273, 123);
				// SugarCpp.g:273:123: ( STRING )*
				while ( stream_STRING.HasNext )
				{
					DebugLocation(273, 123);
					adaptor.AddChild(root_1, stream_STRING.NextNode());

				}
				stream_STRING.Reset();

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			if (state.backtracking == 0) {
			retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("import_def", 11);
			LeaveRule("import_def", 11);
			LeaveRule_import_def();
		}
		DebugLocation(274, 1);
		} finally { DebugExitRule(GrammarFileName, "import_def"); }
		return retval;

	}
コード例 #25
0
ファイル: cParser.cs プロジェクト: greenflame/vsu_compiler
	private AstParserRuleReturnScope<object, IToken> func_declaration()
	{
		EnterRule_func_declaration();
		EnterRule("func_declaration", 17);
		TraceIn("func_declaration", 17);
		AstParserRuleReturnScope<object, IToken> retval = new AstParserRuleReturnScope<object, IToken>();
		retval.Start = (IToken)input.LT(1);

		object root_0 = default(object);

		IToken ID77 = default(IToken);
		IToken char_literal78 = default(IToken);
		IToken ID80 = default(IToken);
		IToken char_literal81 = default(IToken);
		IToken ID83 = default(IToken);
		IToken char_literal84 = default(IToken);
		IToken char_literal85 = default(IToken);
		IToken char_literal87 = default(IToken);
		AstParserRuleReturnScope<object, IToken> type76 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> type79 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> type82 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> complex_expr86 = default(AstParserRuleReturnScope<object, IToken>);

		object ID77_tree = default(object);
		object char_literal78_tree = default(object);
		object ID80_tree = default(object);
		object char_literal81_tree = default(object);
		object ID83_tree = default(object);
		object char_literal84_tree = default(object);
		object char_literal85_tree = default(object);
		object char_literal87_tree = default(object);
		RewriteRuleITokenStream stream_55=new RewriteRuleITokenStream(adaptor,"token 55");
		RewriteRuleITokenStream stream_56=new RewriteRuleITokenStream(adaptor,"token 56");
		RewriteRuleITokenStream stream_57=new RewriteRuleITokenStream(adaptor,"token 57");
		RewriteRuleITokenStream stream_59=new RewriteRuleITokenStream(adaptor,"token 59");
		RewriteRuleITokenStream stream_60=new RewriteRuleITokenStream(adaptor,"token 60");
		RewriteRuleITokenStream stream_ID=new RewriteRuleITokenStream(adaptor,"token ID");
		RewriteRuleSubtreeStream stream_complex_expr=new RewriteRuleSubtreeStream(adaptor,"rule complex_expr");
		RewriteRuleSubtreeStream stream_type=new RewriteRuleSubtreeStream(adaptor,"rule type");
		try { DebugEnterRule(GrammarFileName, "func_declaration");
		DebugLocation(192, 1);
		try
		{
			// c.g:193:2: ( type ID '(' ( type ID ( ',' type ID )* )? ')' '{' ( complex_expr )* '}' -> ^( FUNC_DEC ^( FUNC_TYPE type ) ^( FUNC_ID ID ) ^( DEC_PARAMS ( ^( DEC_PARAM type ID ) )* ) ^( FUNC_BODY ( complex_expr )* ) ) )
			DebugEnterAlt(1);
			// c.g:193:4: type ID '(' ( type ID ( ',' type ID )* )? ')' '{' ( complex_expr )* '}'
			{
			DebugLocation(193, 4);
			PushFollow(Follow._type_in_func_declaration1214);
			type76=type();
			PopFollow();

			stream_type.Add(type76.Tree);
			DebugLocation(193, 9);
			ID77=(IToken)Match(input,ID,Follow._ID_in_func_declaration1216);  
			stream_ID.Add(ID77);

			DebugLocation(193, 12);
			char_literal78=(IToken)Match(input,55,Follow._55_in_func_declaration1218);  
			stream_55.Add(char_literal78);

			DebugLocation(193, 16);
			// c.g:193:16: ( type ID ( ',' type ID )* )?
			int alt19=2;
			try { DebugEnterSubRule(19);
			try { DebugEnterDecision(19, false);
			int LA19_1 = input.LA(1);

			if ((LA19_1==BOOL_TYPE||LA19_1==INT_TYPE||LA19_1==STRING_TYPE||LA19_1==VOID_TYPE))
			{
				alt19 = 1;
			}
			} finally { DebugExitDecision(19); }
			switch (alt19)
			{
			case 1:
				DebugEnterAlt(1);
				// c.g:193:18: type ID ( ',' type ID )*
				{
				DebugLocation(193, 18);
				PushFollow(Follow._type_in_func_declaration1222);
				type79=type();
				PopFollow();

				stream_type.Add(type79.Tree);
				DebugLocation(193, 23);
				ID80=(IToken)Match(input,ID,Follow._ID_in_func_declaration1224);  
				stream_ID.Add(ID80);

				DebugLocation(193, 26);
				// c.g:193:26: ( ',' type ID )*
				try { DebugEnterSubRule(18);
				while (true)
				{
					int alt18=2;
					try { DebugEnterDecision(18, false);
					int LA18_1 = input.LA(1);

					if ((LA18_1==57))
					{
						alt18 = 1;
					}


					} finally { DebugExitDecision(18); }
					switch ( alt18 )
					{
					case 1:
						DebugEnterAlt(1);
						// c.g:193:28: ',' type ID
						{
						DebugLocation(193, 28);
						char_literal81=(IToken)Match(input,57,Follow._57_in_func_declaration1228);  
						stream_57.Add(char_literal81);

						DebugLocation(193, 32);
						PushFollow(Follow._type_in_func_declaration1230);
						type82=type();
						PopFollow();

						stream_type.Add(type82.Tree);
						DebugLocation(193, 37);
						ID83=(IToken)Match(input,ID,Follow._ID_in_func_declaration1232);  
						stream_ID.Add(ID83);


						}
						break;

					default:
						goto loop18;
					}
				}

				loop18:
					;

				} finally { DebugExitSubRule(18); }


				}
				break;

			}
			} finally { DebugExitSubRule(19); }

			DebugLocation(193, 47);
			char_literal84=(IToken)Match(input,56,Follow._56_in_func_declaration1241);  
			stream_56.Add(char_literal84);

			DebugLocation(193, 51);
			char_literal85=(IToken)Match(input,59,Follow._59_in_func_declaration1243);  
			stream_59.Add(char_literal85);

			DebugLocation(193, 55);
			// c.g:193:55: ( complex_expr )*
			try { DebugEnterSubRule(20);
			while (true)
			{
				int alt20=2;
				try { DebugEnterDecision(20, false);
				int LA20_1 = input.LA(1);

				if ((LA20_1==BOOL_TYPE||LA20_1==FOR||(LA20_1>=ID && LA20_1<=IF)||LA20_1==INT_TYPE||(LA20_1>=READ && LA20_1<=RETURN)||LA20_1==STRING_TYPE||(LA20_1>=VOID_TYPE && LA20_1<=WRITE)||LA20_1==59))
				{
					alt20 = 1;
				}


				} finally { DebugExitDecision(20); }
				switch ( alt20 )
				{
				case 1:
					DebugEnterAlt(1);
					// c.g:193:55: complex_expr
					{
					DebugLocation(193, 55);
					PushFollow(Follow._complex_expr_in_func_declaration1245);
					complex_expr86=complex_expr();
					PopFollow();

					stream_complex_expr.Add(complex_expr86.Tree);

					}
					break;

				default:
					goto loop20;
				}
			}

			loop20:
				;

			} finally { DebugExitSubRule(20); }

			DebugLocation(193, 69);
			char_literal87=(IToken)Match(input,60,Follow._60_in_func_declaration1248);  
			stream_60.Add(char_literal87);



			{
			// AST REWRITE
			// elements: ID, ID, type, complex_expr, type
			// 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.Nil();
			// 193:73: -> ^( FUNC_DEC ^( FUNC_TYPE type ) ^( FUNC_ID ID ) ^( DEC_PARAMS ( ^( DEC_PARAM type ID ) )* ) ^( FUNC_BODY ( complex_expr )* ) )
			{
				DebugLocation(194, 3);
				// c.g:194:3: ^( FUNC_DEC ^( FUNC_TYPE type ) ^( FUNC_ID ID ) ^( DEC_PARAMS ( ^( DEC_PARAM type ID ) )* ) ^( FUNC_BODY ( complex_expr )* ) )
				{
				object root_1 = (object)adaptor.Nil();
				DebugLocation(194, 5);
				root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(FUNC_DEC, "FUNC_DEC"), root_1);

				DebugLocation(194, 14);
				// c.g:194:14: ^( FUNC_TYPE type )
				{
				object root_2 = (object)adaptor.Nil();
				DebugLocation(194, 17);
				root_2 = (object)adaptor.BecomeRoot((object)adaptor.Create(FUNC_TYPE, "FUNC_TYPE"), root_2);

				DebugLocation(194, 27);
				adaptor.AddChild(root_2, stream_type.NextTree());

				adaptor.AddChild(root_1, root_2);
				}
				DebugLocation(194, 34);
				// c.g:194:34: ^( FUNC_ID ID )
				{
				object root_2 = (object)adaptor.Nil();
				DebugLocation(194, 37);
				root_2 = (object)adaptor.BecomeRoot((object)adaptor.Create(FUNC_ID, "FUNC_ID"), root_2);

				DebugLocation(194, 45);
				adaptor.AddChild(root_2, stream_ID.NextNode());

				adaptor.AddChild(root_1, root_2);
				}
				DebugLocation(194, 50);
				// c.g:194:50: ^( DEC_PARAMS ( ^( DEC_PARAM type ID ) )* )
				{
				object root_2 = (object)adaptor.Nil();
				DebugLocation(194, 52);
				root_2 = (object)adaptor.BecomeRoot((object)adaptor.Create(DEC_PARAMS, "DEC_PARAMS"), root_2);

				DebugLocation(194, 63);
				// c.g:194:63: ( ^( DEC_PARAM type ID ) )*
				while ( stream_ID.HasNext||stream_type.HasNext )
				{
					DebugLocation(194, 63);
					// c.g:194:63: ^( DEC_PARAM type ID )
					{
					object root_3 = (object)adaptor.Nil();
					DebugLocation(194, 66);
					root_3 = (object)adaptor.BecomeRoot((object)adaptor.Create(DEC_PARAM, "DEC_PARAM"), root_3);

					DebugLocation(194, 76);
					adaptor.AddChild(root_3, stream_type.NextTree());
					DebugLocation(194, 81);
					adaptor.AddChild(root_3, stream_ID.NextNode());

					adaptor.AddChild(root_2, root_3);
					}

				}
				stream_ID.Reset();
				stream_type.Reset();

				adaptor.AddChild(root_1, root_2);
				}
				DebugLocation(194, 89);
				// c.g:194:89: ^( FUNC_BODY ( complex_expr )* )
				{
				object root_2 = (object)adaptor.Nil();
				DebugLocation(194, 92);
				root_2 = (object)adaptor.BecomeRoot((object)adaptor.Create(FUNC_BODY, "FUNC_BODY"), root_2);

				DebugLocation(194, 102);
				// c.g:194:102: ( complex_expr )*
				while ( stream_complex_expr.HasNext )
				{
					DebugLocation(194, 102);
					adaptor.AddChild(root_2, stream_complex_expr.NextTree());

				}
				stream_complex_expr.Reset();

				adaptor.AddChild(root_1, root_2);
				}

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (object)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
			retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("func_declaration", 17);
			LeaveRule("func_declaration", 17);
			LeaveRule_func_declaration();
		}
		DebugLocation(195, 1);
		} finally { DebugExitRule(GrammarFileName, "func_declaration"); }
		return retval;

	}
コード例 #26
0
	private AstParserRuleReturnScope<CommonTree, IToken> type_star()
	{
		EnterRule_type_star();
		EnterRule("type_star", 20);
		TraceIn("type_star", 20);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken WS218 = default(IToken);
		IToken char_literal219 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> type_template_type217 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree WS218_tree = default(CommonTree);
		CommonTree char_literal219_tree = default(CommonTree);
		RewriteRuleITokenStream stream_95=new RewriteRuleITokenStream(adaptor,"token 95");
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleSubtreeStream stream_type_template_type=new RewriteRuleSubtreeStream(adaptor,"rule type_template_type");
		try { DebugEnterRule(GrammarFileName, "type_star");
		DebugLocation(322, 1);
		try
		{
			// SugarCpp.g:323:2: ( type_template_type ( ( ( WS )* '*' )+ -> ^( Type_Star type_template_type ( '*' )+ ) | -> type_template_type ) )
			DebugEnterAlt(1);
			// SugarCpp.g:323:4: type_template_type ( ( ( WS )* '*' )+ -> ^( Type_Star type_template_type ( '*' )+ ) | -> type_template_type )
			{
			DebugLocation(323, 4);
			PushFollow(Follow._type_template_type_in_type_star2081);
			type_template_type217=type_template_type();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_type_template_type.Add(type_template_type217.Tree);
			DebugLocation(323, 23);
			// SugarCpp.g:323:23: ( ( ( WS )* '*' )+ -> ^( Type_Star type_template_type ( '*' )+ ) | -> type_template_type )
			int alt145=2;
			try { DebugEnterSubRule(145);
			try { DebugEnterDecision(145, false);
			try
			{
				alt145 = dfa145.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(145); }
			switch (alt145)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:323:25: ( ( WS )* '*' )+
				{
				DebugLocation(323, 25);
				// SugarCpp.g:323:25: ( ( WS )* '*' )+
				int cnt144=0;
				try { DebugEnterSubRule(144);
				while (true)
				{
					int alt144=2;
					try { DebugEnterDecision(144, false);
					try
					{
						alt144 = dfa144.Predict(input);
					}
					catch (NoViableAltException nvae)
					{
						DebugRecognitionException(nvae);
						throw;
					}
					} finally { DebugExitDecision(144); }
					switch (alt144)
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:323:26: ( WS )* '*'
						{
						DebugLocation(323, 26);
						// SugarCpp.g:323:26: ( WS )*
						try { DebugEnterSubRule(143);
						while (true)
						{
							int alt143=2;
							try { DebugEnterDecision(143, false);
							int LA143_0 = input.LA(1);

							if ((LA143_0==WS))
							{
								alt143 = 1;
							}


							} finally { DebugExitDecision(143); }
							switch ( alt143 )
							{
							case 1:
								DebugEnterAlt(1);
								// SugarCpp.g:323:26: WS
								{
								DebugLocation(323, 26);
								WS218=(IToken)Match(input,WS,Follow._WS_in_type_star2086); if (state.failed) return retval; 
								if (state.backtracking == 0) stream_WS.Add(WS218);


								}
								break;

							default:
								goto loop143;
							}
						}

						loop143:
							;

						} finally { DebugExitSubRule(143); }

						DebugLocation(323, 30);
						char_literal219=(IToken)Match(input,95,Follow._95_in_type_star2089); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_95.Add(char_literal219);


						}
						break;

					default:
						if (cnt144 >= 1)
							goto loop144;

						if (state.backtracking>0) {state.failed=true; return retval;}
						EarlyExitException eee144 = new EarlyExitException( 144, input );
						DebugRecognitionException(eee144);
						throw eee144;
					}
					cnt144++;
				}
				loop144:
					;

				} finally { DebugExitSubRule(144); }



				{
				// AST REWRITE
				// elements: type_template_type, 95
				// 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 = (CommonTree)adaptor.Nil();
				// 323:36: -> ^( Type_Star type_template_type ( '*' )+ )
				{
					DebugLocation(323, 39);
					// SugarCpp.g:323:39: ^( Type_Star type_template_type ( '*' )+ )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(323, 41);
					root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Type_Star, "Type_Star"), root_1);

					DebugLocation(323, 51);
					adaptor.AddChild(root_1, stream_type_template_type.NextTree());
					DebugLocation(323, 70);
					if (!(stream_95.HasNext))
					{
						throw new RewriteEarlyExitException();
					}
					while ( stream_95.HasNext )
					{
						DebugLocation(323, 70);
						adaptor.AddChild(root_1, stream_95.NextNode());

					}
					stream_95.Reset();

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarCpp.g:324:10: 
				{

				{
				// AST REWRITE
				// elements: type_template_type
				// 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 = (CommonTree)adaptor.Nil();
				// 324:10: -> type_template_type
				{
					DebugLocation(324, 13);
					adaptor.AddChild(root_0, stream_type_template_type.NextTree());

				}

				retval.Tree = root_0;
				}
				}

				}
				break;

			}
			} finally { DebugExitSubRule(145); }


			}

			retval.Stop = (IToken)input.LT(-1);

			if (state.backtracking == 0) {
			retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("type_star", 20);
			LeaveRule("type_star", 20);
			LeaveRule_type_star();
		}
		DebugLocation(326, 1);
		} finally { DebugExitRule(GrammarFileName, "type_star"); }
		return retval;

	}
コード例 #27
0
	private AstParserRuleReturnScope<object, IToken> continueStatement()
	{
		EnterRule_continueStatement();
		EnterRule("continueStatement", 22);
		TraceIn("continueStatement", 22);
		AstParserRuleReturnScope<object, IToken> retval = new AstParserRuleReturnScope<object, IToken>();
		retval.Start = (IToken)input.LT(1);
		int continueStatement_StartIndex = input.Index;

		object root_0 = default(object);

		IToken string_literal144 = default(IToken);
		IToken Identifier145 = default(IToken);
		IToken LT146 = default(IToken);
		IToken char_literal147 = default(IToken);

		object string_literal144_tree = default(object);
		object Identifier145_tree = default(object);
		object LT146_tree = default(object);
		object char_literal147_tree = default(object);
		RewriteRuleITokenStream stream_124=new RewriteRuleITokenStream(adaptor,"token 124");
		RewriteRuleITokenStream stream_Identifier=new RewriteRuleITokenStream(adaptor,"token Identifier");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_102=new RewriteRuleITokenStream(adaptor,"token 102");
		try { DebugEnterRule(GrammarFileName, "continueStatement");
		DebugLocation(188, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 22)) { return retval; }

			// JavaScript.g3:189:2: ( 'continue' ( Identifier )? ( LT | ';' ) -> ^( CONTINUE ( ^( IDENTIFIER Identifier ) )? ) )
			DebugEnterAlt(1);
			// JavaScript.g3:189:4: 'continue' ( Identifier )? ( LT | ';' )
			{
			DebugLocation(189, 4);
			string_literal144=(IToken)Match(input,124,Follow._124_in_continueStatement1123); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_124.Add(string_literal144);

			DebugLocation(189, 15);
			// JavaScript.g3:189:15: ( Identifier )?
			int alt67=2;
			try { DebugEnterSubRule(67);
			try { DebugEnterDecision(67, false);
			int LA67_1 = input.LA(1);

			if ((LA67_1==Identifier))
			{
				alt67 = 1;
			}
			} finally { DebugExitDecision(67); }
			switch (alt67)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g3:189:15: Identifier
				{
				DebugLocation(189, 15);
				Identifier145=(IToken)Match(input,Identifier,Follow._Identifier_in_continueStatement1125); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_Identifier.Add(Identifier145);


				}
				break;

			}
			} finally { DebugExitSubRule(67); }

			DebugLocation(189, 27);
			// JavaScript.g3:189:27: ( LT | ';' )
			int alt68=2;
			try { DebugEnterSubRule(68);
			try { DebugEnterDecision(68, false);
			int LA68_1 = input.LA(1);

			if ((LA68_1==LT))
			{
				alt68 = 1;
			}
			else if ((LA68_1==102))
			{
				alt68 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 68, 0, input, 1);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(68); }
			switch (alt68)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g3:189:28: LT
				{
				DebugLocation(189, 28);
				LT146=(IToken)Match(input,LT,Follow._LT_in_continueStatement1129); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_LT.Add(LT146);


				}
				break;
			case 2:
				DebugEnterAlt(2);
				// JavaScript.g3:189:33: ';'
				{
				DebugLocation(189, 33);
				char_literal147=(IToken)Match(input,102,Follow._102_in_continueStatement1133); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_102.Add(char_literal147);


				}
				break;

			}
			} finally { DebugExitSubRule(68); }



			{
			// AST REWRITE
			// elements: Identifier
			// 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.Nil();
			// 189:38: -> ^( CONTINUE ( ^( IDENTIFIER Identifier ) )? )
			{
				DebugLocation(189, 41);
				// JavaScript.g3:189:41: ^( CONTINUE ( ^( IDENTIFIER Identifier ) )? )
				{
				object root_1 = (object)adaptor.Nil();
				DebugLocation(189, 43);
				root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(CONTINUE, "CONTINUE"), root_1);

				DebugLocation(189, 52);
				// JavaScript.g3:189:52: ( ^( IDENTIFIER Identifier ) )?
				if (stream_Identifier.HasNext)
				{
					DebugLocation(189, 52);
					// JavaScript.g3:189:52: ^( IDENTIFIER Identifier )
					{
					object root_2 = (object)adaptor.Nil();
					DebugLocation(189, 54);
					root_2 = (object)adaptor.BecomeRoot((object)adaptor.Create(IDENTIFIER, "IDENTIFIER"), root_2);

					DebugLocation(189, 65);
					adaptor.AddChild(root_2, stream_Identifier.NextNode());

					adaptor.AddChild(root_1, root_2);
					}

				}
				stream_Identifier.Reset();

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			if (state.backtracking == 0) {
			retval.Tree = (object)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("continueStatement", 22);
			LeaveRule("continueStatement", 22);
			LeaveRule_continueStatement();
			if (state.backtracking > 0) { Memoize(input, 22, continueStatement_StartIndex); }

		}
		DebugLocation(190, 1);
		} finally { DebugExitRule(GrammarFileName, "continueStatement"); }
		return retval;

	}
コード例 #28
0
ファイル: AS3Parser.cs プロジェクト: jbakst/xas
	private AstParserRuleReturnScope<CommonTree, IToken> identifierStar()
	{
		EnterRule_identifierStar();
		EnterRule("identifierStar", 77);
		TraceIn("identifierStar", 77);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken DOT249 = default(IToken);
		IToken STAR250 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> ident247 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> dotIdent248 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree DOT249_tree = default(CommonTree);
		CommonTree STAR250_tree = default(CommonTree);
		RewriteRuleITokenStream stream_DOT=new RewriteRuleITokenStream(adaptor,"token DOT");
		RewriteRuleITokenStream stream_STAR=new RewriteRuleITokenStream(adaptor,"token STAR");
		RewriteRuleSubtreeStream stream_ident=new RewriteRuleSubtreeStream(adaptor,"rule ident");
		RewriteRuleSubtreeStream stream_dotIdent=new RewriteRuleSubtreeStream(adaptor,"rule dotIdent");
		try { DebugEnterRule(GrammarFileName, "identifierStar");
		DebugLocation(600, 1);
		try
		{
			// AS3.g:601:2: ( ident ( dotIdent )* ( DOT STAR )? -> ^( IDENTIFIER_STAR ident ( dotIdent )* ( DOT )? ( STAR )? ) )
			DebugEnterAlt(1);
			// AS3.g:601:4: ident ( dotIdent )* ( DOT STAR )?
			{
			DebugLocation(601, 4);
			PushFollow(Follow._ident_in_identifierStar3287);
			ident247=ident();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_ident.Add(ident247.Tree);
			DebugLocation(602, 3);
			// AS3.g:602:3: ( dotIdent )*
			try { DebugEnterSubRule(54);
			while (true)
			{
				int alt54=2;
				try { DebugEnterDecision(54, false);
				int LA54_1 = input.LA(1);

				if ((LA54_1==DOT))
				{
					int LA54_2 = input.LA(2);

					if ((LA54_2==AS||LA54_2==DYNAMIC||LA54_2==GET||LA54_2==IDENT||LA54_2==IS||LA54_2==NAMESPACE||LA54_2==SET||LA54_2==SUPER||LA54_2==USE||LA54_2==XML))
					{
						alt54 = 1;
					}


				}


				} finally { DebugExitDecision(54); }
				switch ( alt54 )
				{
				case 1:
					DebugEnterAlt(1);
					// AS3.g:602:3: dotIdent
					{
					DebugLocation(602, 3);
					PushFollow(Follow._dotIdent_in_identifierStar3291);
					dotIdent248=dotIdent();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_dotIdent.Add(dotIdent248.Tree);

					}
					break;

				default:
					goto loop54;
				}
			}

			loop54:
				;

			} finally { DebugExitSubRule(54); }

			DebugLocation(603, 3);
			// AS3.g:603:3: ( DOT STAR )?
			int alt55=2;
			try { DebugEnterSubRule(55);
			try { DebugEnterDecision(55, false);
			int LA55_1 = input.LA(1);

			if ((LA55_1==DOT))
			{
				alt55 = 1;
			}
			} finally { DebugExitDecision(55); }
			switch (alt55)
			{
			case 1:
				DebugEnterAlt(1);
				// AS3.g:603:4: DOT STAR
				{
				DebugLocation(603, 4);
				DOT249=(IToken)Match(input,DOT,Follow._DOT_in_identifierStar3297); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_DOT.Add(DOT249);

				DebugLocation(603, 8);
				STAR250=(IToken)Match(input,STAR,Follow._STAR_in_identifierStar3299); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_STAR.Add(STAR250);


				}
				break;

			}
			} finally { DebugExitSubRule(55); }



			{
			// AST REWRITE
			// elements: ident, dotIdent, DOT, STAR
			// 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 = (CommonTree)adaptor.Nil();
			// 604:3: -> ^( IDENTIFIER_STAR ident ( dotIdent )* ( DOT )? ( STAR )? )
			{
				DebugLocation(604, 6);
				// AS3.g:604:6: ^( IDENTIFIER_STAR ident ( dotIdent )* ( DOT )? ( STAR )? )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(604, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(IDENTIFIER_STAR, "IDENTIFIER_STAR"), root_1);

				DebugLocation(604, 24);
				adaptor.AddChild(root_1, stream_ident.NextTree());
				DebugLocation(604, 30);
				// AS3.g:604:30: ( dotIdent )*
				while ( stream_dotIdent.HasNext )
				{
					DebugLocation(604, 30);
					adaptor.AddChild(root_1, stream_dotIdent.NextTree());

				}
				stream_dotIdent.Reset();
				DebugLocation(604, 40);
				// AS3.g:604:40: ( DOT )?
				if (stream_DOT.HasNext)
				{
					DebugLocation(604, 40);
					adaptor.AddChild(root_1, stream_DOT.NextNode());

				}
				stream_DOT.Reset();
				DebugLocation(604, 45);
				// AS3.g:604:45: ( STAR )?
				if (stream_STAR.HasNext)
				{
					DebugLocation(604, 45);
					adaptor.AddChild(root_1, stream_STAR.NextNode());

				}
				stream_STAR.Reset();

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			if (state.backtracking == 0) {
			retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("identifierStar", 77);
			LeaveRule("identifierStar", 77);
			LeaveRule_identifierStar();
		}
		DebugLocation(605, 1);
		} finally { DebugExitRule(GrammarFileName, "identifierStar"); }
		return retval;

	}
コード例 #29
0
	private AstParserRuleReturnScope<object, IToken> breakStatement()
	{
		EnterRule_breakStatement();
		EnterRule("breakStatement", 23);
		TraceIn("breakStatement", 23);
		AstParserRuleReturnScope<object, IToken> retval = new AstParserRuleReturnScope<object, IToken>();
		retval.Start = (IToken)input.LT(1);
		int breakStatement_StartIndex = input.Index;

		object root_0 = default(object);

		IToken string_literal148 = default(IToken);
		IToken Identifier149 = default(IToken);
		IToken LT150 = default(IToken);
		IToken char_literal151 = default(IToken);

		object string_literal148_tree = default(object);
		object Identifier149_tree = default(object);
		object LT150_tree = default(object);
		object char_literal151_tree = default(object);
		RewriteRuleITokenStream stream_121=new RewriteRuleITokenStream(adaptor,"token 121");
		RewriteRuleITokenStream stream_Identifier=new RewriteRuleITokenStream(adaptor,"token Identifier");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_102=new RewriteRuleITokenStream(adaptor,"token 102");
		try { DebugEnterRule(GrammarFileName, "breakStatement");
		DebugLocation(192, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 23)) { return retval; }

			// JavaScript.g3:193:2: ( 'break' ( Identifier )? ( LT | ';' ) -> ^( BREAK ( ^( IDENTIFIER Identifier ) )? ) )
			DebugEnterAlt(1);
			// JavaScript.g3:193:4: 'break' ( Identifier )? ( LT | ';' )
			{
			DebugLocation(193, 4);
			string_literal148=(IToken)Match(input,121,Follow._121_in_breakStatement1158); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_121.Add(string_literal148);

			DebugLocation(193, 12);
			// JavaScript.g3:193:12: ( Identifier )?
			int alt69=2;
			try { DebugEnterSubRule(69);
			try { DebugEnterDecision(69, false);
			int LA69_1 = input.LA(1);

			if ((LA69_1==Identifier))
			{
				alt69 = 1;
			}
			} finally { DebugExitDecision(69); }
			switch (alt69)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g3:193:12: Identifier
				{
				DebugLocation(193, 12);
				Identifier149=(IToken)Match(input,Identifier,Follow._Identifier_in_breakStatement1160); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_Identifier.Add(Identifier149);


				}
				break;

			}
			} finally { DebugExitSubRule(69); }

			DebugLocation(193, 24);
			// JavaScript.g3:193:24: ( LT | ';' )
			int alt70=2;
			try { DebugEnterSubRule(70);
			try { DebugEnterDecision(70, false);
			int LA70_1 = input.LA(1);

			if ((LA70_1==LT))
			{
				alt70 = 1;
			}
			else if ((LA70_1==102))
			{
				alt70 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 70, 0, input, 1);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(70); }
			switch (alt70)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g3:193:25: LT
				{
				DebugLocation(193, 25);
				LT150=(IToken)Match(input,LT,Follow._LT_in_breakStatement1164); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_LT.Add(LT150);


				}
				break;
			case 2:
				DebugEnterAlt(2);
				// JavaScript.g3:193:30: ';'
				{
				DebugLocation(193, 30);
				char_literal151=(IToken)Match(input,102,Follow._102_in_breakStatement1168); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_102.Add(char_literal151);


				}
				break;

			}
			} finally { DebugExitSubRule(70); }



			{
			// AST REWRITE
			// elements: Identifier
			// 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.Nil();
			// 193:35: -> ^( BREAK ( ^( IDENTIFIER Identifier ) )? )
			{
				DebugLocation(193, 38);
				// JavaScript.g3:193:38: ^( BREAK ( ^( IDENTIFIER Identifier ) )? )
				{
				object root_1 = (object)adaptor.Nil();
				DebugLocation(193, 40);
				root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(BREAK, "BREAK"), root_1);

				DebugLocation(193, 46);
				// JavaScript.g3:193:46: ( ^( IDENTIFIER Identifier ) )?
				if (stream_Identifier.HasNext)
				{
					DebugLocation(193, 46);
					// JavaScript.g3:193:46: ^( IDENTIFIER Identifier )
					{
					object root_2 = (object)adaptor.Nil();
					DebugLocation(193, 48);
					root_2 = (object)adaptor.BecomeRoot((object)adaptor.Create(IDENTIFIER, "IDENTIFIER"), root_2);

					DebugLocation(193, 59);
					adaptor.AddChild(root_2, stream_Identifier.NextNode());

					adaptor.AddChild(root_1, root_2);
					}

				}
				stream_Identifier.Reset();

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			if (state.backtracking == 0) {
			retval.Tree = (object)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("breakStatement", 23);
			LeaveRule("breakStatement", 23);
			LeaveRule_breakStatement();
			if (state.backtracking > 0) { Memoize(input, 23, breakStatement_StartIndex); }

		}
		DebugLocation(194, 1);
		} finally { DebugExitRule(GrammarFileName, "breakStatement"); }
		return retval;

	}
コード例 #30
0
ファイル: AS3Parser.cs プロジェクト: jbakst/xas
	private AstParserRuleReturnScope<CommonTree, IToken> typeExpression()
	{
		EnterRule_typeExpression();
		EnterRule("typeExpression", 71);
		TraceIn("typeExpression", 71);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken COLON232 = default(IToken);
		IToken string_literal234 = default(IToken);
		IToken STAR235 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> typeIdentifier233 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree COLON232_tree = default(CommonTree);
		CommonTree string_literal234_tree = default(CommonTree);
		CommonTree STAR235_tree = default(CommonTree);
		RewriteRuleITokenStream stream_COLON=new RewriteRuleITokenStream(adaptor,"token COLON");
		RewriteRuleITokenStream stream_257=new RewriteRuleITokenStream(adaptor,"token 257");
		RewriteRuleITokenStream stream_STAR=new RewriteRuleITokenStream(adaptor,"token STAR");
		RewriteRuleSubtreeStream stream_typeIdentifier=new RewriteRuleSubtreeStream(adaptor,"rule typeIdentifier");
		try { DebugEnterRule(GrammarFileName, "typeExpression");
		DebugLocation(567, 4);
		try
		{
			// AS3.g:568:2: ( COLON ( typeIdentifier | 'void' | STAR ) -> ^( TYPE_SPEC COLON ( typeIdentifier )? ( 'void' )? ( STAR )? ) )
			DebugEnterAlt(1);
			// AS3.g:569:3: COLON ( typeIdentifier | 'void' | STAR )
			{
			DebugLocation(569, 3);
			COLON232=(IToken)Match(input,COLON,Follow._COLON_in_typeExpression3075); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_COLON.Add(COLON232);

			DebugLocation(569, 9);
			// AS3.g:569:9: ( typeIdentifier | 'void' | STAR )
			int alt49=3;
			try { DebugEnterSubRule(49);
			try { DebugEnterDecision(49, false);
			switch (input.LA(1))
			{
			case AS:
			case DYNAMIC:
			case GET:
			case IDENT:
			case IS:
			case NAMESPACE:
			case SET:
			case SUPER:
			case USE:
			case XML:
				{
				alt49 = 1;
				}
				break;
			case 257:
				{
				alt49 = 2;
				}
				break;
			case STAR:
				{
				alt49 = 3;
				}
				break;
			default:
				{
					if (state.backtracking>0) {state.failed=true; return retval;}
					NoViableAltException nvae = new NoViableAltException("", 49, 0, input, 1);
					DebugRecognitionException(nvae);
					throw nvae;
				}
			}

			} finally { DebugExitDecision(49); }
			switch (alt49)
			{
			case 1:
				DebugEnterAlt(1);
				// AS3.g:569:10: typeIdentifier
				{
				DebugLocation(569, 10);
				PushFollow(Follow._typeIdentifier_in_typeExpression3078);
				typeIdentifier233=typeIdentifier();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_typeIdentifier.Add(typeIdentifier233.Tree);

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// AS3.g:569:27: 'void'
				{
				DebugLocation(569, 27);
				string_literal234=(IToken)Match(input,257,Follow._257_in_typeExpression3082); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_257.Add(string_literal234);


				}
				break;
			case 3:
				DebugEnterAlt(3);
				// AS3.g:569:36: STAR
				{
				DebugLocation(569, 36);
				STAR235=(IToken)Match(input,STAR,Follow._STAR_in_typeExpression3086); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_STAR.Add(STAR235);


				}
				break;

			}
			} finally { DebugExitSubRule(49); }



			{
			// AST REWRITE
			// elements: COLON, typeIdentifier, 257, STAR
			// 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 = (CommonTree)adaptor.Nil();
			// 570:3: -> ^( TYPE_SPEC COLON ( typeIdentifier )? ( 'void' )? ( STAR )? )
			{
				DebugLocation(570, 6);
				// AS3.g:570:6: ^( TYPE_SPEC COLON ( typeIdentifier )? ( 'void' )? ( STAR )? )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(570, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(TYPE_SPEC, "TYPE_SPEC"), root_1);

				DebugLocation(570, 18);
				adaptor.AddChild(root_1, stream_COLON.NextNode());
				DebugLocation(570, 24);
				// AS3.g:570:24: ( typeIdentifier )?
				if (stream_typeIdentifier.HasNext)
				{
					DebugLocation(570, 24);
					adaptor.AddChild(root_1, stream_typeIdentifier.NextTree());

				}
				stream_typeIdentifier.Reset();
				DebugLocation(570, 40);
				// AS3.g:570:40: ( 'void' )?
				if (stream_257.HasNext)
				{
					DebugLocation(570, 40);
					adaptor.AddChild(root_1, stream_257.NextNode());

				}
				stream_257.Reset();
				DebugLocation(570, 48);
				// AS3.g:570:48: ( STAR )?
				if (stream_STAR.HasNext)
				{
					DebugLocation(570, 48);
					adaptor.AddChild(root_1, stream_STAR.NextNode());

				}
				stream_STAR.Reset();

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			if (state.backtracking == 0) {
			retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("typeExpression", 71);
			LeaveRule("typeExpression", 71);
			LeaveRule_typeExpression();
		}
		DebugLocation(571, 4);
		} finally { DebugExitRule(GrammarFileName, "typeExpression"); }
		return retval;

	}
コード例 #31
0
        private AstParserRuleReturnScope <object, IToken> plain_elem()
        {
            EnterRule_plain_elem();
            EnterRule("plain_elem", 5);
            TraceIn("plain_elem", 5);
            AstParserRuleReturnScope <object, IToken> retval = new AstParserRuleReturnScope <object, IToken>();

            retval.Start = (IToken)input.LT(1);

            object root_0 = default(object);

            IToken i1       = default(IToken);
            IToken i2       = default(IToken);
            IToken al       = default(IToken);
            IToken ID12     = default(IToken);
            IToken FROM13   = default(IToken);
            IToken TO14     = default(IToken);
            IToken ID15     = default(IToken);
            IToken LENGTH16 = default(IToken);

            object i1_tree       = default(object);
            object i2_tree       = default(object);
            object al_tree       = default(object);
            object ID12_tree     = default(object);
            object FROM13_tree   = default(object);
            object TO14_tree     = default(object);
            object ID15_tree     = default(object);
            object LENGTH16_tree = default(object);
            RewriteRuleITokenStream stream_INT         = new RewriteRuleITokenStream(adaptor, "token INT");
            RewriteRuleITokenStream stream_ALIGN_RIGHT = new RewriteRuleITokenStream(adaptor, "token ALIGN_RIGHT");
            RewriteRuleITokenStream stream_ID          = new RewriteRuleITokenStream(adaptor, "token ID");
            RewriteRuleITokenStream stream_FROM        = new RewriteRuleITokenStream(adaptor, "token FROM");
            RewriteRuleITokenStream stream_TO          = new RewriteRuleITokenStream(adaptor, "token TO");
            RewriteRuleITokenStream stream_ALIGN_LEFT  = new RewriteRuleITokenStream(adaptor, "token ALIGN_LEFT");
            RewriteRuleITokenStream stream_LENGTH      = new RewriteRuleITokenStream(adaptor, "token LENGTH");

            try { DebugEnterRule(GrammarFileName, "plain_elem");
                  DebugLocation(47, 2);
                  try
                  {
                      // C:\\Users\\franz\\SkyDrive\\Dokumente\\workspace\\TextTable\\src\\eu\\reitmayer\\texttable\\lang\\TextTable.g:47:11: ( ID FROM i1= INT TO i2= INT (al= ALIGN_LEFT |al= ALIGN_RIGHT )? -> ^( ID $i1 $i2 ( $al)? ) | ID LENGTH i1= INT (al= ALIGN_LEFT |al= ALIGN_RIGHT )? -> ^( ID $i1 ( $al)? ) )
                      int alt5 = 2;
                      try { DebugEnterDecision(5, false);
                            int LA5_0 = input.LA(1);

                            if ((LA5_0 == ID))
                            {
                                int LA5_1 = input.LA(2);

                                if ((LA5_1 == FROM))
                                {
                                    alt5 = 1;
                                }
                                else if ((LA5_1 == LENGTH))
                                {
                                    alt5 = 2;
                                }
                                else
                                {
                                    NoViableAltException nvae = new NoViableAltException("", 5, 1, input);
                                    DebugRecognitionException(nvae);
                                    throw nvae;
                                }
                            }
                            else
                            {
                                NoViableAltException nvae = new NoViableAltException("", 5, 0, input);
                                DebugRecognitionException(nvae);
                                throw nvae;
                            } } finally { DebugExitDecision(5); }
                      switch (alt5)
                      {
                      case 1:
                          DebugEnterAlt(1);
                          // C:\\Users\\franz\\SkyDrive\\Dokumente\\workspace\\TextTable\\src\\eu\\reitmayer\\texttable\\lang\\TextTable.g:48:3: ID FROM i1= INT TO i2= INT (al= ALIGN_LEFT |al= ALIGN_RIGHT )?
                          {
                              DebugLocation(48, 3);
                              ID12 = (IToken)Match(input, ID, Follow._ID_in_plain_elem181);
                              stream_ID.Add(ID12);

                              DebugLocation(48, 6);
                              FROM13 = (IToken)Match(input, FROM, Follow._FROM_in_plain_elem183);
                              stream_FROM.Add(FROM13);

                              DebugLocation(48, 13);
                              i1 = (IToken)Match(input, INT, Follow._INT_in_plain_elem187);
                              stream_INT.Add(i1);

                              DebugLocation(48, 18);
                              TO14 = (IToken)Match(input, TO, Follow._TO_in_plain_elem189);
                              stream_TO.Add(TO14);

                              DebugLocation(48, 23);
                              i2 = (IToken)Match(input, INT, Follow._INT_in_plain_elem193);
                              stream_INT.Add(i2);

                              DebugLocation(48, 28);
                              // C:\\Users\\franz\\SkyDrive\\Dokumente\\workspace\\TextTable\\src\\eu\\reitmayer\\texttable\\lang\\TextTable.g:48:28: (al= ALIGN_LEFT |al= ALIGN_RIGHT )?
                              int alt3 = 3;
                              try { DebugEnterSubRule(3);
                                    try { DebugEnterDecision(3, false);
                                          int LA3_0 = input.LA(1);

                                          if ((LA3_0 == ALIGN_LEFT))
                                          {
                                              alt3 = 1;
                                          }
                                          else if ((LA3_0 == ALIGN_RIGHT))
                                          {
                                              alt3 = 2;
                                          }
                                    } finally { DebugExitDecision(3); }
                                    switch (alt3)
                                    {
                                    case 1:
                                        DebugEnterAlt(1);
                                        // C:\\Users\\franz\\SkyDrive\\Dokumente\\workspace\\TextTable\\src\\eu\\reitmayer\\texttable\\lang\\TextTable.g:48:29: al= ALIGN_LEFT
                                        {
                                            DebugLocation(48, 31);
                                            al = (IToken)Match(input, ALIGN_LEFT, Follow._ALIGN_LEFT_in_plain_elem198);
                                            stream_ALIGN_LEFT.Add(al);
                                        }
                                        break;

                                    case 2:
                                        DebugEnterAlt(2);
                                        // C:\\Users\\franz\\SkyDrive\\Dokumente\\workspace\\TextTable\\src\\eu\\reitmayer\\texttable\\lang\\TextTable.g:48:45: al= ALIGN_RIGHT
                                        {
                                            DebugLocation(48, 47);
                                            al = (IToken)Match(input, ALIGN_RIGHT, Follow._ALIGN_RIGHT_in_plain_elem204);
                                            stream_ALIGN_RIGHT.Add(al);
                                        }
                                        break;
                                    }
                              } finally { DebugExitSubRule(3); }



                              {
                                  // AST REWRITE
                                  // elements: i2, ID, al, i1
                                  // token labels: al, i2, i1
                                  // rule labels: retval
                                  // token list labels:
                                  // rule list labels:
                                  // wildcard labels:
                                  retval.Tree = root_0;
                                  RewriteRuleITokenStream  stream_al     = new RewriteRuleITokenStream(adaptor, "token al", al);
                                  RewriteRuleITokenStream  stream_i2     = new RewriteRuleITokenStream(adaptor, "token i2", i2);
                                  RewriteRuleITokenStream  stream_i1     = new RewriteRuleITokenStream(adaptor, "token i1", i1);
                                  RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null?retval.Tree:null);

                                  root_0 = (object)adaptor.Nil();
                                  // 48:62: -> ^( ID $i1 $i2 ( $al)? )
                                  {
                                      DebugLocation(48, 65);
                                      // C:\\Users\\franz\\SkyDrive\\Dokumente\\workspace\\TextTable\\src\\eu\\reitmayer\\texttable\\lang\\TextTable.g:48:65: ^( ID $i1 $i2 ( $al)? )
                                      {
                                          object root_1 = (object)adaptor.Nil();
                                          DebugLocation(48, 67);
                                          root_1 = (object)adaptor.BecomeRoot(stream_ID.NextNode(), root_1);

                                          DebugLocation(48, 71);
                                          adaptor.AddChild(root_1, stream_i1.NextNode());
                                          DebugLocation(48, 75);
                                          adaptor.AddChild(root_1, stream_i2.NextNode());
                                          DebugLocation(48, 79);
                                          // C:\\Users\\franz\\SkyDrive\\Dokumente\\workspace\\TextTable\\src\\eu\\reitmayer\\texttable\\lang\\TextTable.g:48:79: ( $al)?
                                          if (stream_al.HasNext)
                                          {
                                              DebugLocation(48, 79);
                                              adaptor.AddChild(root_1, stream_al.NextNode());
                                          }
                                          stream_al.Reset();

                                          adaptor.AddChild(root_0, root_1);
                                      }
                                  }

                                  retval.Tree = root_0;
                              }
                          }
                          break;

                      case 2:
                          DebugEnterAlt(2);
                          // C:\\Users\\franz\\SkyDrive\\Dokumente\\workspace\\TextTable\\src\\eu\\reitmayer\\texttable\\lang\\TextTable.g:50:3: ID LENGTH i1= INT (al= ALIGN_LEFT |al= ALIGN_RIGHT )?
                          {
                              DebugLocation(50, 3);
                              ID15 = (IToken)Match(input, ID, Follow._ID_in_plain_elem230);
                              stream_ID.Add(ID15);

                              DebugLocation(50, 6);
                              LENGTH16 = (IToken)Match(input, LENGTH, Follow._LENGTH_in_plain_elem232);
                              stream_LENGTH.Add(LENGTH16);

                              DebugLocation(50, 15);
                              i1 = (IToken)Match(input, INT, Follow._INT_in_plain_elem236);
                              stream_INT.Add(i1);

                              DebugLocation(50, 20);
                              // C:\\Users\\franz\\SkyDrive\\Dokumente\\workspace\\TextTable\\src\\eu\\reitmayer\\texttable\\lang\\TextTable.g:50:20: (al= ALIGN_LEFT |al= ALIGN_RIGHT )?
                              int alt4 = 3;
                              try { DebugEnterSubRule(4);
                                    try { DebugEnterDecision(4, false);
                                          int LA4_0 = input.LA(1);

                                          if ((LA4_0 == ALIGN_LEFT))
                                          {
                                              alt4 = 1;
                                          }
                                          else if ((LA4_0 == ALIGN_RIGHT))
                                          {
                                              alt4 = 2;
                                          }
                                    } finally { DebugExitDecision(4); }
                                    switch (alt4)
                                    {
                                    case 1:
                                        DebugEnterAlt(1);
                                        // C:\\Users\\franz\\SkyDrive\\Dokumente\\workspace\\TextTable\\src\\eu\\reitmayer\\texttable\\lang\\TextTable.g:50:21: al= ALIGN_LEFT
                                        {
                                            DebugLocation(50, 23);
                                            al = (IToken)Match(input, ALIGN_LEFT, Follow._ALIGN_LEFT_in_plain_elem241);
                                            stream_ALIGN_LEFT.Add(al);
                                        }
                                        break;

                                    case 2:
                                        DebugEnterAlt(2);
                                        // C:\\Users\\franz\\SkyDrive\\Dokumente\\workspace\\TextTable\\src\\eu\\reitmayer\\texttable\\lang\\TextTable.g:50:37: al= ALIGN_RIGHT
                                        {
                                            DebugLocation(50, 39);
                                            al = (IToken)Match(input, ALIGN_RIGHT, Follow._ALIGN_RIGHT_in_plain_elem247);
                                            stream_ALIGN_RIGHT.Add(al);
                                        }
                                        break;
                                    }
                              } finally { DebugExitSubRule(4); }



                              {
                                  // AST REWRITE
                                  // elements: i1, al, ID
                                  // token labels: al, i1
                                  // rule labels: retval
                                  // token list labels:
                                  // rule list labels:
                                  // wildcard labels:
                                  retval.Tree = root_0;
                                  RewriteRuleITokenStream  stream_al     = new RewriteRuleITokenStream(adaptor, "token al", al);
                                  RewriteRuleITokenStream  stream_i1     = new RewriteRuleITokenStream(adaptor, "token i1", i1);
                                  RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null?retval.Tree:null);

                                  root_0 = (object)adaptor.Nil();
                                  // 50:54: -> ^( ID $i1 ( $al)? )
                                  {
                                      DebugLocation(50, 57);
                                      // C:\\Users\\franz\\SkyDrive\\Dokumente\\workspace\\TextTable\\src\\eu\\reitmayer\\texttable\\lang\\TextTable.g:50:57: ^( ID $i1 ( $al)? )
                                      {
                                          object root_1 = (object)adaptor.Nil();
                                          DebugLocation(50, 59);
                                          root_1 = (object)adaptor.BecomeRoot(stream_ID.NextNode(), root_1);

                                          DebugLocation(50, 63);
                                          adaptor.AddChild(root_1, stream_i1.NextNode());
                                          DebugLocation(50, 67);
                                          // C:\\Users\\franz\\SkyDrive\\Dokumente\\workspace\\TextTable\\src\\eu\\reitmayer\\texttable\\lang\\TextTable.g:50:67: ( $al)?
                                          if (stream_al.HasNext)
                                          {
                                              DebugLocation(50, 67);
                                              adaptor.AddChild(root_1, stream_al.NextNode());
                                          }
                                          stream_al.Reset();

                                          adaptor.AddChild(root_0, root_1);
                                      }
                                  }

                                  retval.Tree = root_0;
                              }
                          }
                          break;
                      }
                      retval.Stop = (IToken)input.LT(-1);

                      retval.Tree = (object)adaptor.RulePostProcessing(root_0);
                      adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
                  }
                  catch (RecognitionException re)
                  {
                      ReportError(re);
                      Recover(input, re);
                      retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);
                  }
                  finally
                  {
                      TraceOut("plain_elem", 5);
                      LeaveRule("plain_elem", 5);
                      LeaveRule_plain_elem();
                  }
                  DebugLocation(51, 2); } finally { DebugExitRule(GrammarFileName, "plain_elem"); }
            return(retval);
        }