public object Visit(Expr.Prefix prefix) { object right = Evaluate(prefix.rhs); switch (prefix.opp.type) { case TokenType.Bang: return(!IsTrue(right)); case TokenType.Minus: ValidateNumberOperand(prefix.opp, right); return(-(double)right); case TokenType.MinusMinus: ValidateNumberOperand(prefix.opp, right); return((double)right - 1); case TokenType.PlusPlus: ValidateNumberOperand(prefix.opp, right); return((double)right + 1); } // Unreachable return(null); }
public object Visit(Expr.Prefix _prefix) { return(null); }
string Expr.IVisitor <string> .Visit(Expr.Prefix prefix) { return(Parenthesize(prefix.opp.lexeme, prefix.rhs)); }