I am trying to find a good way to manage state with the hierarchical visitor pattern and ANTLRs autogenerated base visitor class. While the example below is something silly I made up, I believe it helps get the point across about which concepts I would like to address. As an example lets say we have a class: Now note that