I am writing a java tool to parse C++ code and extract information. Something similar to ExtractInterface example in the Definitive ANTLR4 reference book.
I am using a listener, so I do not have to explicitly walk through all the child nodes.
I would like to keep extra data with the contexts to the lower level exit rules can pass extra information up to the higher level exit rules.
Is there a good way to do this in Java.
I was thinking if the context instances were created with a factory then we could have casted to our extended versions but the code creates the contextes directly.
I was playing with a decorator design pattern but had trouble since the Context's do not implement interfaces.
Is the best solution to keep a parallel AST or Map from context ot my extra data?
Thanks
Marc