How can i see the live parse tree using Antlr4 Ide in Eclipse?
Asked Answered
B

2

13

I'm new using Antlr4 but I know that exist a plugin for Eclipse. I have a simple question...After I created the g4 file how can I visualize the live parse tree in order to see the tree of an input expression? Thanks

Balch answered 30/4, 2014 at 13:40 Comment(2)
Eclipse IS an IDE. Do you mean to say that there exists a plugin for Eclipse?Consideration
sorry for the bad explanationBalch
B
-4

Currently there is no provision for viewing live parse tree in ANTLR 4 IDE for Eclipse.

Meanwhile, you can see the parse tree using -gui switch in the command line. It also provides a feature of saving the parse tree as PNG.

Blalock answered 1/5, 2014 at 17:18 Comment(3)
but if I write something specific in the run configuration of eclipse can I generate the parseTree? By the way someone can precisely explain me how to generate this parse tree if I have a project in eclipse? ThanksBalch
If you are familiar with Ant scripts, just write one script to compile all the generated .java files to .class files and then invoke the grun command on the input. The ANTLR4IDE by Edgar Espina will automatically generate the java files by running the antlr4 command.Blalock
This answer is simply incorrect (at this date): there is provision for viewing live parse trees. See the other answer, which gives exact instructionsInhesion
O
26

After installing Antlr4Ide plugin in Eclipse:

  • Window>Show View>Other, Antlr4>Parse tree
  • Activate g4 file
  • Click parsing rule in g4 file, Parse tree now shows active rule above source editor box

In the parse tree view you see a live source editor on the left, with syntax highlighting for your language. When you enter code in your language there, the tree will update on the right. The antlr console shows parsing errors at the same time.

Obverse answered 26/2, 2015 at 11:35 Comment(1)
In eclipse Oxygen I can't "Click parsing rule in g4 file,". My situation is described here #45870963 . Can you help me?Strickler
B
-4

Currently there is no provision for viewing live parse tree in ANTLR 4 IDE for Eclipse.

Meanwhile, you can see the parse tree using -gui switch in the command line. It also provides a feature of saving the parse tree as PNG.

Blalock answered 1/5, 2014 at 17:18 Comment(3)
but if I write something specific in the run configuration of eclipse can I generate the parseTree? By the way someone can precisely explain me how to generate this parse tree if I have a project in eclipse? ThanksBalch
If you are familiar with Ant scripts, just write one script to compile all the generated .java files to .class files and then invoke the grun command on the input. The ANTLR4IDE by Edgar Espina will automatically generate the java files by running the antlr4 command.Blalock
This answer is simply incorrect (at this date): there is provision for viewing live parse trees. See the other answer, which gives exact instructionsInhesion

© 2022 - 2024 — McMap. All rights reserved.