I was trying to implement ANTLR4 for a project that i'm working on and I created a Python3 parser for JavaScript by using the ANTLR4 tool. The problem is that when I try to run the code, the following error is raised: TypeError: Assignment to constant variable.
TypeError: Assignment to constant variable.
The piece of code is the following: Assignment
let old_lexer = Python3Lexer;
Python3Lexer = function () {
old_lexer.apply(this, arguments);
this.reset.call(this);
}
Python3Lexer is a class.
I am using ANTLR 4.9.2 and ECMAScript 5.1 (but I don't really know if this one is running, maybe it is the default version).
I don't really understand what does that assignment mean and also I don't really know if it can be written on some other way.
Thanks in advance.
Using ANTLR 4.9.x, the JavaScript target generates EcmaScript 6 source code and must be transpiled to EcmaScript 5 (Documentation for the JavaScript target recommends using WebPack and has instructions for using it.) The JavaScript runtime has a webpack.config.js to help out. This is necessary for output that will run under an EcmaScript 5.x runtime. (class, let, etc. are all ES6 specific).