Вопрос

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.

Это было полезно?

Решение

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top