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.
This commit is contained in:
Pablo Galindo 2020-09-16 19:42:00 +01:00 committed by GitHub
parent 5c1b46d897
commit a5634c4067
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 1338 additions and 1086 deletions

View file

@ -970,15 +970,15 @@ ExprList_Dealloc(ExprList *l)
l->size = -1;
}
static asdl_seq *
static asdl_expr_seq *
ExprList_Finish(ExprList *l, PyArena *arena)
{
asdl_seq *seq;
asdl_expr_seq *seq;
ExprList_check_invariants(l);
/* Allocate the asdl_seq and copy the expressions in to it. */
seq = _Py_asdl_seq_new(l->size, arena);
seq = _Py_asdl_expr_seq_new(l->size, arena);
if (seq) {
Py_ssize_t i;
for (i = 0; i < l->size; i++) {
@ -1167,7 +1167,7 @@ expr_ty
_PyPegen_FstringParser_Finish(Parser *p, FstringParser *state, Token* first_token,
Token *last_token)
{
asdl_seq *seq;
asdl_expr_seq *seq;
FstringParser_check_invariants(state);