ANTLR4 parser for Python 3.11.4
About files:
-
PythonParser.g4 is the ANTLR4 parser grammar that based on the official Python PEG grammar.
-
PythonLexerBase.java handles the Python indentations. This class also can be used with older ANTLR4 Python grammars. See the instructions in the comments.
-
PythonParserBase.java is a helper class to implement PEG grammar specific expressions in an ANTLR4 parser grammar by semantic predicates.
A simple usage example in command line:
antlr4 PythonLexer.g4
antlr4 PythonParser.g4
javac *.java
grun Python file -tokens test.py
grun Python file -gui test.py
Known issues:
- slow parsing for longer codes