bpo-40334: Add type to the assignment rule in the grammar file (GH-19963)

This commit is contained in:
Lysandros Nikolaou 2020-05-06 21:11:04 +03:00 committed by GitHub
parent b7aa23d29f
commit 999ec9ab6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -82,7 +82,7 @@ compound_stmt[stmt_ty]:
| &'while' while_stmt | &'while' while_stmt
# NOTE: annotated_rhs may start with 'yield'; yield_expr must start with 'yield' # NOTE: annotated_rhs may start with 'yield'; yield_expr must start with 'yield'
assignment: assignment[stmt_ty]:
| a=NAME ':' b=expression c=['=' d=annotated_rhs { d }] { | a=NAME ':' b=expression c=['=' d=annotated_rhs { d }] {
CHECK_VERSION( CHECK_VERSION(
6, 6,

View File

@ -378,7 +378,7 @@ static asdl_seq* statement_newline_rule(Parser *p);
static asdl_seq* simple_stmt_rule(Parser *p); static asdl_seq* simple_stmt_rule(Parser *p);
static stmt_ty small_stmt_rule(Parser *p); static stmt_ty small_stmt_rule(Parser *p);
static stmt_ty compound_stmt_rule(Parser *p); static stmt_ty compound_stmt_rule(Parser *p);
static void *assignment_rule(Parser *p); static stmt_ty assignment_rule(Parser *p);
static AugOperator* augassign_rule(Parser *p); static AugOperator* augassign_rule(Parser *p);
static stmt_ty global_stmt_rule(Parser *p); static stmt_ty global_stmt_rule(Parser *p);
static stmt_ty nonlocal_stmt_rule(Parser *p); static stmt_ty nonlocal_stmt_rule(Parser *p);
@ -1256,7 +1256,7 @@ small_stmt_rule(Parser *p)
int start_col_offset = p->tokens[mark]->col_offset; int start_col_offset = p->tokens[mark]->col_offset;
UNUSED(start_col_offset); // Only used by EXTRA macro UNUSED(start_col_offset); // Only used by EXTRA macro
{ // assignment { // assignment
void *assignment_var; stmt_ty assignment_var;
if ( if (
(assignment_var = assignment_rule(p)) (assignment_var = assignment_rule(p))
) )
@ -1586,13 +1586,13 @@ compound_stmt_rule(Parser *p)
// | ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT? // | ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT?
// | target augassign (yield_expr | star_expressions) // | target augassign (yield_expr | star_expressions)
// | invalid_assignment // | invalid_assignment
static void * static stmt_ty
assignment_rule(Parser *p) assignment_rule(Parser *p)
{ {
if (p->error_indicator) { if (p->error_indicator) {
return NULL; return NULL;
} }
void * res = NULL; stmt_ty res = NULL;
int mark = p->mark; int mark = p->mark;
if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) {
p->error_indicator = 1; p->error_indicator = 1;