Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

start rule: <select from navigator or grammar> in antlr plugin in IntelliJ

I have created simple grammar file in IntelliJ but failing to see any effect of Antlr plugin. When I open file in ANTLR preview, it says

start rule: <select from navigator or grammar>

enter image description here

What is start rule? How to select it from navigator? How to select it from grammar?

like image 576
Dims Avatar asked Apr 07 '16 07:04

Dims


3 Answers

So I haven't found a way to mark permanently one rule as a start rule, however in the right-click context menu for the grammar, there are two options that relate to ANTLR, one of them is 'test rule xyz', that did the job:

antlr context menu items

like image 110
Groostav Avatar answered Oct 11 '22 15:10

Groostav


You need to right-click the specific rule name in the grammar (.g4 file), to have the option of "Test rule " active in the popup context menu.

like image 36
ShaulF Avatar answered Oct 11 '22 14:10

ShaulF


You should paste your "program" (e.g., a Java program/class) in the "Preview" window, not your grammer/rules (e.g., grammer of Java language). Then select the target rule xxx, right click and select "Test Rule xxx". This means you can test any single rule, not only the root rule:

Test root rule "prog" test root rule "prog"

Test rule "stat" Test rule "stat"

like image 4
Leon Avatar answered Oct 11 '22 14:10

Leon