Beispiel #1
0
        // throws RecognitionException [1]
        // $ANTLR start unaryExpression
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1420:1: unaryExpression : (iin= INC unaryExpression -> ^( PRE_INC[$iin] unaryExpression ) | dde= DEC unaryExpression -> ^( PRE_DEC[$dde] unaryExpression ) | tmin= MINUS unaryExpression -> ^( UNARY_MINUS unaryExpression ) | tplus= PLUS unaryExpression -> ^( UNARY_PLUS unaryExpression ) | unaryExpressionNotPlusMinus );
        public unaryExpression_return unaryExpression()
        {
            unaryExpression_return retval = new unaryExpression_return();
            retval.start = input.LT(1);
            int unaryExpression_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken iin = null;
            CommonToken dde = null;
            CommonToken tmin = null;
            CommonToken tplus = null;
            unaryExpression_return unaryExpression274 = null;

            unaryExpression_return unaryExpression275 = null;

            unaryExpression_return unaryExpression276 = null;

            unaryExpression_return unaryExpression277 = null;

            unaryExpressionNotPlusMinus_return unaryExpressionNotPlusMinus278 = null;

            CommonTree iin_tree=null;
            CommonTree dde_tree=null;
            CommonTree tmin_tree=null;
            CommonTree tplus_tree=null;
            RewriteRuleTokenStream stream_PLUS = new RewriteRuleTokenStream(adaptor,"token PLUS");
            RewriteRuleTokenStream stream_INC = new RewriteRuleTokenStream(adaptor,"token INC");
            RewriteRuleTokenStream stream_MINUS = new RewriteRuleTokenStream(adaptor,"token MINUS");
            RewriteRuleTokenStream stream_DEC = new RewriteRuleTokenStream(adaptor,"token DEC");
            RewriteRuleSubtreeStream stream_unaryExpression = new RewriteRuleSubtreeStream(adaptor,"rule unaryExpression");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 108) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1421:4: (iin= INC unaryExpression -> ^( PRE_INC[$iin] unaryExpression ) | dde= DEC unaryExpression -> ^( PRE_DEC[$dde] unaryExpression ) | tmin= MINUS unaryExpression -> ^( UNARY_MINUS unaryExpression ) | tplus= PLUS unaryExpression -> ^( UNARY_PLUS unaryExpression ) | unaryExpressionNotPlusMinus )
            int alt80 = 5;
            switch ( input.LA(1) )
            {
            case INC:
                {
                alt80 = 1;
                }
                break;
            case DEC:
                {
                alt80 = 2;
                }
                break;
            case MINUS:
                {
                alt80 = 3;
                }
                break;
            case PLUS:
                {
                alt80 = 4;
                }
                break;
            case LCURLY:
            case STRING_LITERAL:
            case FUNCTION:
            case GET:
            case SET:
            case LPAREN:
            case VOID:
            case IDENT:
            case LBRACK:
            case DYNAMIC:
            case IS:
            case AS:
            case DELETE:
            case TYPEOF:
            case LNOT:
            case BNOT:
            case UNDEFINED:
            case TRUE:
            case FALSE:
            case NULL:
            case HEX_LITERAL:
            case DECIMAL_LITERAL:
            case OCTAL_LITERAL:
            case FLOAT_LITERAL:
            case NEW:
            case USE:
            case XML:
                {
                alt80 = 5;
                }
                break;
                default:
                    if ( backtracking > 0 ) {failed = true; return retval;}
                    NoViableAltException nvae_d80s0 =
                        new NoViableAltException("1420:1: unaryExpression : (iin= INC unaryExpression -> ^( PRE_INC[$iin] unaryExpression ) | dde= DEC unaryExpression -> ^( PRE_DEC[$dde] unaryExpression ) | tmin= MINUS unaryExpression -> ^( UNARY_MINUS unaryExpression ) | tplus= PLUS unaryExpression -> ^( UNARY_PLUS unaryExpression ) | unaryExpressionNotPlusMinus );", 80, 0, input);

                    throw nvae_d80s0;
            }

            switch (alt80)
            {
                case 1 :
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1421:4: iin= INC unaryExpression
                    {
                        iin = (CommonToken)input.LT(1);
                        Match(input,INC,FOLLOW_INC_in_unaryExpression4884); if (failed) return retval;
                        if ( backtracking==0 ) stream_INC.Add(iin);

                        if ( backtracking == 0 )
                        {
                           buffer.Append(iin.Text);
                        }
                        PushFollow(FOLLOW_unaryExpression_in_unaryExpression4889);
                        unaryExpression274 = unaryExpression();
                        followingStackPointer_--;
                        if (failed) return retval;
                        if ( backtracking==0 ) stream_unaryExpression.Add(unaryExpression274.Tree);

                        // AST REWRITE
                        // elements:          unaryExpression
                        // 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();
                        // 1421:59: -> ^( PRE_INC[$iin] unaryExpression )
                        {
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1421:62: ^( PRE_INC[$iin] unaryExpression )
                            {
                            CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                            root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(PRE_INC, iin), root_1);

                            adaptor.AddChild(root_1, stream_unaryExpression.Next());

                            adaptor.AddChild(root_0, root_1);
                            }

                        }

                        }

                    }
                    break;
                case 2 :
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1422:4: dde= DEC unaryExpression
                    {
                        dde = (CommonToken)input.LT(1);
                        Match(input,DEC,FOLLOW_DEC_in_unaryExpression4906); if (failed) return retval;
                        if ( backtracking==0 ) stream_DEC.Add(dde);

                        if ( backtracking == 0 )
                        {
                           buffer.Append(dde.Text);
                        }
                        PushFollow(FOLLOW_unaryExpression_in_unaryExpression4911);
                        unaryExpression275 = unaryExpression();
                        followingStackPointer_--;
                        if (failed) return retval;
                        if ( backtracking==0 ) stream_unaryExpression.Add(unaryExpression275.Tree);

                        // AST REWRITE
                        // elements:          unaryExpression
                        // 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();
                        // 1422:59: -> ^( PRE_DEC[$dde] unaryExpression )
                        {
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1422:62: ^( PRE_DEC[$dde] unaryExpression )
                            {
                            CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                            root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(PRE_DEC, dde), root_1);

                            adaptor.AddChild(root_1, stream_unaryExpression.Next());

                            adaptor.AddChild(root_0, root_1);
                            }

                        }

                        }

                    }
                    break;
                case 3 :
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1423:4: tmin= MINUS unaryExpression
                    {
                        tmin = (CommonToken)input.LT(1);
                        Match(input,MINUS,FOLLOW_MINUS_in_unaryExpression4928); if (failed) return retval;
                        if ( backtracking==0 ) stream_MINUS.Add(tmin);

                        if ( backtracking == 0 )
                        {
                           buffer.Append(tmin.Text);
                        }
                        PushFollow(FOLLOW_unaryExpression_in_unaryExpression4932);
                        unaryExpression276 = unaryExpression();
                        followingStackPointer_--;
                        if (failed) return retval;
                        if ( backtracking==0 ) stream_unaryExpression.Add(unaryExpression276.Tree);

                        // AST REWRITE
                        // elements:          unaryExpression
                        // 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();
                        // 1423:63: -> ^( UNARY_MINUS unaryExpression )
                        {
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1423:66: ^( UNARY_MINUS unaryExpression )
                            {
                            CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                            root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(UNARY_MINUS, "UNARY_MINUS"), root_1);

                            adaptor.AddChild(root_1, stream_unaryExpression.Next());

                            adaptor.AddChild(root_0, root_1);
                            }

                        }

                        }

                    }
                    break;
                case 4 :
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1424:4: tplus= PLUS unaryExpression
                    {
                        tplus = (CommonToken)input.LT(1);
                        Match(input,PLUS,FOLLOW_PLUS_in_unaryExpression4948); if (failed) return retval;
                        if ( backtracking==0 ) stream_PLUS.Add(tplus);

                        if ( backtracking == 0 )
                        {
                           buffer.Append(tplus.Text);
                        }
                        PushFollow(FOLLOW_unaryExpression_in_unaryExpression4952);
                        unaryExpression277 = unaryExpression();
                        followingStackPointer_--;
                        if (failed) return retval;
                        if ( backtracking==0 ) stream_unaryExpression.Add(unaryExpression277.Tree);

                        // AST REWRITE
                        // elements:          unaryExpression
                        // 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();
                        // 1424:63: -> ^( UNARY_PLUS unaryExpression )
                        {
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1424:66: ^( UNARY_PLUS unaryExpression )
                            {
                            CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                            root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(UNARY_PLUS, "UNARY_PLUS"), root_1);

                            adaptor.AddChild(root_1, stream_unaryExpression.Next());

                            adaptor.AddChild(root_0, root_1);
                            }

                        }

                        }

                    }
                    break;
                case 5 :
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1425:4: unaryExpressionNotPlusMinus
                    {
                        root_0 = (CommonTree)adaptor.GetNilNode();

                        PushFollow(FOLLOW_unaryExpressionNotPlusMinus_in_unaryExpression4966);
                        unaryExpressionNotPlusMinus278 = unaryExpressionNotPlusMinus();
                        followingStackPointer_--;
                        if (failed) return retval;
                        if ( backtracking==0 ) adaptor.AddChild(root_0, unaryExpressionNotPlusMinus278.Tree);

                    }
                    break;

            }
            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, 108, unaryExpression_StartIndex);
            }
            }
            return retval;
        }
