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.

Answer

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]