0
votes

Trying to view specific portions of the parse tree inside of methods generated by ANTLR4 inside Eclipse Kepler Release. For instance ANTLR generates an 'enter/exit' method for a grammar rule created called FunctionDefinition.

Inside the FunctionDefinition method I'm able to getText from the child nodes inside context. Is there a way to graphically represent this context and it's child nodes, via a plugin etc.?

1

1 Answers

1
votes

The FunctionDefinitionContext object returned from the parser extends RuleContext, so you can call inspect() on the object to view the result graphically.

FunctionDefinitionContext ctx = parser.functionDefinition();
Future<JDialog> futureDialog = ctx.inspect(Arrays.asList(parser.getRuleNames()));
// wait for the dialog to close (if you want)
Utils.waitForClose(futureDialog.get());