示例#1
0
        private ExpressionNode ParseRel()
        {
            var lhs = ParseMathExpr();

            if (_reader.Peek() is LessThan)
            {
                Match <LessThan>();
                lhs = new LessThanNode(lhs, ParseMathExpr());
            }
            else if (_reader.Peek() is LessThanOrEqual)
            {
                Match <LessThanOrEqual>();
                lhs = new LessThanOrEqualNode(lhs, ParseMathExpr());
            }
            else if (_reader.Peek() is GreaterThan)
            {
                Match <GreaterThan>();
                lhs = new GreaterThanNode(lhs, ParseMathExpr());
            }
            else if (_reader.Peek() is GreaterThanOrEqual)
            {
                Match <GreaterThanOrEqual>();
                lhs = new GreaterThanNodeOrEqual(lhs, ParseMathExpr());
            }

            return(lhs);
        }
示例#2
0
        private object GreaterThanNode(GreaterThanNode gt)
        {
            var l = Evaluate(gt.l);
            var r = Evaluate(gt.r);

            return((decimal)l > (decimal)r);
        }
示例#3
0
文件: Parser.cs 项目: Daxea/RainyDay
        private AstNode Expression()
        {
            // EXPRESSION = TERM (ADD | SUBTRACT TERM)* (COMPARISON TERM)

            var node = Term();

            var ops = new[] { Tokens.Add, Tokens.Subtract };

            while (ops.Contains(_currentToken.Type))
            {
                var token = _currentToken;
                Eat(token.Type);
                if (token.Type == Tokens.Add)
                {
                    node = new AddNode(node, Term());
                }
                else if (token.Type == Tokens.Subtract)
                {
                    node = new SubtractNode(node, Term());
                }
            }

            if (Tokens.IsComparison(_currentToken.Type))
            {
                var token = _currentToken;
                if (token.Type == Tokens.Equal)
                {
                    Eat(Tokens.Equal);
                    node = new EqualToNode(node, Term());
                }
                else if (token.Type == Tokens.NotEqual)
                {
                    Eat(Tokens.NotEqual);
                    node = new NotEqualToNode(node, Term());
                }
                else if (token.Type == Tokens.GreaterThan)
                {
                    Eat(Tokens.GreaterThan);
                    node = new GreaterThanNode(node, Term());
                }
                else if (token.Type == Tokens.GreaterThanOrEqualTo)
                {
                    Eat(Tokens.GreaterThanOrEqualTo);
                    node = new GreaterThanOrEqualToNode(node, Term());
                }
                else if (token.Type == Tokens.LessThan)
                {
                    Eat(Tokens.LessThan);
                    node = new LessThanNode(node, Term());
                }
                else if (token.Type == Tokens.LessThanOrEqualTo)
                {
                    Eat(Tokens.LessThanOrEqualTo);
                    node = new LessThanOrEqualToNode(node, Term());
                }
            }

            return(node);
        }
示例#4
0
        public void Init()
        {
            _testExpression = Expression.GreaterThan(TestLeftExpression, TestRightExpression);

            TestObject = new GreaterThanNode(
                MockNodeFactory.Object,
                TestExpression);
        }
示例#5
0
 public object Visit(GreaterThanNode node)
 {
     return(this.Calculate(node.Value1, node.Value2,
                           (v1, v2) => v1 > v2,
                           (v1, v2) => v1 > v2,
                           (v1, v2, ex) =>
                           throw new InvalidOperationException($"[{v1 ?? "(null)"} > {v2 ?? "(null)"}] failed!", ex)));
 }
示例#6
0
        public void GreaterThanExpressionHasExpectedRight()
        {
            IExpressionNode actual = TestObject.Build(TestGreaterThanExpression);

            GreaterThanNode actualNode = actual.VerifyIsActually <GreaterThanNode>();
            ConstantNode    rightNode  = actualNode.Right.VerifyIsActually <ConstantNode>();

            Assert.AreSame(TestConstantOne, rightNode.SourceExpression);
        }
