Question

The current TestRig tool of ANTLR4 supports the -gui option to parse the whole input file and display the whole resultant parse tree graphically. Is it possible for us to obtain the parse tree first, modify it and call some APIs to display graphically a subset/subtree of the parse tree.

My input source file is large and the standard parse tree displayed by TestRig is impossible to view. What's more, i want to filter out a lot of irrelevant grammar and focus on verifying those grammar I need to test. But it is difficult to locate a small piece of information from the standard huge parse tree provided by TestRig.

Was it helpful?

Solution

You can call RuleContext.inspect on any non-terminal in the parse tree to view just that subset. In addition, the next version of ANTLR includes a Save to PNG button on the tree GUI that saves the entire tree display even if it doesn't fit on the screen all at once.

Edit: The next version also includes an update to allow you to focus on a subtree if the full tree doesn't fit.

Parse Tree Inspector

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top