Georg Brandl | 5b318c0 | 2008-08-03 09:47:27 +0000 | [diff] [blame] | 1 | Full Grammar specification |
| 2 | ========================== |
| 3 | |
Pablo Galindo | 72cabb2 | 2020-07-27 19:20:36 +0100 | [diff] [blame] | 4 | This is the full Python grammar, derived directly from the grammar |
| 5 | used to generate the CPython parser (see :source:`Grammar/python.gram`). |
| 6 | The version here omits details related to code generation and |
| 7 | error recovery. |
Georg Brandl | 5b318c0 | 2008-08-03 09:47:27 +0000 | [diff] [blame] | 8 | |
Pablo Galindo | 72cabb2 | 2020-07-27 19:20:36 +0100 | [diff] [blame] | 9 | The notation is a mixture of `EBNF |
| 10 | <https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form>`_ |
| 11 | and `PEG <https://en.wikipedia.org/wiki/Parsing_expression_grammar>`_. |
| 12 | In particular, ``&`` followed by a symbol, token or parenthesized |
| 13 | group indicates a positive lookahead (i.e., is required to match but |
| 14 | not consumed), while ``!`` indicates a negative lookahead (i.e., is |
| 15 | required _not_ to match). We use the ``|`` separator to mean PEG's |
James Gerity | bcc9579 | 2020-11-30 14:08:26 -0500 | [diff] [blame^] | 16 | "ordered choice" (written as ``/`` in traditional PEG grammars). See |
| 17 | :pep:`617` for more details on the grammar's syntax. |
Pablo Galindo | 72cabb2 | 2020-07-27 19:20:36 +0100 | [diff] [blame] | 18 | |
| 19 | .. literalinclude:: ../../Grammar/python.gram |
| 20 | :language: peg |