public override void Visit(RelationalBinOpExpression node)
        {
            string op = "";

            if (node.Op == RelationalBinOp.Equal)
            {
                op = "=";
            }
            else if (node.Op == RelationalBinOp.GreaterThan)
            {
                op = ">";
            }
            else if (node.Op == RelationalBinOp.GreaterThanOrEqual)
            {
                op = ">=";
            }
            else if (node.Op == RelationalBinOp.LessThan)
            {
                op = "<";
            }
            else if (node.Op == RelationalBinOp.LessThanOrEqual)
            {
                op = "<=";
            }
            else if (node.Op == RelationalBinOp.NotEqual)
            {
                op = "!=";
            }
            List <string> children = PopChildren();

            Return(SurroundWithParens(children[0] + op + children[1], node.ParenCount));
        }
示例#2
0
        void RelationalTerm(out Expression exp)
        {
            Expression right = null, left = null; RelationalBinOp op = RelationalBinOp.Equal;

            ArithmeticExpression(out left);
            exp = left;
            if (StartOf(3))
            {
                switch (la.kind)
                {
                case 30: {
                    Get();
                    op = RelationalBinOp.Equal;
                    break;
                }

                case 31: {
                    Get();
                    op = RelationalBinOp.NotEqual;
                    break;
                }

                case 32: {
                    Get();
                    op = RelationalBinOp.GreaterThan;
                    break;
                }

                case 33: {
                    Get();
                    op = RelationalBinOp.GreaterThanOrEqual;
                    break;
                }

                case 34: {
                    Get();
                    op = RelationalBinOp.LessThan;
                    break;
                }

                case 35: {
                    Get();
                    op = RelationalBinOp.LessThanOrEqual;
                    break;
                }
                }
                ArithmeticExpression(out right);
                exp = new RelationalBinOpExpression(exp, right, op); CopyPos(exp, ((RelationalBinOpExpression)exp).Left, t);
            }
        }
        public override void Visit(RelationalBinOpExpression exp)
        {
            if (exp.Left is Number && exp.Right is Number)
            {
                bool result = false;
                int  leftVal, rightVal;
                leftVal  = ((Number)exp.Left).Value;
                rightVal = ((Number)exp.Right).Value;

                if (exp.Op == RelationalBinOp.Equal)
                {
                    result = rightVal == leftVal;
                }
                else if (exp.Op == RelationalBinOp.GreaterThan)
                {
                    result = leftVal > rightVal;
                }
                else if (exp.Op == RelationalBinOp.GreaterThanOrEqual)
                {
                    result = leftVal >= rightVal;
                }
                else if (exp.Op == RelationalBinOp.LessThan)
                {
                    result = leftVal < rightVal;
                }
                else if (exp.Op == RelationalBinOp.LessThanOrEqual)
                {
                    result = leftVal <= rightVal;
                }
                else if (exp.Op == RelationalBinOp.NotEqual)
                {
                    result = leftVal != rightVal;
                }
                exp.Parent.Replace(exp, new Bool(result));
            }
        }
 public virtual void Visit(RelationalBinOpExpression node)
 {
 }