I need to implement generics with Antlr4. In order to do this, I need to be able to take a class and, as it is used, dynamically generate code for it like a macro, tokenize that code, generate a tree, and then add that new tree to my original parse tree.
I saw these two classes
http://www.antlr.org/api/JavaTool/org/antlr/v4/runtime/RuleContext.html
http://www.antlr.org/api/JavaTool/org/antlr/v4/runtime/ParserRuleContext.html
However, I'm not sure what they actually do, nor am I sure how to use the constructor.
ParserRuleContext(ParserRuleContext parent, int invokingStateNumber)
RuleContext(RuleContext parent, int invokingState)
Specifically, are these the classes that will represent the new tree, and what should I pass into invokingState/invokingStateNumber?