public object VisitUnary(Expression.Unary expression) { var right = Evaluate(expression.Right); switch (expression.Operator.Type) { case TokenType.Minus: CheckNumberOperand(expression.Operator, right); return(-(double)right); case TokenType.Bang: return(!IsTruthy(right)); } // unreachable. return(null); }
public string VisitUnary(Expression.Unary expression) { return(Parenthesize(expression.Operator.Lexeme, expression.Right)); }