TomasTourikis
TomasTourikis

Reputation: 13

ANTLR4 parse tree viewer in Eclipse

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.?

Upvotes: 0

Views: 1440

Answers (1)

Sam Harwell
Sam Harwell

Reputation: 99869

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());

Upvotes: 1

Related Questions