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
Tag: visitor-pattern
ANTLR Visitor Implementation For ArrayInitVisitorImpl
I am trying to build a visitor implementation that will convert a string array to unicode. I am using the following grammar: I have gotten as far as this: and I’m not sure how to handle the nested visiting. Any assistance is appreciated. Edit: Thank to help from Bart, I was able to come up with a final solution for
Java visitor pattern instead of instanceof switch
In this question it is said I can use visitor pattern instead of a bunch of instanceofs. Jmg said “If you are not free to change A, B, and C, you could apply the visitor pattern to achieve the same.” As far as I understand I still have to make A, B and C support visitor (have an accept() method,