Esempio n. 1
0
        public object visitUnaryExpr(Expr.Unary expr)
        {
            object right = evaluate(expr.right);

            switch (expr.operator_.type)
            {
            case TokenType.BANG:
                return(!isTruthy(right));

            case TokenType.MINUS:
                checkNumberOperand(expr.operator_, right);
                return(-(double)right);
            }

            // Unreachable
            return(null);
        }
Esempio n. 2
0
 public string visitUnaryExpr(Expr.Unary expr)
 {
     return(parenthesize(expr.operator_.lexeme, expr.right));
 }
Esempio n. 3
0
 public object visitUnaryExpr(Expr.Unary expr)
 {
     resolve(expr.right);
     return(null);
 }