Beispiel #2
0
    // $ANTLR start unaryExpression
    // C:\\Documents and Settings\\Sébastien Ros\\Mes documents\\Développement\\NLinq\\NLinq.g:141:1: unaryExpression returns [Expression value] : ( statement | '!' statement | '-' statement );
    public unaryExpression_return unaryExpression() // throws RecognitionException [1]
    {   
        unaryExpression_return retval = new unaryExpression_return();
        retval.start = input.LT(1);
        
        CommonTree root_0 = null;
    
        IToken char_literal23 = null;
        IToken char_literal25 = null;
        statement_return statement22 = null;

        statement_return statement24 = null;

        statement_return statement26 = null;
        
        
        CommonTree char_literal23_tree=null;
        CommonTree char_literal25_tree=null;
    
        try 
    	{
            // C:\\Documents and Settings\\Sébastien Ros\\Mes documents\\Développement\\NLinq\\NLinq.g:142:2: ( statement | '!' statement | '-' statement )
            int alt13 = 3;
            switch ( input.LA(1) ) 
            {
            case INTEGER:
            case FLOAT:
            case STRING:
            case ID:
            case 34:
            case 38:
            case 42:
            case 57:
            case 58:
            	{
                alt13 = 1;
                }
                break;
            case 32:
            	{
                alt13 = 2;
                }
                break;
            case 28:
            	{
                alt13 = 3;
                }
                break;
            	default:
            	    NoViableAltException nvae_d13s0 =
            	        new NoViableAltException("141:1: unaryExpression returns [Expression value] : ( statement | '!' statement | '-' statement );", 13, 0, input);
            
            	    throw nvae_d13s0;
            }
            
            switch (alt13) 
            {
                case 1 :
                    // C:\\Documents and Settings\\Sébastien Ros\\Mes documents\\Développement\\NLinq\\NLinq.g:142:4: statement
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();
                    
                    	PushFollow(FOLLOW_statement_in_unaryExpression542);
                    	statement22 = statement();
                    	followingStackPointer_--;
                    	
                    	adaptor.AddChild(root_0, statement22.Tree);
                    	 retval.value =  statement22.value; 
                    
                    }
                    break;
                case 2 :
                    // C:\\Documents and Settings\\Sébastien Ros\\Mes documents\\Développement\\NLinq\\NLinq.g:143:8: '!' statement
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();
                    
                    	char_literal23 = (IToken)input.LT(1);
                    	Match(input,32,FOLLOW_32_in_unaryExpression553); 
                    	char_literal23_tree = (CommonTree)adaptor.Create(char_literal23);
                    	adaptor.AddChild(root_0, char_literal23_tree);

                    	PushFollow(FOLLOW_statement_in_unaryExpression555);
                    	statement24 = statement();
                    	followingStackPointer_--;
                    	
                    	adaptor.AddChild(root_0, statement24.Tree);
                    	 retval.value =  new UnaryExpression(UnaryExpressionType.Not, statement24.value); 
                    
                    }
                    break;
                case 3 :
                    // C:\\Documents and Settings\\Sébastien Ros\\Mes documents\\Développement\\NLinq\\NLinq.g:144:8: '-' statement
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();
                    
                    	char_literal25 = (IToken)input.LT(1);
                    	Match(input,28,FOLLOW_28_in_unaryExpression566); 
                    	char_literal25_tree = (CommonTree)adaptor.Create(char_literal25);
                    	adaptor.AddChild(root_0, char_literal25_tree);

                    	PushFollow(FOLLOW_statement_in_unaryExpression568);
                    	statement26 = statement();
                    	followingStackPointer_--;
                    	
                    	adaptor.AddChild(root_0, statement26.Tree);
                    	 retval.value =  new UnaryExpression(UnaryExpressionType.Negate, statement26.value); 
                    
                    }
                    break;
            
            }
            retval.stop = input.LT(-1);
            
            	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
    
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return retval;
    }