Paul Taele
Paul Taele

Reputation: 51

Issues with running "Test ANTLR rule" on start rule in IntelliJ with ANTLR plugin

I am trying to run a simple grammar file in IntelliJ with the ANTLR v4 grammar plugin on a new computer. I have followed the online steps for installing the plugin in IntelliJ, and the plugin looks like it is installed correctly. I have written simple code in a .g4 grammar file, and clicked the option to generate an ANTLR recognizer on the code. However, when I try to run the grammar file on the start rule by right-clicking the start rule, the option "Test ANTLR rule" is greyed out. When I look at the .g4 file, it does not show the ANTLR "red A" icon, but instead an icon with curly braces for generic files.

I have uninstalled and re-installed IntelliJ twice, uninstalled and in-installed the ANTLR v4 grammar plugin multiple times, and tried to find similar posts of this issue. I have been able to get the ANTLR plugin to work in other computers on the same steps, but it is not working for me this time.

grammar g;

prule: 'hello ' CHAR;

CHAR: 'a'..'z' | ' ' | 'A'..'Z';

After each attempted solution, I expected for the "Test ANTLR rule" option to be available and not greyed out when I right-click the start rule, but each time the option is disabled. Any assistance to be able to run the ANTLR code from the start rule will be really appreciated.

Upvotes: 3

Views: 913

Answers (2)

Yang
Yang

Reputation: 1

right click the file and choose 'override file type', change it to g4. it seems like you've choosen the file type before you download the plugin

Upvotes: 0

Dmitrii Dulaev
Dmitrii Dulaev

Reputation: 11

I had the same issue (Windows 10). Updating IntelliJ to 2019 helped for me.

Upvotes: 1

Related Questions