示例#7
0
        public void GreaterThanExpressionHasExpectedLeft()
        {
            IExpressionNode actual = TestObject.Build(TestGreaterThanExpression);

            GreaterThanNode actualNode = actual.VerifyIsActually <GreaterThanNode>();
            ConstantNode    leftNode   = actualNode.Left.VerifyIsActually <ConstantNode>();

            Assert.AreSame(TestConstantZero, leftNode.SourceExpression);
        }
示例#8
0
        public void GreaterThanExpressionIsExpected()
        {
            Expression testExpression = TestGreaterThanExpression;

            IExpressionNode actual = TestObject.Build(testExpression);

            GreaterThanNode actualNode = actual.VerifyIsActually <GreaterThanNode>();

            Assert.AreSame(testExpression, actualNode.SourceExpression);
        }
示例#9
0
        public DomainId <IAstNode> CreateGreaterThanOperation(
            string definition,
            DomainId <IAstNode> leftExpression,
            DomainId <IAstNode> rightExpression)
        {
            var greaterThanNode = new GreaterThanNode(
                m_ids.Next,
                definition,
                leftExpression,
                rightExpression);

            return(DomainItemRegistration <IGreaterThanNode>(greaterThanNode));
        }
        protected virtual BaseQuery HandleGreaterThan(GreaterThanNode node, ElasticSearchQueryMapperState state)
        {
            BaseQuery query;

            var fieldNode = node.GetFieldNode();
            var valueNode = QueryHelper.GetValueNode(node, fieldNode.FieldType);

            if (ProcessAsVirtualField(fieldNode, valueNode, node.Boost, ComparisonType.GreaterThan, state, out query))
            {
                return(query);
            }

            return(HandleGreaterThan(fieldNode.FieldKey, valueNode.Value, node.Boost));
        }
示例#11
0
        private bool Visit(GreaterThanNode node)
        {
            var left  = Visit(node.Left);
            var right = Visit(node.Right);

            if (left is int && right is int)
            {
                return((int)left > (int)right);
            }
            else if (left is float && right is float)
            {
                return((float)left > (float)right);
            }
            return(false);
        }
示例#12
0
文件: ASTBuilder.cs 项目: Deaxz/ML4D
        public override Node VisitInfixRelationalExpr(ML4DParser.InfixRelationalExprContext context)
        {
            InfixExpressionNode node;

            switch (context.op.Type)
            {
            case ML4DLexer.LTHAN:
                node = new LessThanNode(context.op.Text);
                break;

            case ML4DLexer.GTHAN:
                node = new GreaterThanNode(context.op.Text);
                break;

            case ML4DLexer.LETHAN:
                node = new LessEqualThanNode(context.op.Text);
                break;

            case ML4DLexer.GETHAN:
                node = new GreaterEqualThanNode(context.op.Text);
                break;

            case ML4DLexer.EQUALS:
                node = new EqualNode(context.op.Text);
                break;

            case ML4DLexer.NOTEQUALS:
                node = new NotEqualNode(context.op.Text);
                break;

            default:
                throw new NotSupportedException(
                          $"The operator {context.op.Text}, is not a valid relational operator.");
            }
            node.Left  = (ExpressionNode)Visit(context.left);
            node.Right = (ExpressionNode)Visit(context.right);
            return(node);
        }
示例#13
0
 public virtual void VisitGreaterThan(GreaterThanNode greaterThanNode) => throw new NotImplementedException();
 protected virtual QueryNode VisitGreaterThan(GreaterThanNode node, AzureQueryOptimizerState state)
 {
     return((QueryNode) new GreaterThanNode(this.Visit(node.LeftNode, state), this.Visit(node.RightNode, state)));
 }
