Debian Codegraph @

Doc/reference/grammar.rst

raw
1 .. _full-grammar-specification:
2
3 Full Grammar specification
4 ==========================
5
6 This is the full Python grammar, derived directly from the grammar
7 used to generate the CPython parser (see :source:`Grammar/python.gram`).
8 The version here omits details related to code generation and
9 error recovery.
10
11 The notation is a mixture of `EBNF
12 <https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form>`_
13 and `PEG <https://en.wikipedia.org/wiki/Parsing_expression_grammar>`_.
14 In particular, ``&`` followed by a symbol, token or parenthesized
15 group indicates a positive lookahead (i.e., is required to match but
16 not consumed), while ``!`` indicates a negative lookahead (i.e., is
17 required *not* to match). We use the ``|`` separator to mean PEG's
18 "ordered choice" (written as ``/`` in traditional PEG grammars). See
19 :pep:`617` for more details on the grammar's syntax.
20
21 .. literalinclude:: ../../Grammar/python.gram
22 :language: peg