An ANTLR4 grammar for Python 3 based on version 3.3.5 of The Python Language Reference.
For examples and unit tests, which consist of parsing all Python source files from Python 3's standard library, see this GitHub repository.
Note that this grammar contains embedded Java code that handles
the insertion of INDENT
and DEDENT
tokens. The embedded code,
located inside the NEWLINE
lexer rule as well as the @lexer::members
section is well documented, so people trying to port this grammar to
another target should not have much difficulty.