示例#15
0
        private bool TryExpression(ParserContext context, out IAstNode instr)
        {
            IAstNode value2;

            if (context.Stream.Consume <IAstNode>(TryTerm, context, out var currInstr))
            {
                instr = currInstr;

                while (!context.Stream.Eof)
                {
                    if (context.Stream.Consume(TokenTypes.Plus))
                    {
                        if (!context.Stream.Consume <IAstNode>(TryTerm, context, out value2))
                        {
                            return(false);
                        }

                        currInstr = new AddNode(currInstr, value2);
                        instr     = currInstr;
                    }
                    else if (context.Stream.Consume(TokenTypes.Minus))
                    {
                        if (!context.Stream.Consume <IAstNode>(TryTerm, context, out value2))
                        {
                            return(false);
                        }

                        currInstr = new SubNode(currInstr, value2);
                        instr     = currInstr;
                    }
                    else if (context.Stream.Consume(TokenTypes.GreaterThan))
                    {
                        if (!context.Stream.Consume <IAstNode>(TryTerm, context, out value2))
                        {
                            return(false);
                        }

                        currInstr = new GreaterThanNode(currInstr, value2);
                        instr     = currInstr;
                    }
                    else if (context.Stream.Consume(TokenTypes.LessThan))
                    {
                        if (!context.Stream.Consume <IAstNode>(TryTerm, context, out value2))
                        {
                            return(false);
                        }

                        currInstr = new LessThanNode(currInstr, value2);
                        instr     = currInstr;
                    }
                    else if (context.Stream.Consume(TokenTypes.Equal))
                    {
                        if (!context.Stream.Consume <IAstNode>(TryTerm, context, out value2))
                        {
                            return(false);
                        }

                        currInstr = new EqualNode(currInstr, value2);
                        instr     = currInstr;
                    }
                    else if (context.Stream.Consume(TokenTypes.NotEqual))
                    {
                        if (!context.Stream.Consume <IAstNode>(TryTerm, context, out value2))
                        {
                            return(false);
                        }

                        currInstr = new NotEqualNode(currInstr, value2);
                        instr     = currInstr;
                    }
                    else
                    {
                        return(true);
                    }
                }

                return(true);
            }

            instr = null;
            return(false);
        }
        protected virtual QueryNode VisitGreaterThan(GreaterThanNode node, ElasticSearchQueryOptimizerState state)
        {
            var node2 = Visit(node.LeftNode, state);

            return(new GreaterThanNode(node2, Visit(node.RightNode, state)));
        }
