Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ANTLR cannot generate Javascript code as of version 4.5

when i try to generate the listener/visitor ... for my Grammar I get the following error : ANTLR cannot generate Javascript code as of version 4.5

Does anybody knows how to fix it? I still can generate C# and Java Code.

like image 726
Bruno Avatar asked Nov 30 '22 10:11

Bruno


2 Answers

I was working with ATNLR to parse hive queries in java and had a similar issue. It turns out that I was missing the case. Instead of Java I was writing java

$>antlr -Dlanguage=java Hplsql.g4 -->error(31): ANTLR cannot generate java code as of version 4.7.1

$>antlr -Dlanguage=Java Hplsql.g4 -->Success

like image 33
Ujjwal Avatar answered Dec 09 '22 16:12

Ujjwal


From the docs:

This is pretty much the same as creating a Java lexer or parser, except you need to specify the language target, for example:

$ antlr4 -Dlanguage=JavaScript MyGrammar.g4

For a full list of antlr4 tool options, please visit the tool documentation page.

It is possible that you are targeting Javascript instead of the required JavaScript (note the case); observe the difference when I execute the two:

╭─{ yaauie@celeborn:~/Desktop/tmp-20160108 }
╰─○ antlr4 -Dlanguage=JavaScript Hello.g4
[success]

╭─{ yaauie@celeborn:~/Desktop/tmp-20160108 }
╰─○ antlr4 -Dlanguage=Javascript Hello.g4
error(31):  ANTLR cannot generate Javascript code as of version 4.5.1
[error: 1]
like image 55
Ry Biesemeyer Avatar answered Dec 09 '22 18:12

Ry Biesemeyer