blob: acf83765b5796cc8883e66a70cdfb81f0e7698db [file] [log] [blame]
Georg Brandl5b318c02008-08-03 09:47:27 +00001Full Grammar specification
2==========================
3
Guido van Rossume6b2d932020-07-27 12:00:42 -07004This is the full Python grammar, derived directly from the grammar
5used to generate the CPython parser (see :source:`Grammar/python.gram`).
6The version here omits details related to code generation and
7error recovery.
Georg Brandl5b318c02008-08-03 09:47:27 +00008
Guido van Rossume6b2d932020-07-27 12:00:42 -07009The notation is a mixture of `EBNF
10<https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form>`_
11and `PEG <https://en.wikipedia.org/wiki/Parsing_expression_grammar>`_.
12In particular, ``&`` followed by a symbol, token or parenthesized
13group indicates a positive lookahead (i.e., is required to match but
14not consumed), while ``!`` indicates a negative lookahead (i.e., is
15required _not_ to match). We use the ``|`` separator to mean PEG's
16"ordered choice" (written as ``/`` in traditional PEG grammars).
17
18.. literalinclude:: ../../Grammar/python.gram
19 :language: peg