mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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:
parent
5c1b46d897
commit
a5634c4067
22 changed files with 1338 additions and 1086 deletions
|
@ -117,7 +117,7 @@ static int
|
|||
append_ast_boolop(_PyUnicodeWriter *writer, expr_ty e, int level)
|
||||
{
|
||||
Py_ssize_t i, value_count;
|
||||
asdl_seq *values;
|
||||
asdl_expr_seq *values;
|
||||
const char *op = (e->v.BoolOp.op == And) ? " and " : " or ";
|
||||
int pr = (e->v.BoolOp.op == And) ? PR_AND : PR_OR;
|
||||
|
||||
|
@ -398,7 +398,7 @@ append_ast_comprehension(_PyUnicodeWriter *writer, comprehension_ty gen)
|
|||
}
|
||||
|
||||
static int
|
||||
append_ast_comprehensions(_PyUnicodeWriter *writer, asdl_seq *comprehensions)
|
||||
append_ast_comprehensions(_PyUnicodeWriter *writer, asdl_comprehension_seq *comprehensions)
|
||||
{
|
||||
Py_ssize_t i, gen_count;
|
||||
gen_count = asdl_seq_LEN(comprehensions);
|
||||
|
@ -453,7 +453,7 @@ append_ast_compare(_PyUnicodeWriter *writer, expr_ty e, int level)
|
|||
{
|
||||
const char *op;
|
||||
Py_ssize_t i, comparator_count;
|
||||
asdl_seq *comparators;
|
||||
asdl_expr_seq *comparators;
|
||||
asdl_int_seq *ops;
|
||||
|
||||
APPEND_STR_IF(level > PR_CMP, "(");
|
||||
|
@ -612,7 +612,7 @@ append_fstring_element(_PyUnicodeWriter *writer, expr_ty e, bool is_format_spec)
|
|||
/* Build body separately to enable wrapping the entire stream of Strs,
|
||||
Constants and FormattedValues in one opening and one closing quote. */
|
||||
static PyObject *
|
||||
build_fstring_body(asdl_seq *values, bool is_format_spec)
|
||||
build_fstring_body(asdl_expr_seq *values, bool is_format_spec)
|
||||
{
|
||||
Py_ssize_t i, value_count;
|
||||
_PyUnicodeWriter body_writer;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue