private Expr Postfix() { Expr expression = Primary(); while (Match(TokenType.MinusMinus, TokenType.PlusPlus)) { expression = new Expr.Postfix(Previous(), expression); } return(expression); }
public object Visit(Expr.Postfix postfix) { object right = Evaluate(postfix.lhs); ValidateNumberOperand(postfix.opp, right); switch (postfix.opp.type) { case TokenType.MinusMinus: right = (double)right - 1; break; case TokenType.PlusPlus: right = (double)right + 1; break; } /// This was made up by me because in the book there is nothing that assigns this value. // Cast to variable type Expr.Variable asVariable = (Expr.Variable)postfix.lhs; // Assign it's value m_Enviroment.Assign(asVariable.name, right); // Return the value. return(right); }
public object Visit(Expr.Postfix _postfix) { return(null); }
string Expr.IVisitor <string> .Visit(Expr.Postfix postfix) { return(Parenthesize(postfix.opp.lexeme, postfix.lhs)); }