public object VisitUnaryExpr(Expr.Unary expr) { var right = Evaluate(expr.Right); switch (expr.Operator.Type) { case TokenType.Minus: CheckNumberOperand(expr.Operator, right); return(-(double)right); case TokenType.Bang: return(!IsTruthy(right)); } return(null); }
public string VisitUnaryExpr(Expr.Unary expr) { return($"{expr.Operator}{expr.Right.Accept(this)}"); }
public string VisitUnaryExpr(Expr.Unary expr) { return(Parenthesize(expr.Operator.Lexeme, expr.Right)); }