示例#1
0
 /// <summary>
 ///     Performs "Modulo" specific operations.
 /// </summary>
 /// <param name="node">The "Modulo" node.</param>
 public virtual void Visit(ModuloNode node)
 {
     ExpressionGenerateInstructions <ModuloNumericToNumeric>();
 }
    // $ANTLR start "multiplicativeExpression"
    // JavaScript.g:309:1: multiplicativeExpression : unaryExpression ( ( LT )* ( ( '*' | '/' | '%' ) ( LT )* unaryExpression ) )* ;
    public JavaScriptParser.multiplicativeExpression_return multiplicativeExpression() // throws RecognitionException [1]
    {   
        JavaScriptParser.multiplicativeExpression_return retval = new JavaScriptParser.multiplicativeExpression_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken LT362 = null;
        IToken char_literal363 = null;
        IToken char_literal364 = null;
        IToken char_literal365 = null;
        IToken LT366 = null;
        JavaScriptParser.unaryExpression_return unaryExpression361 = default(JavaScriptParser.unaryExpression_return);

        JavaScriptParser.unaryExpression_return unaryExpression367 = default(JavaScriptParser.unaryExpression_return);


        object LT362_tree=null;
        object char_literal363_tree=null;
        object char_literal364_tree=null;
        object char_literal365_tree=null;
        object LT366_tree=null;

        try 
    	{
            // JavaScript.g:310:2: ( unaryExpression ( ( LT )* ( ( '*' | '/' | '%' ) ( LT )* unaryExpression ) )* )
            // JavaScript.g:310:4: unaryExpression ( ( LT )* ( ( '*' | '/' | '%' ) ( LT )* unaryExpression ) )*
            {
            	root_0 = (object)adaptor.GetNilNode();

            	PushFollow(FOLLOW_unaryExpression_in_multiplicativeExpression2787);
            	unaryExpression361 = unaryExpression();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, unaryExpression361.Tree);
            	// JavaScript.g:310:20: ( ( LT )* ( ( '*' | '/' | '%' ) ( LT )* unaryExpression ) )*
            	do 
            	{
            	    int alt191 = 2;
            	    alt191 = dfa191.Predict(input);
            	    switch (alt191) 
            		{
            			case 1 :
            			    // JavaScript.g:310:21: ( LT )* ( ( '*' | '/' | '%' ) ( LT )* unaryExpression )
            			    {
            			    	// JavaScript.g:310:23: ( LT )*
            			    	do 
            			    	{
            			    	    int alt188 = 2;
            			    	    int LA188_0 = input.LA(1);

            			    	    if ( (LA188_0 == LT) )
            			    	    {
            			    	        alt188 = 1;
            			    	    }


            			    	    switch (alt188) 
            			    		{
            			    			case 1 :
            			    			    // JavaScript.g:310:23: LT
            			    			    {
            			    			    	LT362=(IToken)Match(input,LT,FOLLOW_LT_in_multiplicativeExpression2790); if (state.failed) return retval;

            			    			    }
            			    			    break;

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

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

            			    	// JavaScript.g:310:25: ( ( '*' | '/' | '%' ) ( LT )* unaryExpression )
            			    	// JavaScript.g:310:26: ( '*' | '/' | '%' ) ( LT )* unaryExpression
            			    	{
            			    		// JavaScript.g:310:26: ( '*' | '/' | '%' )
            			    		int alt189 = 3;
            			    		switch ( input.LA(1) ) 
            			    		{
            			    		case 101:
            			    			{
            			    		    alt189 = 1;
            			    		    }
            			    		    break;
            			    		case 102:
            			    			{
            			    		    alt189 = 2;
            			    		    }
            			    		    break;
            			    		case 103:
            			    			{
            			    		    alt189 = 3;
            			    		    }
            			    		    break;
            			    			default:
            			    			    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            			    			    NoViableAltException nvae_d189s0 =
            			    			        new NoViableAltException("", 189, 0, input);

            			    			    throw nvae_d189s0;
            			    		}

            			    		switch (alt189) 
            			    		{
            			    		    case 1 :
            			    		        // JavaScript.g:310:27: '*'
            			    		        {
            			    		        	char_literal363=(IToken)Match(input,101,FOLLOW_101_in_multiplicativeExpression2795); if (state.failed) return retval;
            			    		        	if ( state.backtracking == 0 )
            			    		        	{char_literal363_tree = new MultiplyNode(char_literal363) ;
            			    		        		root_0 = (object)adaptor.BecomeRoot(char_literal363_tree, root_0);
            			    		        	}

            			    		        }
            			    		        break;
            			    		    case 2 :
            			    		        // JavaScript.g:310:48: '/'
            			    		        {
            			    		        	char_literal364=(IToken)Match(input,102,FOLLOW_102_in_multiplicativeExpression2803); if (state.failed) return retval;
            			    		        	if ( state.backtracking == 0 )
            			    		        	{char_literal364_tree = new DivideNode(char_literal364) ;
            			    		        		root_0 = (object)adaptor.BecomeRoot(char_literal364_tree, root_0);
            			    		        	}

            			    		        }
            			    		        break;
            			    		    case 3 :
            			    		        // JavaScript.g:310:67: '%'
            			    		        {
            			    		        	char_literal365=(IToken)Match(input,103,FOLLOW_103_in_multiplicativeExpression2811); if (state.failed) return retval;
            			    		        	if ( state.backtracking == 0 )
            			    		        	{char_literal365_tree = new ModuloNode(char_literal365) ;
            			    		        		root_0 = (object)adaptor.BecomeRoot(char_literal365_tree, root_0);
            			    		        	}

            			    		        }
            			    		        break;

            			    		}

            			    		// JavaScript.g:310:87: ( LT )*
            			    		do 
            			    		{
            			    		    int alt190 = 2;
            			    		    int LA190_0 = input.LA(1);

            			    		    if ( (LA190_0 == LT) )
            			    		    {
            			    		        alt190 = 1;
            			    		    }


            			    		    switch (alt190) 
            			    			{
            			    				case 1 :
            			    				    // JavaScript.g:310:87: LT
            			    				    {
            			    				    	LT366=(IToken)Match(input,LT,FOLLOW_LT_in_multiplicativeExpression2818); if (state.failed) return retval;

            			    				    }
            			    				    break;

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

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

            			    		PushFollow(FOLLOW_unaryExpression_in_multiplicativeExpression2822);
            			    		unaryExpression367 = unaryExpression();
            			    		state.followingStackPointer--;
            			    		if (state.failed) return retval;
            			    		if ( state.backtracking == 0 ) adaptor.AddChild(root_0, unaryExpression367.Tree);

            			    	}


            			    }
            			    break;

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

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


            }

            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;
    }
示例#3
0
        private RdlSyntaxNode ComposeArithmeticOperators(Precendence precendence)
        {
            RdlSyntaxNode node = null;

            switch (precendence)
            {
            case Precendence.Level1:
            {
                node = ComposeArithmeticOperators(Precendence.Level2);
                while (IsArithmeticOperator(Current, Precendence.Level1))
                {
                    switch (Current.TokenType)
                    {
                    case StatementType.Star:
                        Consume(StatementType.Star);
                        node = new StarNode(node, ComposeBaseTypes());
                        break;

                    case StatementType.FSlash:
                        Consume(StatementType.FSlash);
                        node = new FSlashNode(node, ComposeBaseTypes());
                        break;

                    case StatementType.Mod:
                        Consume(StatementType.Mod);
                        node = new ModuloNode(node, ComposeBaseTypes());
                        break;

                    case StatementType.In:
                        Consume(StatementType.In);
                        node = new InNode(node, ComposeArgs());
                        break;

                    case StatementType.NotIn:
                        Consume(StatementType.NotIn);
                        node = new NotInNode(node, ComposeArgs());
                        break;
                    }
                }
                break;
            }

            case Precendence.Level2:
            {
                node = ComposeArithmeticOperators(Precendence.Level3);
                while (IsArithmeticOperator(Current, Precendence.Level2))
                {
                    switch (Current.TokenType)
                    {
                    case StatementType.Plus:
                        Consume(StatementType.Plus);
                        node = new AddNode(node, ComposeBaseTypes());
                        break;

                    case StatementType.Hyphen:
                        Consume(StatementType.Hyphen);
                        node = new HyphenNode(node, ComposeBaseTypes());
                        break;
                    }
                }
                break;
            }

            case Precendence.Level3:
                node = ComposeBaseTypes();
                break;
            }
            return(node);
        }