Exemplo n.º 1
0
        public object visitUnaryExpr(Expr.Unary expr)
        {
            object right = Evaluate(expr.right);

            switch (expr.oper.type)
            {
            case TokenType.MINUS:
                CheckNumberOperand(expr.oper, right);
                return(-(double)right);

            case TokenType.BANG:
                return(!IsTruthy(right));
            }

            return(null);            // should be unreachable
        }
Exemplo n.º 2
0
        public Void visitUnaryExpr(Expr.Unary expr)
        {
            Resolve(expr.right);

            return(null);
        }