PEP 617: Resolve unreferenced footnotes (#3250)

This commit is contained in:
Adam Turner 2023-08-02 18:08:18 +01:00 committed by GitHub
parent 5a77bca05b
commit 8e978d4ac3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 30 deletions

View File

@ -1,7 +1,5 @@
PEP: 617
Title: New PEG parser for CPython
Version: $Revision$
Last-Modified: $Date$
Author: Guido van Rossum <guido@python.org>,
Pablo Galindo <pablogsal@python.org>,
Lysandros Nikolaou <lisandrosnik@gmail.com>
@ -13,6 +11,8 @@ Created: 24-Mar-2020
Python-Version: 3.9
Post-History: 02-Apr-2020
.. highlight:: PEG
========
Overview
========
@ -298,13 +298,13 @@ and "hidden left-recursion" like::
Syntax
------
The grammar consists of a sequence of rules of the form: ::
The grammar consists of a sequence of rules of the form::
rule_name: expression
Optionally, a type can be included right after the rule name, which
specifies the return type of the C or Python function corresponding to
the rule: ::
the rule::
rule_name[return_type]: expression
@ -324,7 +324,7 @@ Python-style comments.
Match e1, then match e2.
::
.. code:: PEG
rule_name: first_rule second_rule
@ -339,7 +339,7 @@ The first alternative can also appear on the line after the rule name
for formatting purposes. In that case, a \| must be used before the
first alternative, like so:
::
.. code:: PEG
rule_name[return_type]:
| first_alt
@ -350,14 +350,14 @@ first alternative, like so:
Match e.
::
.. code:: PEG
rule_name: (e)
A slightly more complex and useful example includes using the grouping
operator together with the repeat operators:
::
.. code:: PEG
rule_name: (e1 e2)*
@ -366,14 +366,14 @@ operator together with the repeat operators:
Optionally match e.
::
.. code:: PEG
rule_name: [e]
A more useful example includes defining that a trailing comma is
optional:
::
.. code:: PEG
rule_name: e (',' e)* [',']
@ -384,7 +384,7 @@ optional:
Match zero or more occurrences of e.
::
.. code:: PEG
rule_name: (e1 e2)*
@ -395,7 +395,7 @@ Match zero or more occurrences of e.
Match one or more occurrences of e.
::
.. code:: PEG
rule_name: (e1 e2)+
@ -406,7 +406,7 @@ Match one or more occurrences of e, separated by s. The generated parse
tree does not include the separator. This is otherwise identical to
``(e (s e)*)``.
::
.. code:: PEG
rule_name: ','.e+
@ -428,7 +428,7 @@ An example taken from the proposed Python grammar specifies that a primary
consists of an atom, which is not followed by a ``.`` or a ``(`` or a
``[``:
::
.. code:: PEG
primary: atom !'.' !'(' !'['
@ -439,7 +439,7 @@ consists of an atom, which is not followed by a ``.`` or a ``(`` or a
Commit to the current alternative, even if it fails to parse.
::
.. code:: PEG
rule_name: '(' ~ some_rule ')' | some_alt
@ -451,7 +451,7 @@ Variables in the Grammar
~~~~~~~~~~~~~~~~~~~~~~~~
A subexpression can be named by preceding it with an identifier and an
``=`` sign. The name can then be used in the action (see below), like this: ::
``=`` sign. The name can then be used in the action (see below), like this::
rule_name[return_type]: '(' a=some_other_rule ')' { a }
@ -496,7 +496,7 @@ with all the parsed expressions gets returned (this is meant for debugging).
The full meta-grammar for the grammars supported by the PEG generator is:
::
.. code:: PEG
start[Grammar]: grammar ENDMARKER { grammar }
@ -589,7 +589,7 @@ As an illustrative example this simple grammar file allows directly
generating a full parser that can parse simple arithmetic expressions and that
returns a valid C-based Python AST:
::
.. code:: PEG
start[mod_ty]: a=expr_stmt* $ { Module(a, NULL, p->arena) }
expr_stmt[stmt_ty]: a=expr NEWLINE { _Py_Expr(a, EXTRA) }
@ -619,7 +619,7 @@ for the parser.
A similar grammar written to target Python AST objects:
::
.. code:: PEG
start: expr NEWLINE? ENDMARKER { ast.Expression(expr) }
expr:
@ -787,17 +787,16 @@ References
==========
.. [1] Ford, Bryan
http://pdos.csail.mit.edu/~baford/packrat/thesis
https://pdos.csail.mit.edu/~baford/packrat/thesis/
.. [2] Medeiros et al.
https://arxiv.org/pdf/1207.0443.pdf
.. [3] Warth et al.
http://web.cs.ucla.edu/~todd/research/pepm08.pdf
https://web.cs.ucla.edu/~todd/research/pepm08.pdf
.. [#GUIDO_PEG]
Guido's series on PEG parsing
https://medium.com/@gvanrossum_83706/peg-parsing-series-de5d41b2ed60
[4] Guido's series on PEG parsing
\ https://medium.com/@gvanrossum_83706/peg-parsing-series-de5d41b2ed60
=========
Copyright