]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-41746: Add type information to asdl_seq objects (GH-22223)
authorPablo Galindo <Pablogsal@gmail.com>
Wed, 16 Sep 2020 18:42:00 +0000 (19:42 +0100)
committerGitHub <noreply@github.com>
Wed, 16 Sep 2020 18:42:00 +0000 (19:42 +0100)
commita5634c406767ef694df49b624adf9cfa6c0d9064
treed0fccb7521e88e3528d5265bf0209f1554fd0098
parent5c1b46d897d4c693e2f3ae049d54725dfb09f2dc
bpo-41746: Add type information to asdl_seq objects (GH-22223)

* Add new capability to the PEG parser to type variable assignments. For instance:
```
       | a[asdl_stmt_seq*]=';'.small_stmt+ [';'] NEWLINE { a }
```

* Add new sequence types from the asdl definition (automatically generated)
* Make `asdl_seq` type a generic aliasing pointer type.
* Create a new `asdl_generic_seq` for the generic case using `void*`.
* The old `asdl_seq_GET`/`ast_seq_SET` macros now are typed.
* New `asdl_seq_GET_UNTYPED`/`ast_seq_SET_UNTYPED` macros for dealing with generic sequences.
* Changes all possible `asdl_seq` types to use specific versions everywhere.
22 files changed:
Doc/tools/extensions/peg_highlight.py
Grammar/python.gram
Include/Python-ast.h
Include/asdl.h
Include/ast.h
Parser/asdl_c.py
Parser/parser.c
Parser/pegen.c
Parser/pegen.h
Parser/string_parser.c
Python/Python-ast.c
Python/asdl.c
Python/ast.c
Python/ast_opt.c
Python/ast_unparse.c
Python/compile.c
Python/future.c
Python/symtable.c
Tools/peg_generator/pegen/c_generator.py
Tools/peg_generator/pegen/grammar.py
Tools/peg_generator/pegen/grammar_parser.py
Tools/peg_generator/pegen/metagrammar.gram