public static InterpreterResult Or(InterpreterResult left, InterpreterResult right)
        {
            var result        = left.Result || right.Result;
            var isAlwaysFalse = (bool?)null;

            if (left.IsAlwaysFalse.HasValue && right.IsAlwaysFalse.HasValue)
            {
                isAlwaysFalse = left.IsAlwaysFalse.Value && right.IsAlwaysFalse.Value;
            }

            return(new InterpreterResult(result, isAlwaysFalse));
        }
Ejemplo n.º 2
0
        public InterpreterResult VisitBinaryOperatorNode(BinaryOperatorNode node)
        {
            switch (node.Op.Type)
            {
            case TokenType.And:
                return(InterpreterResult.And(Visit(node.Left) as InterpreterResult, Visit(node.Right) as InterpreterResult));

            case TokenType.Or:
                return(InterpreterResult.Or(Visit(node.Left) as InterpreterResult, Visit(node.Right) as InterpreterResult));

            case TokenType.LargerThan:
                return(new InterpreterResult((decimal)Visit(node.Left) > (decimal)Visit(node.Right), null));

            case TokenType.SmallerThan:
                return(new InterpreterResult((decimal)Visit(node.Left) < (decimal)Visit(node.Right), null));

            default:
                throw new InvalidSyntaxException("Error syntax");
            }
        }