PEP 617: Grammar (#2029)

This commit is contained in:
Борис Верховский 2021-07-10 09:40:22 -06:00 committed by GitHub
parent f6c6e24976
commit c40101bad1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -158,7 +158,7 @@ machinery in CPython that motivates the need for a new parser.
Some rules are not actually LL(1) Some rules are not actually LL(1)
--------------------------------- ---------------------------------
Although the Python grammar is technically an LL(1) grammar (because is parsed by Although the Python grammar is technically an LL(1) grammar (because it is parsed by
an LL(1) parser) several rules are not LL(1) and several workarounds are an LL(1) parser) several rules are not LL(1) and several workarounds are
implemented in the grammar and in other parts of CPython to deal with this. For implemented in the grammar and in other parts of CPython to deal with this. For
example, consider the rule for assignment expressions:: example, consider the rule for assignment expressions::
@ -472,7 +472,7 @@ that parses grammar files is bootstrapped from a meta-grammar file with
Python actions that generate the grammar tree as a result of the parsing. Python actions that generate the grammar tree as a result of the parsing.
In the specific case of the new proposed PEG grammar for Python, having In the specific case of the new proposed PEG grammar for Python, having
actions allows to directly describe how the AST is composed in the grammar actions allows directly describing how the AST is composed in the grammar
itself, making it more clear and maintainable. This AST generation process is itself, making it more clear and maintainable. This AST generation process is
supported by the use of some helper functions that factor out common AST supported by the use of some helper functions that factor out common AST
object manipulations and some other required operations that are not directly object manipulations and some other required operations that are not directly
@ -585,8 +585,8 @@ The full meta-grammar for the grammars supported by the PEG generator is:
| "?" { "?" } | "?" { "?" }
| ":" { ":" } | ":" { ":" }
As an illustrative example this simple grammar file allows to directly As an illustrative example this simple grammar file allows directly
generate a full parser that can parse simple arithmetic expressions and that generating a full parser that can parse simple arithmetic expressions and that
returns a valid C-based Python AST: returns a valid C-based Python AST:
:: ::