Exemple #1
0
        void AndTerm(out Expression exp)
        {
            Expression right = null, left = null;

            RelationalTerm(out left);
            exp = left;
            while (la.kind == 29)
            {
                Get();
                RelationalTerm(out right);
                exp = new LogicalBinOpExpression(exp, right, LogicalBinOp.Xor); CopyPos(exp, ((LogicalBinOpExpression)exp).Left, t);
            }
        }
Exemple #2
0
        void OrTerm(out Expression exp)
        {
            Expression right = null, left = null;

            AndTerm(out left);
            exp = left;
            while (la.kind == 28)
            {
                Get();
                AndTerm(out right);
                exp = new LogicalBinOpExpression(exp, right, LogicalBinOp.And); CopyPos(exp, ((LogicalBinOpExpression)exp).Left, t);
            }
        }
        public override void Visit(LogicalBinOpExpression node)
        {
            string op = "";

            if (node.Op == LogicalBinOp.And)
            {
                op = "and";
            }
            else if (node.Op == LogicalBinOp.Or)
            {
                op = "or";
            }
            else if (node.Op == LogicalBinOp.Xor)
            {
                op = "xor";
            }
            List <string> children = PopChildren();

            Return(SurroundWithParens(children[0] + op + children[1], node.ParenCount));
        }
        public override void Visit(LogicalBinOpExpression exp)
        {
            if (exp.Left is Bool && exp.Right is Bool)
            {
                bool result = false, leftVal, rightVal;
                leftVal  = ((Bool)exp.Left).Value;
                rightVal = ((Bool)exp.Right).Value;

                if (exp.Op == LogicalBinOp.And)
                {
                    result = leftVal && rightVal;
                }
                else if (exp.Op == LogicalBinOp.Or)
                {
                    result = leftVal || rightVal;
                }
                else if (exp.Op == LogicalBinOp.Xor)
                {
                    result = leftVal ^ rightVal;
                }
                exp.Parent.Replace(exp, new Bool(result));
            }
        }
 public virtual void Visit(LogicalBinOpExpression node)
 {
 }