Open pasto9 opened 1 year ago
Sorry, I didn't write the port for Python3 yet. I only had time/patience to port the existing targets and add CSharp.
There is no port for the Python3 target. The way to check if a target exists is to look in the desc.xml.
Unfortunately, $parser
is not sufficient either. This is because both the parser object reference and the dereference operator (".", or "->") are target specific. So, this cannot work for Cpp or PHP. But, even considering the rest of the targets, $parser
is insufficient because the APIs between runtimes are so different. The currently "approved/automated" hack is to provide a base class with "transformGrammar.py" file to replace the reference and operator together.
There is a PR in Antlr to allow StringTemplates attribute replacements in actions in a grammar. This is a much cleaner solution to the whole problem.
Nevertheless, ports for specific targets will need to be written still.
Making a PR for the rest of the targets. https://github.com/antlr/grammars-v4/pull/3619
The Python3 port now works. https://github.com/antlr/grammars-v4/pull/3619
Thank you very much for your work. It helps a lot.
I try to use the cpp grammar with the python target. With the latest fix #3603 antlr does not generate proper python code. So I tried to fix it and noticed that the new pureSpecifier implementation has the problem that python does not use the this keyword. Therefore this line in the grammer produces incorrect code in python.
I think this could be fixed if instead of
this.IsPureSpecifierAllowed()
$parser.IsPureSpecifierAllowed()
would be used. This way it should generate correct code for python and c# (only tested this one).I'm new to python and antlr so I hope this is not a stupid suggestion.