[antlr-interest] AST's different in ANTLRWORKS and extracted in Java with getTree

Paul McKee paul.mckee at mckeetech.com
Fri Mar 20 08:36:18 PDT 2009


HI All - I hope somebody can help. I'm still pretty new to ANTLR.
I have built a Transact SQL grammar with output option set to AST. This builds the AST by means of re-write rules and default behavior. From this I have also built a tree walker. I have written a Java test rig as per instructions in the book the key statements here are:
Tsql_asperser.sol_statement_return or =parser.sol_statement();

Common Tree to = (Common Tree)or.get Tree(); //get Tree from Parser

CommonTreeNodeStream nodes = new CommonTreeNodeStream(to);

TsqlWalker walker = new TsqlWalker(nodes);

walker.sol_statement();

I have generated the base grammar with no debugging and the tree walker with debugging and run the java test rig and connected successfully with the ANTLRWORKS remote debugger - all this seems fine.

However, the tree that I am getting displayed in the input window for the tree walker looks quite different from the tree that I get displayed in the AST window for the base grammar (i.e. the generator of the AST). Needless to say, I then get a recognition exception in the tree walker.

I haven't posted the grammar here, because it is quite long and involved, and hope that somebody may be able to point me in the right direction. For example, have I more work to do in building the tree, but in that case how does ANTLRWORKS get it right?



Thanks and Regards



Paul McKee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090320/d5f7691c/attachment.html 


More information about the antlr-interest mailing list