antlr4 icon indicating copy to clipboard operation
antlr4 copied to clipboard

project_LexerBase.js missing from generated files

Open CarbonMan opened this issue 10 months ago • 1 comments

Hi, When I run java org.antlr.v4.Tool -Dlanguage=JavaScript PythonParser.g4

PythonLexer.js is generated, however, it has the line

import PythonLexerBase from './PythonLexerBase.js';

but PythonLexerBase.js does not exist

I am using antlr-4.13.2-complete.jar

CarbonMan avatar Mar 10 '25 11:03 CarbonMan

Antlr4 does not generate base class files. These are written by hand per grammar to implement the Antlr "actions" referenced in the .g4's. You are referring to one of the grammars in https://github.com/antlr/grammars-v4/tree/master/python. Please find the grammar you are using, then look for a "JavaScript/" sub-directory (ever port has a sub-directory named after the port/target) under the grammar you are using. There is the .js file. Copy the file along with all other files in JavaScript/ to the same directory where the .g4's are. If there is a "transformGrammar.py", run "python transformGrammar.py" prior to running the antlr4 tool command (fix-ups may be required for the .g4 for JavaScript).

kaby76 avatar Mar 10 '25 11:03 kaby76