Open 0x410c opened 5 years ago
I have the same problem. generated python3 lexer doesn't work.
You have to implement Python base lexer and parser classes similar to C# or Java ones.
Just found this
Unfortunately it's not a simple task of a 1-1 conversion for the base classes, however it's almsot that simple
YOu also need to change the references in the grammars to point to self instead of this
I've pushed a working example of this here: https://github.com/Anoyomouse/Antlr4-Grammar-JavaScript-Py
Because of the nature of the changes i don't think it's a simple case of making a PR and pushing here
@Anoyomouse could you please suggest a pull request with Python files JavaScriptBaseLexer.py, JavaScriptBaseParer.py? I think it's enough.
@KvanTTT I've updated my parser (same repo) and unfortunately it's still not a trivial matter, the translation from Java/C# is not directly compatible with python because of how the rules in the lexer work (the lexer uses this. instead of self.), that being said, it's actually simple enough to transfrom the g4 before running Antlr, and that gives you a working parser (actually tested properly this time)
However, i've done a PR (#1675), but i'm almost totally sure it'll get killed off because of incompatibilities with all the other languages
self explanatory question.
suggest what i can do to fix it?