I’m learning Visitor using the book. Based on the book example, I developed my own visitor:
My question on this code is: I had to implement:
private BigDecimal finalOut = null;
to maintain the result of the visitor. This is because
visit(ParseTree pt) was finally returning null (I had to override that too).
Let me know if I am doing the correct thing by maintaining state across visitation by using
finalOut, or is there a more elegant way to do things?