Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 996 Bytes

File metadata and controls

24 lines (19 loc) · 996 Bytes

Full Grammar specification

This is the full Python grammar, derived directly from the grammar used to generate the CPython parser (see :source:`Grammar/python.gram`). The version here omits details related to code generation and error recovery.

The notation is a mixture of EBNF and PEG. In particular, & followed by a symbol, token or parenthesized group indicates a positive lookahead (i.e., is required to match but not consumed), while ! indicates a negative lookahead (i.e., is required not to match). We use the | separator to mean PEG's "ordered choice" (written as / in traditional PEG grammars). See PEP 617 for more details on the grammar's syntax.

.. only:: html or latex or epub or text or texinfo

   .. literalinclude:: ../../Grammar/python.gram
     :language: peg