예제 #1
0
        public object VisitUnaryExpr(Expr.Unary expr)
        {
            object right = Evaluate(expr.right);

            switch (expr.oper.Type)
            {
            case TokenType.BANG:
                return(!IsTruthy(right));

            case TokenType.MINUS:
                CheckNumberOperand(expr.oper, right);
                return(-(float)right);
            }

            // Unreachable.
            return(null);
        }
예제 #2
0
        public Void VisitUnaryExpr(Expr.Unary expr)
        {
            Resolve(expr.right);

            return(null);
        }