RobEin / ANTLR4-Python-parser-by-PEG

An ANTLR4 Python grammar based on the official PEG grammar

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ANTLR4 parser for Python 3.11.4   License: MIT

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

Related links:

ANTLR 4

ANTLR 4 Documentation

ANTLR 4 Runtime API

Python 3.10 Lexical Analysis

cpython

ANTLR4 parser for Python 3.8

About

An ANTLR4 Python grammar based on the official PEG grammar

License:MIT License


Languages

Language:ANTLR 71.4%Language:Java 25.6%Language:Python 3.0%