示例#1
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");
            }
        }