Пример #1
0
        private object NotEqualsNode(NotEqualsNode ne)
        {
            var l = Evaluate(ne.l);
            var r = Evaluate(ne.r);

            return((decimal)l != (decimal)r);
        }
Пример #2
0
    // $ANTLR start "equalityExpression"
    // JavaScript.g:271:1: equalityExpression : relationalExpression ( ( LT )* ( '==' ( LT )* relationalExpression | '!=' ( LT )* relationalExpression | '===' ( LT )* relationalExpression | '!==' ( LT )* relationalExpression ) )* ;
    public JavaScriptParser.equalityExpression_return equalityExpression() // throws RecognitionException [1]
    {   
        JavaScriptParser.equalityExpression_return retval = new JavaScriptParser.equalityExpression_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken LT312 = null;
        IToken string_literal313 = null;
        IToken LT314 = null;
        IToken string_literal316 = null;
        IToken LT317 = null;
        IToken string_literal319 = null;
        IToken LT320 = null;
        IToken string_literal322 = null;
        IToken LT323 = null;
        JavaScriptParser.relationalExpression_return relationalExpression311 = default(JavaScriptParser.relationalExpression_return);

        JavaScriptParser.relationalExpression_return relationalExpression315 = default(JavaScriptParser.relationalExpression_return);

        JavaScriptParser.relationalExpression_return relationalExpression318 = default(JavaScriptParser.relationalExpression_return);

        JavaScriptParser.relationalExpression_return relationalExpression321 = default(JavaScriptParser.relationalExpression_return);

        JavaScriptParser.relationalExpression_return relationalExpression324 = default(JavaScriptParser.relationalExpression_return);


        object LT312_tree=null;
        object string_literal313_tree=null;
        object LT314_tree=null;
        object string_literal316_tree=null;
        object LT317_tree=null;
        object string_literal319_tree=null;
        object LT320_tree=null;
        object string_literal322_tree=null;
        object LT323_tree=null;

        try 
    	{
            // JavaScript.g:272:2: ( relationalExpression ( ( LT )* ( '==' ( LT )* relationalExpression | '!=' ( LT )* relationalExpression | '===' ( LT )* relationalExpression | '!==' ( LT )* relationalExpression ) )* )
            // JavaScript.g:272:4: relationalExpression ( ( LT )* ( '==' ( LT )* relationalExpression | '!=' ( LT )* relationalExpression | '===' ( LT )* relationalExpression | '!==' ( LT )* relationalExpression ) )*
            {
            	root_0 = (object)adaptor.GetNilNode();

            	PushFollow(FOLLOW_relationalExpression_in_equalityExpression2399);
            	relationalExpression311 = relationalExpression();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, relationalExpression311.Tree);
            	// JavaScript.g:273:4: ( ( LT )* ( '==' ( LT )* relationalExpression | '!=' ( LT )* relationalExpression | '===' ( LT )* relationalExpression | '!==' ( LT )* relationalExpression ) )*
            	do 
            	{
            	    int alt169 = 2;
            	    alt169 = dfa169.Predict(input);
            	    switch (alt169) 
            		{
            			case 1 :
            			    // JavaScript.g:273:5: ( LT )* ( '==' ( LT )* relationalExpression | '!=' ( LT )* relationalExpression | '===' ( LT )* relationalExpression | '!==' ( LT )* relationalExpression )
            			    {
            			    	// JavaScript.g:273:7: ( LT )*
            			    	do 
            			    	{
            			    	    int alt163 = 2;
            			    	    int LA163_0 = input.LA(1);

            			    	    if ( (LA163_0 == LT) )
            			    	    {
            			    	        alt163 = 1;
            			    	    }


            			    	    switch (alt163) 
            			    		{
            			    			case 1 :
            			    			    // JavaScript.g:273:7: LT
            			    			    {
            			    			    	LT312=(IToken)Match(input,LT,FOLLOW_LT_in_equalityExpression2406); if (state.failed) return retval;

            			    			    }
            			    			    break;

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

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

            			    	// JavaScript.g:273:10: ( '==' ( LT )* relationalExpression | '!=' ( LT )* relationalExpression | '===' ( LT )* relationalExpression | '!==' ( LT )* relationalExpression )
            			    	int alt168 = 4;
            			    	switch ( input.LA(1) ) 
            			    	{
            			    	case 87:
            			    		{
            			    	    alt168 = 1;
            			    	    }
            			    	    break;
            			    	case 88:
            			    		{
            			    	    alt168 = 2;
            			    	    }
            			    	    break;
            			    	case 89:
            			    		{
            			    	    alt168 = 3;
            			    	    }
            			    	    break;
            			    	case 90:
            			    		{
            			    	    alt168 = 4;
            			    	    }
            			    	    break;
            			    		default:
            			    		    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            			    		    NoViableAltException nvae_d168s0 =
            			    		        new NoViableAltException("", 168, 0, input);

            			    		    throw nvae_d168s0;
            			    	}

            			    	switch (alt168) 
            			    	{
            			    	    case 1 :
            			    	        // JavaScript.g:274:6: '==' ( LT )* relationalExpression
            			    	        {
            			    	        	string_literal313=(IToken)Match(input,87,FOLLOW_87_in_equalityExpression2417); if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 )
            			    	        	{string_literal313_tree = new EqualsNode(string_literal313) ;
            			    	        		root_0 = (object)adaptor.BecomeRoot(string_literal313_tree, root_0);
            			    	        	}
            			    	        	// JavaScript.g:274:26: ( LT )*
            			    	        	do 
            			    	        	{
            			    	        	    int alt164 = 2;
            			    	        	    int LA164_0 = input.LA(1);

            			    	        	    if ( (LA164_0 == LT) )
            			    	        	    {
            			    	        	        alt164 = 1;
            			    	        	    }


            			    	        	    switch (alt164) 
            			    	        		{
            			    	        			case 1 :
            			    	        			    // JavaScript.g:274:26: LT
            			    	        			    {
            			    	        			    	LT314=(IToken)Match(input,LT,FOLLOW_LT_in_equalityExpression2423); if (state.failed) return retval;

            			    	        			    }
            			    	        			    break;

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

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

            			    	        	PushFollow(FOLLOW_relationalExpression_in_equalityExpression2427);
            			    	        	relationalExpression315 = relationalExpression();
            			    	        	state.followingStackPointer--;
            			    	        	if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, relationalExpression315.Tree);

            			    	        }
            			    	        break;
            			    	    case 2 :
            			    	        // JavaScript.g:275:6: '!=' ( LT )* relationalExpression
            			    	        {
            			    	        	string_literal316=(IToken)Match(input,88,FOLLOW_88_in_equalityExpression2435); if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 )
            			    	        	{string_literal316_tree = new NotEqualsNode(string_literal316) ;
            			    	        		root_0 = (object)adaptor.BecomeRoot(string_literal316_tree, root_0);
            			    	        	}
            			    	        	// JavaScript.g:275:29: ( LT )*
            			    	        	do 
            			    	        	{
            			    	        	    int alt165 = 2;
            			    	        	    int LA165_0 = input.LA(1);

            			    	        	    if ( (LA165_0 == LT) )
            			    	        	    {
            			    	        	        alt165 = 1;
            			    	        	    }


            			    	        	    switch (alt165) 
            			    	        		{
            			    	        			case 1 :
            			    	        			    // JavaScript.g:275:29: LT
            			    	        			    {
            			    	        			    	LT317=(IToken)Match(input,LT,FOLLOW_LT_in_equalityExpression2441); if (state.failed) return retval;

            			    	        			    }
            			    	        			    break;

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

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

            			    	        	PushFollow(FOLLOW_relationalExpression_in_equalityExpression2445);
            			    	        	relationalExpression318 = relationalExpression();
            			    	        	state.followingStackPointer--;
            			    	        	if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, relationalExpression318.Tree);

            			    	        }
            			    	        break;
            			    	    case 3 :
            			    	        // JavaScript.g:276:6: '===' ( LT )* relationalExpression
            			    	        {
            			    	        	string_literal319=(IToken)Match(input,89,FOLLOW_89_in_equalityExpression2453); if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 )
            			    	        	{string_literal319_tree = new EqualsNodeEx(string_literal319) ;
            			    	        		root_0 = (object)adaptor.BecomeRoot(string_literal319_tree, root_0);
            			    	        	}
            			    	        	// JavaScript.g:276:29: ( LT )*
            			    	        	do 
            			    	        	{
            			    	        	    int alt166 = 2;
            			    	        	    int LA166_0 = input.LA(1);

            			    	        	    if ( (LA166_0 == LT) )
            			    	        	    {
            			    	        	        alt166 = 1;
            			    	        	    }


            			    	        	    switch (alt166) 
            			    	        		{
            			    	        			case 1 :
            			    	        			    // JavaScript.g:276:29: LT
            			    	        			    {
            			    	        			    	LT320=(IToken)Match(input,LT,FOLLOW_LT_in_equalityExpression2459); if (state.failed) return retval;

            			    	        			    }
            			    	        			    break;

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

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

            			    	        	PushFollow(FOLLOW_relationalExpression_in_equalityExpression2463);
            			    	        	relationalExpression321 = relationalExpression();
            			    	        	state.followingStackPointer--;
            			    	        	if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, relationalExpression321.Tree);

            			    	        }
            			    	        break;
            			    	    case 4 :
            			    	        // JavaScript.g:277:6: '!==' ( LT )* relationalExpression
            			    	        {
            			    	        	string_literal322=(IToken)Match(input,90,FOLLOW_90_in_equalityExpression2471); if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 )
            			    	        	{string_literal322_tree = new NotEqualsNodeEx(string_literal322) ;
            			    	        		root_0 = (object)adaptor.BecomeRoot(string_literal322_tree, root_0);
            			    	        	}
            			    	        	// JavaScript.g:277:32: ( LT )*
            			    	        	do 
            			    	        	{
            			    	        	    int alt167 = 2;
            			    	        	    int LA167_0 = input.LA(1);

            			    	        	    if ( (LA167_0 == LT) )
            			    	        	    {
            			    	        	        alt167 = 1;
            			    	        	    }


            			    	        	    switch (alt167) 
            			    	        		{
            			    	        			case 1 :
            			    	        			    // JavaScript.g:277:32: LT
            			    	        			    {
            			    	        			    	LT323=(IToken)Match(input,LT,FOLLOW_LT_in_equalityExpression2477); if (state.failed) return retval;

            			    	        			    }
            			    	        			    break;

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

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

            			    	        	PushFollow(FOLLOW_relationalExpression_in_equalityExpression2481);
            			    	        	relationalExpression324 = relationalExpression();
            			    	        	state.followingStackPointer--;
            			    	        	if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, relationalExpression324.Tree);

            			    	        }
            			    	        break;

            			    	}


            			    }
            			    break;

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

            	loop169:
            		;	// Stops C# compiler whining that label 'loop169' 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;
    }