I am back looking at Hibernate and Antlr4. In that effort we have started a proof-of-concept to start concretely playing with our grammar and Antlr4. We want to simultaneously look at 2 solutions, one using re-writing and another using decoration. I am working on the re-writing proof (because I honestly completely do not understand the decoration approach).
I have a grammar, and have generated the listeners I need. I have successfully parsed a number of queries, and have passed those trees through multiple listeners. So I have those basics down.
The listener I am working on right now handles explicit from-clause elements (this is a query language parser). There are implicit from-clause elements too, but the key to understanding the query overall is understanding its explicit from-clauses. So what I have this listeber doing at the moment is to build a separate model representing the FromClause and friends. Again, that part works pretty well.
Ultimately what I am thinking is to have this produce a new parse/semantic tree. I am wanting to write a second grammar that describes the structure of that tree solely for the purpose of generating listeners/visitors. Feel free to stop me here if this is not reasonable :) The difficulty I am having is that the generated listeners/visitors are expecting "ParserRuleContext" subclass arguments which because they are subclasses have specific constructor expectations which I am totally unfamiliar with. So assuming this is a valid way to attack this problem, how would I go about manually building this tree of "ParserRuleContext" objects?
Thanks!