示例#17
0
    // $ANTLR start "relationalExpression"
    // JavaScript.g:281:1: relationalExpression : shiftExpression ( ( LT )* ( '<' ( LT )* shiftExpression | '>' ( LT )* shiftExpression | '<=' ( LT )* shiftExpression | '>=' ( LT )* shiftExpression | 'instanceof' ( LT )* shiftExpression | 'in' ( LT )* shiftExpression ) )* ;
    public JavaScriptParser.relationalExpression_return relationalExpression() // throws RecognitionException [1]
    {   
        JavaScriptParser.relationalExpression_return retval = new JavaScriptParser.relationalExpression_return();
        retval.Start = input.LT(1);

        object root_0 = null;

        IToken LT326 = null;
        IToken char_literal327 = null;
        IToken LT328 = null;
        IToken char_literal330 = null;
        IToken LT331 = null;
        IToken string_literal333 = null;
        IToken LT334 = null;
        IToken string_literal336 = null;
        IToken LT337 = null;
        IToken string_literal339 = null;
        IToken LT340 = null;
        IToken string_literal342 = null;
        IToken LT343 = null;
        JavaScriptParser.shiftExpression_return shiftExpression325 = default(JavaScriptParser.shiftExpression_return);

        JavaScriptParser.shiftExpression_return shiftExpression329 = default(JavaScriptParser.shiftExpression_return);

        JavaScriptParser.shiftExpression_return shiftExpression332 = default(JavaScriptParser.shiftExpression_return);

        JavaScriptParser.shiftExpression_return shiftExpression335 = default(JavaScriptParser.shiftExpression_return);

        JavaScriptParser.shiftExpression_return shiftExpression338 = default(JavaScriptParser.shiftExpression_return);

        JavaScriptParser.shiftExpression_return shiftExpression341 = default(JavaScriptParser.shiftExpression_return);

        JavaScriptParser.shiftExpression_return shiftExpression344 = default(JavaScriptParser.shiftExpression_return);


        object LT326_tree=null;
        object char_literal327_tree=null;
        object LT328_tree=null;
        object char_literal330_tree=null;
        object LT331_tree=null;
        object string_literal333_tree=null;
        object LT334_tree=null;
        object string_literal336_tree=null;
        object LT337_tree=null;
        object string_literal339_tree=null;
        object LT340_tree=null;
        object string_literal342_tree=null;
        object LT343_tree=null;

        try 
    	{
            // JavaScript.g:282:2: ( shiftExpression ( ( LT )* ( '<' ( LT )* shiftExpression | '>' ( LT )* shiftExpression | '<=' ( LT )* shiftExpression | '>=' ( LT )* shiftExpression | 'instanceof' ( LT )* shiftExpression | 'in' ( LT )* shiftExpression ) )* )
            // JavaScript.g:282:4: shiftExpression ( ( LT )* ( '<' ( LT )* shiftExpression | '>' ( LT )* shiftExpression | '<=' ( LT )* shiftExpression | '>=' ( LT )* shiftExpression | 'instanceof' ( LT )* shiftExpression | 'in' ( LT )* shiftExpression ) )*
            {
            	root_0 = (object)adaptor.GetNilNode();

            	PushFollow(FOLLOW_shiftExpression_in_relationalExpression2501);
            	shiftExpression325 = shiftExpression();
            	state.followingStackPointer--;
            	if (state.failed) return retval;
            	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, shiftExpression325.Tree);
            	// JavaScript.g:283:4: ( ( LT )* ( '<' ( LT )* shiftExpression | '>' ( LT )* shiftExpression | '<=' ( LT )* shiftExpression | '>=' ( LT )* shiftExpression | 'instanceof' ( LT )* shiftExpression | 'in' ( LT )* shiftExpression ) )*
            	do 
            	{
            	    int alt178 = 2;
            	    alt178 = dfa178.Predict(input);
            	    switch (alt178) 
            		{
            			case 1 :
            			    // JavaScript.g:283:5: ( LT )* ( '<' ( LT )* shiftExpression | '>' ( LT )* shiftExpression | '<=' ( LT )* shiftExpression | '>=' ( LT )* shiftExpression | 'instanceof' ( LT )* shiftExpression | 'in' ( LT )* shiftExpression )
            			    {
            			    	// JavaScript.g:283:7: ( LT )*
            			    	do 
            			    	{
            			    	    int alt170 = 2;
            			    	    int LA170_0 = input.LA(1);

            			    	    if ( (LA170_0 == LT) )
            			    	    {
            			    	        alt170 = 1;
            			    	    }


            			    	    switch (alt170) 
            			    		{
            			    			case 1 :
            			    			    // JavaScript.g:283:7: LT
            			    			    {
            			    			    	LT326=(IToken)Match(input,LT,FOLLOW_LT_in_relationalExpression2509); if (state.failed) return retval;

            			    			    }
            			    			    break;

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

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

            			    	// JavaScript.g:283:10: ( '<' ( LT )* shiftExpression | '>' ( LT )* shiftExpression | '<=' ( LT )* shiftExpression | '>=' ( LT )* shiftExpression | 'instanceof' ( LT )* shiftExpression | 'in' ( LT )* shiftExpression )
            			    	int alt177 = 6;
            			    	switch ( input.LA(1) ) 
            			    	{
            			    	case 91:
            			    		{
            			    	    alt177 = 1;
            			    	    }
            			    	    break;
            			    	case 92:
            			    		{
            			    	    alt177 = 2;
            			    	    }
            			    	    break;
            			    	case 93:
            			    		{
            			    	    alt177 = 3;
            			    	    }
            			    	    break;
            			    	case 94:
            			    		{
            			    	    alt177 = 4;
            			    	    }
            			    	    break;
            			    	case 95:
            			    		{
            			    	    alt177 = 5;
            			    	    }
            			    	    break;
            			    	case 53:
            			    		{
            			    	    alt177 = 6;
            			    	    }
            			    	    break;
            			    		default:
            			    		    if ( state.backtracking > 0 ) {state.failed = true; return retval;}
            			    		    NoViableAltException nvae_d177s0 =
            			    		        new NoViableAltException("", 177, 0, input);

            			    		    throw nvae_d177s0;
            			    	}

            			    	switch (alt177) 
            			    	{
            			    	    case 1 :
            			    	        // JavaScript.g:284:6: '<' ( LT )* shiftExpression
            			    	        {
            			    	        	char_literal327=(IToken)Match(input,91,FOLLOW_91_in_relationalExpression2520); if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 )
            			    	        	{char_literal327_tree = new LessThanNode(char_literal327) ;
            			    	        		root_0 = (object)adaptor.BecomeRoot(char_literal327_tree, root_0);
            			    	        	}
            			    	        	// JavaScript.g:284:27: ( LT )*
            			    	        	do 
            			    	        	{
            			    	        	    int alt171 = 2;
            			    	        	    int LA171_0 = input.LA(1);

            			    	        	    if ( (LA171_0 == LT) )
            			    	        	    {
            			    	        	        alt171 = 1;
            			    	        	    }


            			    	        	    switch (alt171) 
            			    	        		{
            			    	        			case 1 :
            			    	        			    // JavaScript.g:284:27: LT
            			    	        			    {
            			    	        			    	LT328=(IToken)Match(input,LT,FOLLOW_LT_in_relationalExpression2526); if (state.failed) return retval;

            			    	        			    }
            			    	        			    break;

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

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

            			    	        	PushFollow(FOLLOW_shiftExpression_in_relationalExpression2530);
            			    	        	shiftExpression329 = shiftExpression();
            			    	        	state.followingStackPointer--;
            			    	        	if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, shiftExpression329.Tree);

            			    	        }
            			    	        break;
            			    	    case 2 :
            			    	        // JavaScript.g:285:6: '>' ( LT )* shiftExpression
            			    	        {
            			    	        	char_literal330=(IToken)Match(input,92,FOLLOW_92_in_relationalExpression2538); if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 )
            			    	        	{char_literal330_tree = new GreaterThanNode(char_literal330) ;
            			    	        		root_0 = (object)adaptor.BecomeRoot(char_literal330_tree, root_0);
            			    	        	}
            			    	        	// JavaScript.g:285:30: ( LT )*
            			    	        	do 
            			    	        	{
            			    	        	    int alt172 = 2;
            			    	        	    int LA172_0 = input.LA(1);

            			    	        	    if ( (LA172_0 == LT) )
            			    	        	    {
            			    	        	        alt172 = 1;
            			    	        	    }


            			    	        	    switch (alt172) 
            			    	        		{
            			    	        			case 1 :
            			    	        			    // JavaScript.g:285:30: LT
            			    	        			    {
            			    	        			    	LT331=(IToken)Match(input,LT,FOLLOW_LT_in_relationalExpression2544); if (state.failed) return retval;

            			    	        			    }
            			    	        			    break;

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

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

            			    	        	PushFollow(FOLLOW_shiftExpression_in_relationalExpression2548);
            			    	        	shiftExpression332 = shiftExpression();
            			    	        	state.followingStackPointer--;
            			    	        	if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, shiftExpression332.Tree);

            			    	        }
            			    	        break;
            			    	    case 3 :
            			    	        // JavaScript.g:286:6: '<=' ( LT )* shiftExpression
            			    	        {
            			    	        	string_literal333=(IToken)Match(input,93,FOLLOW_93_in_relationalExpression2556); if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 )
            			    	        	{string_literal333_tree = new LessThanEqNode(string_literal333) ;
            			    	        		root_0 = (object)adaptor.BecomeRoot(string_literal333_tree, root_0);
            			    	        	}
            			    	        	// JavaScript.g:286:30: ( LT )*
            			    	        	do 
            			    	        	{
            			    	        	    int alt173 = 2;
            			    	        	    int LA173_0 = input.LA(1);

            			    	        	    if ( (LA173_0 == LT) )
            			    	        	    {
            			    	        	        alt173 = 1;
            			    	        	    }


            			    	        	    switch (alt173) 
            			    	        		{
            			    	        			case 1 :
            			    	        			    // JavaScript.g:286:30: LT
            			    	        			    {
            			    	        			    	LT334=(IToken)Match(input,LT,FOLLOW_LT_in_relationalExpression2562); if (state.failed) return retval;

            			    	        			    }
            			    	        			    break;

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

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

            			    	        	PushFollow(FOLLOW_shiftExpression_in_relationalExpression2566);
            			    	        	shiftExpression335 = shiftExpression();
            			    	        	state.followingStackPointer--;
            			    	        	if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, shiftExpression335.Tree);

            			    	        }
            			    	        break;
            			    	    case 4 :
            			    	        // JavaScript.g:287:6: '>=' ( LT )* shiftExpression
            			    	        {
            			    	        	string_literal336=(IToken)Match(input,94,FOLLOW_94_in_relationalExpression2574); if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 )
            			    	        	{string_literal336_tree = new GreaterThanEqNode(string_literal336) ;
            			    	        		root_0 = (object)adaptor.BecomeRoot(string_literal336_tree, root_0);
            			    	        	}
            			    	        	// JavaScript.g:287:33: ( LT )*
            			    	        	do 
            			    	        	{
            			    	        	    int alt174 = 2;
            			    	        	    int LA174_0 = input.LA(1);

            			    	        	    if ( (LA174_0 == LT) )
            			    	        	    {
            			    	        	        alt174 = 1;
            			    	        	    }


            			    	        	    switch (alt174) 
            			    	        		{
            			    	        			case 1 :
            			    	        			    // JavaScript.g:287:33: LT
            			    	        			    {
            			    	        			    	LT337=(IToken)Match(input,LT,FOLLOW_LT_in_relationalExpression2580); if (state.failed) return retval;

            			    	        			    }
            			    	        			    break;

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

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

            			    	        	PushFollow(FOLLOW_shiftExpression_in_relationalExpression2584);
            			    	        	shiftExpression338 = shiftExpression();
            			    	        	state.followingStackPointer--;
            			    	        	if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, shiftExpression338.Tree);

            			    	        }
            			    	        break;
            			    	    case 5 :
            			    	        // JavaScript.g:288:6: 'instanceof' ( LT )* shiftExpression
            			    	        {
            			    	        	string_literal339=(IToken)Match(input,95,FOLLOW_95_in_relationalExpression2592); if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 )
            			    	        	{string_literal339_tree = new InstanceOfNode(string_literal339) ;
            			    	        		root_0 = (object)adaptor.BecomeRoot(string_literal339_tree, root_0);
            			    	        	}
            			    	        	// JavaScript.g:288:38: ( LT )*
            			    	        	do 
            			    	        	{
            			    	        	    int alt175 = 2;
            			    	        	    int LA175_0 = input.LA(1);

            			    	        	    if ( (LA175_0 == LT) )
            			    	        	    {
            			    	        	        alt175 = 1;
            			    	        	    }


            			    	        	    switch (alt175) 
            			    	        		{
            			    	        			case 1 :
            			    	        			    // JavaScript.g:288:38: LT
            			    	        			    {
            			    	        			    	LT340=(IToken)Match(input,LT,FOLLOW_LT_in_relationalExpression2598); if (state.failed) return retval;

            			    	        			    }
            			    	        			    break;

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

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

            			    	        	PushFollow(FOLLOW_shiftExpression_in_relationalExpression2602);
            			    	        	shiftExpression341 = shiftExpression();
            			    	        	state.followingStackPointer--;
            			    	        	if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, shiftExpression341.Tree);

            			    	        }
            			    	        break;
            			    	    case 6 :
            			    	        // JavaScript.g:289:6: 'in' ( LT )* shiftExpression
            			    	        {
            			    	        	string_literal342=(IToken)Match(input,53,FOLLOW_53_in_relationalExpression2610); if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 )
            			    	        	{string_literal342_tree = new InNode(string_literal342) ;
            			    	        		root_0 = (object)adaptor.BecomeRoot(string_literal342_tree, root_0);
            			    	        	}
            			    	        	// JavaScript.g:289:22: ( LT )*
            			    	        	do 
            			    	        	{
            			    	        	    int alt176 = 2;
            			    	        	    int LA176_0 = input.LA(1);

            			    	        	    if ( (LA176_0 == LT) )
            			    	        	    {
            			    	        	        alt176 = 1;
            			    	        	    }


            			    	        	    switch (alt176) 
            			    	        		{
            			    	        			case 1 :
            			    	        			    // JavaScript.g:289:22: LT
            			    	        			    {
            			    	        			    	LT343=(IToken)Match(input,LT,FOLLOW_LT_in_relationalExpression2616); if (state.failed) return retval;

            			    	        			    }
            			    	        			    break;

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

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

            			    	        	PushFollow(FOLLOW_shiftExpression_in_relationalExpression2620);
            			    	        	shiftExpression344 = shiftExpression();
            			    	        	state.followingStackPointer--;
            			    	        	if (state.failed) return retval;
            			    	        	if ( state.backtracking == 0 ) adaptor.AddChild(root_0, shiftExpression344.Tree);

            			    	        }
            			    	        break;

            			    	}


            			    }
            			    break;

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

            	loop178:
            		;	// Stops C# compiler whining that label 'loop178' 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;
    }
示例#18
0
    // throws RecognitionException [1]
    // $ANTLR end "expr_and"
    // $ANTLR start "expr_comp"
    // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:108:1: expr_comp returns [TigerNode comp] : exp1= expr_pm ( IGUAL i= expr_pm | MAYOR o= expr_pm | MENOR p= expr_pm | DIST e= expr_pm | MENIG r= expr_pm | MAYIG f= expr_pm )* ;
    public TigerNode expr_comp()
    {
        TigerNode comp = null;

        IToken IGUAL4 = null;
        IToken MAYOR5 = null;
        IToken MENOR6 = null;
        IToken DIST7 = null;
        IToken MENIG8 = null;
        IToken MAYIG9 = null;
        TigerNode exp1 = null;

        TigerNode i = null;

        TigerNode o = null;

        TigerNode p = null;

        TigerNode e = null;

        TigerNode r = null;

        TigerNode f = null;

        try
        {
            // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:108:36: (exp1= expr_pm ( IGUAL i= expr_pm | MAYOR o= expr_pm | MENOR p= expr_pm | DIST e= expr_pm | MENIG r= expr_pm | MAYIG f= expr_pm )* )
            // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:108:38: exp1= expr_pm ( IGUAL i= expr_pm | MAYOR o= expr_pm | MENOR p= expr_pm | DIST e= expr_pm | MENIG r= expr_pm | MAYIG f= expr_pm )*
            {
                PushFollow(FOLLOW_expr_pm_in_expr_comp684);
                exp1 = expr_pm();
                state.followingStackPointer--;
                if (state.failed) return comp;
                if ( (state.backtracking==0) )
                {
                  comp = exp1;
                }
                // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:109:28: ( IGUAL i= expr_pm | MAYOR o= expr_pm | MENOR p= expr_pm | DIST e= expr_pm | MENIG r= expr_pm | MAYIG f= expr_pm )*
                do
                {
                    int alt4 = 7;
                    switch ( input.LA(1) )
                    {
                    case IGUAL:
                        {
                        alt4 = 1;
                        }
                        break;
                    case MAYOR:
                        {
                        alt4 = 2;
                        }
                        break;
                    case MENOR:
                        {
                        alt4 = 3;
                        }
                        break;
                    case DIST:
                        {
                        alt4 = 4;
                        }
                        break;
                    case MENIG:
                        {
                        alt4 = 5;
                        }
                        break;
                    case MAYIG:
                        {
                        alt4 = 6;
                        }
                        break;

                    }

                    switch (alt4)
                    {
                        case 1 :
                            // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:109:29: IGUAL i= expr_pm
                            {
                                IGUAL4=(IToken)Match(input,IGUAL,FOLLOW_IGUAL_in_expr_comp742); if (state.failed) return comp;
                                PushFollow(FOLLOW_expr_pm_in_expr_comp746);
                                i = expr_pm();
                                state.followingStackPointer--;
                                if (state.failed) return comp;
                                if ( (state.backtracking==0) )
                                {

                                                                                comp =  new EqualNode(comp, i);
                                                                                comp.Col=IGUAL4.CharPositionInLine;
                                                                                comp.Row = IGUAL4.Line;

                                }

                            }
                            break;
                        case 2 :
                            // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:114:19: MAYOR o= expr_pm
                            {
                                MAYOR5=(IToken)Match(input,MAYOR,FOLLOW_MAYOR_in_expr_comp768); if (state.failed) return comp;
                                PushFollow(FOLLOW_expr_pm_in_expr_comp772);
                                o = expr_pm();
                                state.followingStackPointer--;
                                if (state.failed) return comp;
                                if ( (state.backtracking==0) )
                                {

                                                                                comp =  new GreaterThanNode(comp, o);
                                                                                comp.Col=MAYOR5.CharPositionInLine;
                                                                                comp.Row = MAYOR5.Line;

                                }

                            }
                            break;
                        case 3 :
                            // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:119:28: MENOR p= expr_pm
                            {
                                MENOR6=(IToken)Match(input,MENOR,FOLLOW_MENOR_in_expr_comp805); if (state.failed) return comp;
                                PushFollow(FOLLOW_expr_pm_in_expr_comp809);
                                p = expr_pm();
                                state.followingStackPointer--;
                                if (state.failed) return comp;
                                if ( (state.backtracking==0) )
                                {

                                                                                comp =  new LessThanNode(comp,p);
                                                                                comp.Col=MENOR6.CharPositionInLine;
                                                                                comp.Row = MENOR6.Line;

                                }

                            }
                            break;
                        case 4 :
                            // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:124:28: DIST e= expr_pm
                            {
                                DIST7=(IToken)Match(input,DIST,FOLLOW_DIST_in_expr_comp841); if (state.failed) return comp;
                                PushFollow(FOLLOW_expr_pm_in_expr_comp845);
                                e = expr_pm();
                                state.followingStackPointer--;
                                if (state.failed) return comp;
                                if ( (state.backtracking==0) )
                                {

                                                                                comp =  new DistinctNode(comp, e);
                                                                                comp.Col=DIST7.CharPositionInLine;
                                                                                comp.Row = DIST7.Line;

                                }

                            }
                            break;
                        case 5 :
                            // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:129:28: MENIG r= expr_pm
                            {
                                MENIG8=(IToken)Match(input,MENIG,FOLLOW_MENIG_in_expr_comp879); if (state.failed) return comp;
                                PushFollow(FOLLOW_expr_pm_in_expr_comp883);
                                r = expr_pm();
                                state.followingStackPointer--;
                                if (state.failed) return comp;
                                if ( (state.backtracking==0) )
                                {

                                                                                comp =  new LessEqualThanNode(comp,r);
                                                                                comp.Col=MENIG8.CharPositionInLine;
                                                                                comp.Row = MENIG8.Line;

                                }

                            }
                            break;
                        case 6 :
                            // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:134:28: MAYIG f= expr_pm
                            {
                                MAYIG9=(IToken)Match(input,MAYIG,FOLLOW_MAYIG_in_expr_comp916); if (state.failed) return comp;
                                PushFollow(FOLLOW_expr_pm_in_expr_comp920);
                                f = expr_pm();
                                state.followingStackPointer--;
                                if (state.failed) return comp;
                                if ( (state.backtracking==0) )
                                {

                                                                                comp =  new GreaterEqualThanNode(comp,f);
                                                                                comp.Col=MAYIG9.CharPositionInLine;
                                                                                comp.Row = MAYIG9.Line;

                                }

                            }
                            break;

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

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

            }

        }
        catch (RecognitionException re)
        {
            ReportError(re);
            Recover(input,re);
        }
        finally
        {
        }
        return comp;
    }
 // TODO: ProcessAsVirtualField? Both Solr and Lucene do this
 protected QueryBase VisitGreaterThan(GreaterThanNode node, ElasticQueryMapperState state)
 {
     return(GetSingleTermRangeQuery(node, RangeQueryPropertyNames.GreaterThan));
 }