public object visitPrefixExpr(Expr.prefix pf) { object value = evaluate(pf.expr); checkNumberOperand(pf.keyword, value); if (pf.keyword.type == TokenType.PLUS_PLUS) { value = ((double)value) + 1.0; } else { value = ((double)value) - 1.0; } if (locals.TryGetValue(pf.expr, out int distance)) { environment.assignAt(distance, new HelperFunctions.GetToken().evaluate(pf.expr), (double)value); //Assign value after change. } else { globals.assignAt(distance, new HelperFunctions.GetToken().evaluate(pf.expr), (double)value); } return(value); }
public object visitPrefixExpr(Expr.prefix pf) //These two functions may need further resolution { resolve(pf.expr); return(null); }
public string visitPrefixExpr(Expr.prefix pf) { return(parenthesize("p" + pf.keyword.lexeme, new Expr[] { pf.expr })); }