Re: [antlr-discussion] How to show all parser rules in the parse tree?

75 views
Skip to first unread message
Message has been deleted

Mike Lischke

unread,
Mar 20, 2018, 12:31:28 PM3/20/18
to antlr-di...@googlegroups.com
NT,

Hi. I am still new with Antlr and working with Antlr4, Eclipse, Java and the AST-class from https://gist.github.com/bkiers/91827bdfa2b97679568c
At the end of section 22 of the tutorial here https://tomassetti.me/antlr-mega-tutorial/?nabw=0#parser-grammars there is written:
"You can easily notice that the element rule is sort of transparent: where you would expect to find it there is always going to be a tag or content."
I am building another grammar, but I think that's my problem. I want to show the "element" rule in my parse tree to have a better understanding about how the parser works and to debug my grammar easier. Do I have to engage with Listener and Visitor - which I have no clue about - or is there another way?

You might want to give Visual Studio Code a try, where you can install my ANTLR4 extension . It supports debugging grammars and prints nice textual and graphical parse trees.

vscode debugging


Message has been deleted

Mike Lischke

unread,
Mar 20, 2018, 2:41:04 PM3/20/18
to antlr-di...@googlegroups.com

> Wow, this looks amazing, thanks Mike! Yes I would like to give it a try.
> The downside of this is that I would have to migrate the connected projects of my antlr project as well.
> All in all this seems to be some more work, especially because I am not familiar with Visual Studio.


You don't have to give up your existing project. Both IDEs can work side-by-side easily. Just point Visual Studio Code to the same folder and open the grammars in it. Everything else happens magically (provided you have Java on your box).

Mike
--
www.soft-gems.net

Reply all
Reply to author
Forward
0 new messages