• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Full Grammar specification
2==========================
3
4This 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.
8
9The 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
20