// evaluates sub-expression and applies unary operator public object VisitUnaryExpr(Expr.Unary expr) { object right = Evaluate(expr.right); switch (expr.op.type) { case Token.TokenType.Bang: return(!IsTruthy(right)); case Token.TokenType.Minus: return(-(double)right); } // Unreachable. return(null); }
public string VisitUnaryExpr(Expr.Unary expr) { return(Parenthesize(expr.op.lexeme, expr.right)); }
public object VisitUnaryExpr(Expr.Unary expr) { Resolve(expr.right); return(null); }