Пример #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);
            }

            return(null);
        }
Пример #2
0
 public string visitUnaryExpr(Expr.Unary expr)
 {
     return(parenthesize(expr.operator_.lexeme, expr.right));
 }
Пример #3
0
 public object visitUnaryExpr(Expr.Unary expr)
 {
     resolve(expr.right);
     return(null);
 }