Antlr 4 : manually creating trees

318 Views Asked by At

I have long been "kicking the tires" on porting my existing query language parser from Antlr 2 to Antlr 4. But as Antlr 4 represents a major deviation from Antlr 2 and Antlr 3 this represents a significant risk as I do not fully know Antlr 4; I am know Antlr 2, and Antlr 3 is close enough to it that I am at least comfortable there. The existing translation (to SQL ultimately) relies on 2 major tenants that are no longer available in Antlr 4: tree walking (tree parsers) and tree re-writing. Basically I had a multi-phase translation where each phase output a slightly more normalized/simplified tree. To an extent I feel some of that is still needed. Perhaps it is simply my unfamiliarity with Antlr 4. But in either case, I simply do not see how I can reasonably to this transformation walking the same original parse tree structure.

So my question is... How can I manually build an Antlr 4 tree? The thought process here is that I would walk the first tree created from Antlr based on my initial grammar and produce a tree that matched what is expected in a second grammar I write just for producing listeners/visitors.

https://groups.google.com/forum/#!topic/antlr-discussion/vBkwCovqHcI

0

There are 0 best solutions below