From abbd4016adca88a9ebebfc62910d07647df14d29 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 16 Apr 2017 11:07:12 -0700 Subject: [PATCH 01/26] make async and await real keywords --- Grammar/Grammar | 23 +- Include/graminit.h | 41 +-- Include/token.h | 12 +- Parser/tokenizer.c | 63 ---- Parser/tokenizer.h | 7 - Python/ast.c | 83 +++-- Python/graminit.c | 777 ++++++++++++++++++++++++--------------------- 7 files changed, 508 insertions(+), 498 deletions(-) diff --git a/Grammar/Grammar b/Grammar/Grammar index 90582434beef89..ed52842ae8f231 100644 --- a/Grammar/Grammar +++ b/Grammar/Grammar @@ -16,7 +16,7 @@ decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE decorators: decorator+ decorated: decorators (classdef | funcdef | async_funcdef) -async_funcdef: ASYNC funcdef +async_funcdef: 'async' funcdef funcdef: 'def' NAME parameters ['->' test] ':' suite parameters: '(' [typedargslist] ')' @@ -68,7 +68,7 @@ nonlocal_stmt: 'nonlocal' NAME (',' NAME)* assert_stmt: 'assert' test [',' test] compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated | async_stmt -async_stmt: ASYNC (funcdef | with_stmt | for_stmt) +async_stmt: 'async' (funcdef | with_stmt | for_stmt) if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] while_stmt: 'while' test ':' suite ['else' ':' suite] for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] @@ -102,13 +102,14 @@ shift_expr: arith_expr (('<<'|'>>') arith_expr)* arith_expr: term (('+'|'-') term)* term: factor (('*'|'@'|'/'|'%'|'//') factor)* factor: ('+'|'-'|'~') factor | power -power: atom_expr ['**' factor] -atom_expr: [AWAIT] atom trailer* +power: await_expr ['**' factor] +await_expr: 'await' atom_expr | atom_expr +atom_expr: atom trailer* atom: ('(' [yield_expr|testlist_comp] ')' | '[' [testlist_comp] ']' | '{' [dictorsetmaker] '}' | NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False') -testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] ) +testlist_comp: (test|star_expr) ( comp_for | comp_async_for | (',' (test|star_expr))* [','] ) trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME subscriptlist: subscript (',' subscript)* [','] subscript: test | [test] ':' [test] [sliceop] @@ -116,9 +117,9 @@ sliceop: ':' [test] exprlist: (expr|star_expr) (',' (expr|star_expr))* [','] testlist: test (',' test)* [','] dictorsetmaker: ( ((test ':' test | '**' expr) - (comp_for | (',' (test ':' test | '**' expr))* [','])) | + (comp_for | comp_async_for | (',' (test ':' test | '**' expr))* [','])) | ((test | star_expr) - (comp_for | (',' (test | star_expr))* [','])) ) + (comp_for | comp_async_for | (',' (test | star_expr))* [','])) ) classdef: 'class' NAME ['(' [arglist] ')'] ':' suite @@ -133,13 +134,15 @@ arglist: argument (',' argument)* [','] # Illegal combinations and orderings are blocked in ast.c: # multiple (test comp_for) arguments are blocked; keyword unpackings # that precede iterable unpackings are blocked; etc. -argument: ( test [comp_for] | +argument: ( test [comp_for_or_async] | test '=' test | '**' test | '*' test ) -comp_iter: comp_for | comp_if -comp_for: [ASYNC] 'for' exprlist 'in' or_test [comp_iter] +comp_for_or_async: comp_async_for | comp_for +comp_iter: comp_async_for | comp_for | comp_if +comp_async_for: 'async' 'for' exprlist 'in' or_test [comp_iter] +comp_for: 'for' exprlist 'in' or_test [comp_iter] comp_if: 'if' test_nocond [comp_iter] # not used in grammar, but may appear in "node" passed from Parser to Compiler diff --git a/Include/graminit.h b/Include/graminit.h index e9b4a9385956b1..9be336f3f909c8 100644 --- a/Include/graminit.h +++ b/Include/graminit.h @@ -67,22 +67,25 @@ #define term 320 #define factor 321 #define power 322 -#define atom_expr 323 -#define atom 324 -#define testlist_comp 325 -#define trailer 326 -#define subscriptlist 327 -#define subscript 328 -#define sliceop 329 -#define exprlist 330 -#define testlist 331 -#define dictorsetmaker 332 -#define classdef 333 -#define arglist 334 -#define argument 335 -#define comp_iter 336 -#define comp_for 337 -#define comp_if 338 -#define encoding_decl 339 -#define yield_expr 340 -#define yield_arg 341 +#define await_expr 323 +#define atom_expr 324 +#define atom 325 +#define testlist_comp 326 +#define trailer 327 +#define subscriptlist 328 +#define subscript 329 +#define sliceop 330 +#define exprlist 331 +#define testlist 332 +#define dictorsetmaker 333 +#define classdef 334 +#define arglist 335 +#define argument 336 +#define comp_for_or_async 337 +#define comp_iter 338 +#define comp_async_for 339 +#define comp_for 340 +#define comp_if 341 +#define encoding_decl 342 +#define yield_expr 343 +#define yield_arg 344 diff --git a/Include/token.h b/Include/token.h index b28830b8b40387..39a5dd7924db4c 100644 --- a/Include/token.h +++ b/Include/token.h @@ -64,14 +64,12 @@ extern "C" { #define ELLIPSIS 52 /* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */ #define OP 53 -#define AWAIT 54 -#define ASYNC 55 -#define ERRORTOKEN 56 +#define ERRORTOKEN 54 /* These aren't used by the C tokenizer but are needed for tokenize.py */ -#define COMMENT 57 -#define NL 58 -#define ENCODING 59 -#define N_TOKENS 60 +#define COMMENT 55 +#define NL 56 +#define ENCODING 57 +#define N_TOKENS 58 /* Special definitions for cooperation with parser */ diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 51f98e9b2e9213..28254e103318c9 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -103,8 +103,6 @@ const char *_PyParser_TokenNames[] = { "ELLIPSIS", /* This table must match the #defines in token.h! */ "OP", - "AWAIT", - "ASYNC", "", "COMMENT", "NL", @@ -151,10 +149,6 @@ tok_new(void) tok->decoding_buffer = NULL; #endif - tok->async_def = 0; - tok->async_def_indent = 0; - tok->async_def_nl = 0; - return tok; } @@ -1471,21 +1465,6 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end) } } - if (tok->async_def - && !blankline - && tok->level == 0 - /* There was a NEWLINE after ASYNC DEF, - so we're past the signature. */ - && tok->async_def_nl - /* Current indentation level is less than where - the async function was defined */ - && tok->async_def_indent >= tok->indent) - { - tok->async_def = 0; - tok->async_def_indent = 0; - tok->async_def_nl = 0; - } - again: tok->start = NULL; /* Skip spaces */ @@ -1550,43 +1529,6 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end) *p_start = tok->start; *p_end = tok->cur; - /* async/await parsing block. */ - if (tok->cur - tok->start == 5) { - /* Current token length is 5. */ - if (tok->async_def) { - /* We're inside an 'async def' function. */ - if (memcmp(tok->start, "async", 5) == 0) { - return ASYNC; - } - if (memcmp(tok->start, "await", 5) == 0) { - return AWAIT; - } - } - else if (memcmp(tok->start, "async", 5) == 0) { - /* The current token is 'async'. - Look ahead one token.*/ - - struct tok_state ahead_tok; - char *ahead_tok_start = NULL, *ahead_tok_end = NULL; - int ahead_tok_kind; - - memcpy(&ahead_tok, tok, sizeof(ahead_tok)); - ahead_tok_kind = tok_get(&ahead_tok, &ahead_tok_start, - &ahead_tok_end); - - if (ahead_tok_kind == NAME - && ahead_tok.cur - ahead_tok.start == 3 - && memcmp(ahead_tok.start, "def", 3) == 0) - { - /* The next token is going to be 'def', so instead of - returning 'async' NAME token, we return ASYNC. */ - tok->async_def_indent = tok->indent; - tok->async_def = 1; - return ASYNC; - } - } - } - return NAME; } @@ -1599,11 +1541,6 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end) *p_start = tok->start; *p_end = tok->cur - 1; /* Leave '\n' out of the string */ tok->cont_line = 0; - if (tok->async_def) { - /* We're somewhere inside an 'async def' function, and - we've encountered a NEWLINE after its signature. */ - tok->async_def_nl = 1; - } return NEWLINE; } diff --git a/Parser/tokenizer.h b/Parser/tokenizer.h index 0ad3551c8948c1..ad8b1c80171263 100644 --- a/Parser/tokenizer.h +++ b/Parser/tokenizer.h @@ -65,13 +65,6 @@ struct tok_state { const char* enc; /* Encoding for the current str. */ const char* str; const char* input; /* Tokenizer's newline translated copy of the string. */ - - /* async/await related fields; can be removed in 3.7 when async and await - become normal keywords. */ - int async_def; /* =1 if tokens are inside an 'async def' body. */ - int async_def_indent; /* Indentation level of the outermost 'async def'. */ - int async_def_nl; /* =1 if the outermost 'async def' had at least one - NEWLINE token after it. */ }; extern struct tok_state *PyTokenizer_FromString(const char *, int); diff --git a/Python/ast.c b/Python/ast.c index 33356da075669c..5422ffe5e6ffcc 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -1642,9 +1642,9 @@ ast_for_funcdef_impl(struct compiling *c, const node *n, static stmt_ty ast_for_async_funcdef(struct compiling *c, const node *n, asdl_seq *decorator_seq) { - /* async_funcdef: ASYNC funcdef */ + /* async_funcdef: 'async' funcdef */ REQ(n, async_funcdef); - REQ(CHILD(n, 0), ASYNC); + REQ(CHILD(n, 0), NAME); REQ(CHILD(n, 1), funcdef); return ast_for_funcdef_impl(c, CHILD(n, 1), decorator_seq, @@ -1663,9 +1663,9 @@ ast_for_funcdef(struct compiling *c, const node *n, asdl_seq *decorator_seq) static stmt_ty ast_for_async_stmt(struct compiling *c, const node *n) { - /* async_stmt: ASYNC (funcdef | with_stmt | for_stmt) */ + /* async_stmt: 'async' (funcdef | with_stmt | for_stmt) */ REQ(n, async_stmt); - REQ(CHILD(n, 0), ASYNC); + REQ(CHILD(n, 0), NAME); switch (TYPE(CHILD(n, 1))) { case funcdef: @@ -1783,8 +1783,8 @@ count_comp_fors(struct compiling *c, const node *n) count_comp_for: is_async = 0; n_fors++; - REQ(n, comp_for); - if (TYPE(CHILD(n, 0)) == ASYNC) { + assert(TYPE(n) == comp_for || TYPE(n) == comp_async_for); + if (TYPE(n) == comp_async_for) { is_async = 1; } if (NCH(n) == (5 + is_async)) { @@ -1796,7 +1796,7 @@ count_comp_fors(struct compiling *c, const node *n) count_comp_iter: REQ(n, comp_iter); n = CHILD(n, 0); - if (TYPE(n) == comp_for) + if (TYPE(n) == comp_for || TYPE(n) == comp_async_for) goto count_comp_for; else if (TYPE(n) == comp_if) { if (NCH(n) == 3) { @@ -1825,7 +1825,7 @@ count_comp_ifs(struct compiling *c, const node *n) while (1) { REQ(n, comp_iter); - if (TYPE(CHILD(n, 0)) == comp_for) + if (TYPE(CHILD(n, 0)) == comp_for || TYPE(CHILD(n, 0)) == comp_async_for) return n_ifs; n = CHILD(n, 0); REQ(n, comp_if); @@ -1857,9 +1857,9 @@ ast_for_comprehension(struct compiling *c, const node *n) node *for_ch; int is_async = 0; - REQ(n, comp_for); + assert(TYPE(n) == comp_for || TYPE(n) == comp_async_for); - if (TYPE(CHILD(n, 0)) == ASYNC) { + if (TYPE(n) == comp_async_for) { is_async = 1; } @@ -1909,7 +1909,7 @@ ast_for_comprehension(struct compiling *c, const node *n) if (NCH(n) == 3) n = CHILD(n, 2); } - /* on exit, must guarantee that n is a comp_for */ + /* on exit, must guarantee that n is a comp_for or comp_async_for */ if (TYPE(n) == comp_iter) n = CHILD(n, 0); comp->ifs = ifs; @@ -1939,7 +1939,11 @@ ast_for_itercomp(struct compiling *c, const node *n, int type) return NULL; } - comps = ast_for_comprehension(c, CHILD(n, 1)); + ch = CHILD(n, 1); + if (TYPE(ch) == comp_for_or_async) + ch = CHILD(ch, 0); + + comps = ast_for_comprehension(c, ch); if (!comps) return NULL; @@ -2172,7 +2176,7 @@ ast_for_atom(struct compiling *c, const node *n) return ast_for_expr(c, ch); /* testlist_comp: test ( comp_for | (',' test)* [','] ) */ - if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == comp_for)) + if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == comp_for || TYPE(CHILD(ch, 1)) == comp_async_for)) return ast_for_genexp(c, ch); return ast_for_testlist(c, ch); @@ -2212,12 +2216,13 @@ ast_for_atom(struct compiling *c, const node *n) res = ast_for_setdisplay(c, ch); } else if (NCH(ch) > 1 && - TYPE(CHILD(ch, 1)) == comp_for) { + (TYPE(CHILD(ch, 1)) == comp_for || TYPE(CHILD(ch, 1)) == comp_async_for)) { /* It's a set comprehension. */ res = ast_for_setcomp(c, ch); } else if (NCH(ch) > 3 - is_dict && - TYPE(CHILD(ch, 3 - is_dict)) == comp_for) { + (TYPE(CHILD(ch, 3 - is_dict)) == comp_for || + TYPE(CHILD(ch, 3 - is_dict)) == comp_async_for)) { /* It's a dictionary comprehension. */ if (is_dict) { ast_error(c, n, "dict unpacking cannot be used in " @@ -2464,27 +2469,19 @@ ast_for_factor(struct compiling *c, const node *n) static expr_ty ast_for_atom_expr(struct compiling *c, const node *n) { - int i, nch, start = 0; + int i, nch; expr_ty e, tmp; REQ(n, atom_expr); nch = NCH(n); - if (TYPE(CHILD(n, 0)) == AWAIT) { - start = 1; - assert(nch > 1); - } - - e = ast_for_atom(c, CHILD(n, start)); + e = ast_for_atom(c, CHILD(n, 0)); if (!e) return NULL; if (nch == 1) return e; - if (start && nch == 2) { - return Await(e, LINENO(n), n->n_col_offset, c->c_arena); - } - for (i = start + 1; i < nch; i++) { + for (i = 1; i < nch; i++) { node *ch = CHILD(n, i); if (TYPE(ch) != trailer) break; @@ -2496,13 +2493,30 @@ ast_for_atom_expr(struct compiling *c, const node *n) e = tmp; } - if (start) { - /* there was an AWAIT */ - return Await(e, LINENO(n), n->n_col_offset, c->c_arena); + return e; +} + +static expr_ty +ast_for_await_expr(struct compiling* c, const node *n) +{ + int nch, start; + expr_ty e; + + REQ(n, await_expr); + nch = NCH(n); + + if (nch == 2) { + start = 1; + } else { + assert(nch == 1); + start = 0; } - else { + e = ast_for_atom_expr(c, CHILD(n, start)); + if (!e) + return NULL; + if (nch == 1) return e; - } + return Await(e, LINENO(n), n->n_col_offset, c->c_arena); } static expr_ty @@ -2512,7 +2526,7 @@ ast_for_power(struct compiling *c, const node *n) */ expr_ty e; REQ(n, power); - e = ast_for_atom_expr(c, CHILD(n, 0)); + e = ast_for_await_expr(c, CHILD(n, 0)); if (!e) return NULL; if (NCH(n) == 1) @@ -2732,7 +2746,7 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func) if (TYPE(ch) == argument) { if (NCH(ch) == 1) nargs++; - else if (TYPE(CHILD(ch, 1)) == comp_for) + else if (TYPE(CHILD(ch, 1)) == comp_for_or_async) ngens++; else if (TYPE(CHILD(ch, 0)) == STAR) nargs++; @@ -2813,7 +2827,7 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func) asdl_seq_SET(keywords, nkeywords++, kw); ndoublestars++; } - else if (TYPE(CHILD(ch, 1)) == comp_for) { + else if (TYPE(CHILD(ch, 1)) == comp_for_or_async) { /* the lone generator expression */ e = ast_for_genexp(c, ch); if (!e) @@ -2880,6 +2894,7 @@ ast_for_testlist(struct compiling *c, const node* n) if (TYPE(n) == testlist_comp) { if (NCH(n) > 1) assert(TYPE(CHILD(n, 1)) != comp_for); + assert(TYPE(CHILD(n, 1)) != comp_async_for); } else { assert(TYPE(n) == testlist || diff --git a/Python/graminit.c b/Python/graminit.c index f2584e0a2adfa4..5ff3ba6a26a917 100644 --- a/Python/graminit.c +++ b/Python/graminit.c @@ -1440,644 +1440,702 @@ static arc arcs_67_0[2] = { static arc arcs_67_1[1] = { {152, 2}, }; -static arc arcs_67_2[2] = { - {153, 2}, +static arc arcs_67_2[1] = { {0, 2}, }; static state states_67[3] = { {2, arcs_67_0}, {1, arcs_67_1}, - {2, arcs_67_2}, + {1, arcs_67_2}, }; -static arc arcs_68_0[10] = { +static arc arcs_68_0[1] = { + {153, 1}, +}; +static arc arcs_68_1[2] = { + {154, 1}, + {0, 1}, +}; +static state states_68[2] = { + {1, arcs_68_0}, + {2, arcs_68_1}, +}; +static arc arcs_69_0[10] = { {13, 1}, - {155, 2}, - {157, 3}, + {156, 2}, + {158, 3}, {23, 4}, - {160, 4}, - {161, 5}, + {161, 4}, + {162, 5}, {83, 4}, - {162, 4}, {163, 4}, {164, 4}, + {165, 4}, }; -static arc arcs_68_1[3] = { +static arc arcs_69_1[3] = { {50, 6}, - {154, 6}, + {155, 6}, {15, 4}, }; -static arc arcs_68_2[2] = { - {154, 7}, - {156, 4}, +static arc arcs_69_2[2] = { + {155, 7}, + {157, 4}, }; -static arc arcs_68_3[2] = { - {158, 8}, - {159, 4}, +static arc arcs_69_3[2] = { + {159, 8}, + {160, 4}, }; -static arc arcs_68_4[1] = { +static arc arcs_69_4[1] = { {0, 4}, }; -static arc arcs_68_5[2] = { - {161, 5}, +static arc arcs_69_5[2] = { + {162, 5}, {0, 5}, }; -static arc arcs_68_6[1] = { +static arc arcs_69_6[1] = { {15, 4}, }; -static arc arcs_68_7[1] = { - {156, 4}, +static arc arcs_69_7[1] = { + {157, 4}, }; -static arc arcs_68_8[1] = { - {159, 4}, -}; -static state states_68[9] = { - {10, arcs_68_0}, - {3, arcs_68_1}, - {2, arcs_68_2}, - {2, arcs_68_3}, - {1, arcs_68_4}, - {2, arcs_68_5}, - {1, arcs_68_6}, - {1, arcs_68_7}, - {1, arcs_68_8}, +static arc arcs_69_8[1] = { + {160, 4}, }; -static arc arcs_69_0[2] = { +static state states_69[9] = { + {10, arcs_69_0}, + {3, arcs_69_1}, + {2, arcs_69_2}, + {2, arcs_69_3}, + {1, arcs_69_4}, + {2, arcs_69_5}, + {1, arcs_69_6}, + {1, arcs_69_7}, + {1, arcs_69_8}, +}; +static arc arcs_70_0[2] = { {26, 1}, {51, 1}, }; -static arc arcs_69_1[3] = { - {165, 2}, +static arc arcs_70_1[4] = { + {166, 2}, + {167, 2}, {32, 3}, {0, 1}, }; -static arc arcs_69_2[1] = { +static arc arcs_70_2[1] = { {0, 2}, }; -static arc arcs_69_3[3] = { +static arc arcs_70_3[3] = { {26, 4}, {51, 4}, {0, 3}, }; -static arc arcs_69_4[2] = { +static arc arcs_70_4[2] = { {32, 3}, {0, 4}, }; -static state states_69[5] = { - {2, arcs_69_0}, - {3, arcs_69_1}, - {1, arcs_69_2}, - {3, arcs_69_3}, - {2, arcs_69_4}, +static state states_70[5] = { + {2, arcs_70_0}, + {4, arcs_70_1}, + {1, arcs_70_2}, + {3, arcs_70_3}, + {2, arcs_70_4}, }; -static arc arcs_70_0[3] = { +static arc arcs_71_0[3] = { {13, 1}, - {155, 2}, + {156, 2}, {82, 3}, }; -static arc arcs_70_1[2] = { +static arc arcs_71_1[2] = { {14, 4}, {15, 5}, }; -static arc arcs_70_2[1] = { - {166, 6}, +static arc arcs_71_2[1] = { + {168, 6}, }; -static arc arcs_70_3[1] = { +static arc arcs_71_3[1] = { {23, 5}, }; -static arc arcs_70_4[1] = { +static arc arcs_71_4[1] = { {15, 5}, }; -static arc arcs_70_5[1] = { +static arc arcs_71_5[1] = { {0, 5}, }; -static arc arcs_70_6[1] = { - {156, 5}, +static arc arcs_71_6[1] = { + {157, 5}, }; -static state states_70[7] = { - {3, arcs_70_0}, - {2, arcs_70_1}, - {1, arcs_70_2}, - {1, arcs_70_3}, - {1, arcs_70_4}, - {1, arcs_70_5}, - {1, arcs_70_6}, +static state states_71[7] = { + {3, arcs_71_0}, + {2, arcs_71_1}, + {1, arcs_71_2}, + {1, arcs_71_3}, + {1, arcs_71_4}, + {1, arcs_71_5}, + {1, arcs_71_6}, }; -static arc arcs_71_0[1] = { - {167, 1}, +static arc arcs_72_0[1] = { + {169, 1}, }; -static arc arcs_71_1[2] = { +static arc arcs_72_1[2] = { {32, 2}, {0, 1}, }; -static arc arcs_71_2[2] = { - {167, 1}, +static arc arcs_72_2[2] = { + {169, 1}, {0, 2}, }; -static state states_71[3] = { - {1, arcs_71_0}, - {2, arcs_71_1}, - {2, arcs_71_2}, +static state states_72[3] = { + {1, arcs_72_0}, + {2, arcs_72_1}, + {2, arcs_72_2}, }; -static arc arcs_72_0[2] = { +static arc arcs_73_0[2] = { {26, 1}, {27, 2}, }; -static arc arcs_72_1[2] = { +static arc arcs_73_1[2] = { {27, 2}, {0, 1}, }; -static arc arcs_72_2[3] = { +static arc arcs_73_2[3] = { {26, 3}, - {168, 4}, + {170, 4}, {0, 2}, }; -static arc arcs_72_3[2] = { - {168, 4}, +static arc arcs_73_3[2] = { + {170, 4}, {0, 3}, }; -static arc arcs_72_4[1] = { +static arc arcs_73_4[1] = { {0, 4}, }; -static state states_72[5] = { - {2, arcs_72_0}, - {2, arcs_72_1}, - {3, arcs_72_2}, - {2, arcs_72_3}, - {1, arcs_72_4}, +static state states_73[5] = { + {2, arcs_73_0}, + {2, arcs_73_1}, + {3, arcs_73_2}, + {2, arcs_73_3}, + {1, arcs_73_4}, }; -static arc arcs_73_0[1] = { +static arc arcs_74_0[1] = { {27, 1}, }; -static arc arcs_73_1[2] = { +static arc arcs_74_1[2] = { {26, 2}, {0, 1}, }; -static arc arcs_73_2[1] = { +static arc arcs_74_2[1] = { {0, 2}, }; -static state states_73[3] = { - {1, arcs_73_0}, - {2, arcs_73_1}, - {1, arcs_73_2}, +static state states_74[3] = { + {1, arcs_74_0}, + {2, arcs_74_1}, + {1, arcs_74_2}, }; -static arc arcs_74_0[2] = { +static arc arcs_75_0[2] = { {108, 1}, {51, 1}, }; -static arc arcs_74_1[2] = { +static arc arcs_75_1[2] = { {32, 2}, {0, 1}, }; -static arc arcs_74_2[3] = { +static arc arcs_75_2[3] = { {108, 1}, {51, 1}, {0, 2}, }; -static state states_74[3] = { - {2, arcs_74_0}, - {2, arcs_74_1}, - {3, arcs_74_2}, +static state states_75[3] = { + {2, arcs_75_0}, + {2, arcs_75_1}, + {3, arcs_75_2}, }; -static arc arcs_75_0[1] = { +static arc arcs_76_0[1] = { {26, 1}, }; -static arc arcs_75_1[2] = { +static arc arcs_76_1[2] = { {32, 2}, {0, 1}, }; -static arc arcs_75_2[2] = { +static arc arcs_76_2[2] = { {26, 1}, {0, 2}, }; -static state states_75[3] = { - {1, arcs_75_0}, - {2, arcs_75_1}, - {2, arcs_75_2}, +static state states_76[3] = { + {1, arcs_76_0}, + {2, arcs_76_1}, + {2, arcs_76_2}, }; -static arc arcs_76_0[3] = { +static arc arcs_77_0[3] = { {26, 1}, {34, 2}, {51, 3}, }; -static arc arcs_76_1[4] = { +static arc arcs_77_1[5] = { {27, 4}, - {165, 5}, + {166, 5}, + {167, 5}, {32, 6}, {0, 1}, }; -static arc arcs_76_2[1] = { +static arc arcs_77_2[1] = { {108, 7}, }; -static arc arcs_76_3[3] = { - {165, 5}, +static arc arcs_77_3[4] = { + {166, 5}, + {167, 5}, {32, 6}, {0, 3}, }; -static arc arcs_76_4[1] = { +static arc arcs_77_4[1] = { {26, 7}, }; -static arc arcs_76_5[1] = { +static arc arcs_77_5[1] = { {0, 5}, }; -static arc arcs_76_6[3] = { +static arc arcs_77_6[3] = { {26, 8}, {51, 8}, {0, 6}, }; -static arc arcs_76_7[3] = { - {165, 5}, +static arc arcs_77_7[4] = { + {166, 5}, + {167, 5}, {32, 9}, {0, 7}, }; -static arc arcs_76_8[2] = { +static arc arcs_77_8[2] = { {32, 6}, {0, 8}, }; -static arc arcs_76_9[3] = { +static arc arcs_77_9[3] = { {26, 10}, {34, 11}, {0, 9}, }; -static arc arcs_76_10[1] = { +static arc arcs_77_10[1] = { {27, 12}, }; -static arc arcs_76_11[1] = { +static arc arcs_77_11[1] = { {108, 13}, }; -static arc arcs_76_12[1] = { +static arc arcs_77_12[1] = { {26, 13}, }; -static arc arcs_76_13[2] = { +static arc arcs_77_13[2] = { {32, 9}, {0, 13}, }; -static state states_76[14] = { - {3, arcs_76_0}, - {4, arcs_76_1}, - {1, arcs_76_2}, - {3, arcs_76_3}, - {1, arcs_76_4}, - {1, arcs_76_5}, - {3, arcs_76_6}, - {3, arcs_76_7}, - {2, arcs_76_8}, - {3, arcs_76_9}, - {1, arcs_76_10}, - {1, arcs_76_11}, - {1, arcs_76_12}, - {2, arcs_76_13}, -}; -static arc arcs_77_0[1] = { - {169, 1}, +static state states_77[14] = { + {3, arcs_77_0}, + {5, arcs_77_1}, + {1, arcs_77_2}, + {4, arcs_77_3}, + {1, arcs_77_4}, + {1, arcs_77_5}, + {3, arcs_77_6}, + {4, arcs_77_7}, + {2, arcs_77_8}, + {3, arcs_77_9}, + {1, arcs_77_10}, + {1, arcs_77_11}, + {1, arcs_77_12}, + {2, arcs_77_13}, }; -static arc arcs_77_1[1] = { +static arc arcs_78_0[1] = { + {171, 1}, +}; +static arc arcs_78_1[1] = { {23, 2}, }; -static arc arcs_77_2[2] = { +static arc arcs_78_2[2] = { {13, 3}, {27, 4}, }; -static arc arcs_77_3[2] = { +static arc arcs_78_3[2] = { {14, 5}, {15, 6}, }; -static arc arcs_77_4[1] = { +static arc arcs_78_4[1] = { {28, 7}, }; -static arc arcs_77_5[1] = { +static arc arcs_78_5[1] = { {15, 6}, }; -static arc arcs_77_6[1] = { +static arc arcs_78_6[1] = { {27, 4}, }; -static arc arcs_77_7[1] = { +static arc arcs_78_7[1] = { {0, 7}, }; -static state states_77[8] = { - {1, arcs_77_0}, - {1, arcs_77_1}, - {2, arcs_77_2}, - {2, arcs_77_3}, - {1, arcs_77_4}, - {1, arcs_77_5}, - {1, arcs_77_6}, - {1, arcs_77_7}, +static state states_78[8] = { + {1, arcs_78_0}, + {1, arcs_78_1}, + {2, arcs_78_2}, + {2, arcs_78_3}, + {1, arcs_78_4}, + {1, arcs_78_5}, + {1, arcs_78_6}, + {1, arcs_78_7}, }; -static arc arcs_78_0[1] = { - {170, 1}, +static arc arcs_79_0[1] = { + {172, 1}, }; -static arc arcs_78_1[2] = { +static arc arcs_79_1[2] = { {32, 2}, {0, 1}, }; -static arc arcs_78_2[2] = { - {170, 1}, +static arc arcs_79_2[2] = { + {172, 1}, {0, 2}, }; -static state states_78[3] = { - {1, arcs_78_0}, - {2, arcs_78_1}, - {2, arcs_78_2}, +static state states_79[3] = { + {1, arcs_79_0}, + {2, arcs_79_1}, + {2, arcs_79_2}, }; -static arc arcs_79_0[3] = { +static arc arcs_80_0[3] = { {26, 1}, {34, 2}, {33, 2}, }; -static arc arcs_79_1[3] = { - {165, 3}, +static arc arcs_80_1[3] = { + {173, 3}, {31, 2}, {0, 1}, }; -static arc arcs_79_2[1] = { +static arc arcs_80_2[1] = { {26, 3}, }; -static arc arcs_79_3[1] = { +static arc arcs_80_3[1] = { {0, 3}, }; -static state states_79[4] = { - {3, arcs_79_0}, - {3, arcs_79_1}, - {1, arcs_79_2}, - {1, arcs_79_3}, +static state states_80[4] = { + {3, arcs_80_0}, + {3, arcs_80_1}, + {1, arcs_80_2}, + {1, arcs_80_3}, }; -static arc arcs_80_0[2] = { - {165, 1}, - {172, 1}, +static arc arcs_81_0[2] = { + {167, 1}, + {166, 1}, }; -static arc arcs_80_1[1] = { +static arc arcs_81_1[1] = { {0, 1}, }; -static state states_80[2] = { - {2, arcs_80_0}, - {1, arcs_80_1}, +static state states_81[2] = { + {2, arcs_81_0}, + {1, arcs_81_1}, }; -static arc arcs_81_0[2] = { +static arc arcs_82_0[3] = { + {167, 1}, + {166, 1}, + {175, 1}, +}; +static arc arcs_82_1[1] = { + {0, 1}, +}; +static state states_82[2] = { + {3, arcs_82_0}, + {1, arcs_82_1}, +}; +static arc arcs_83_0[1] = { {21, 1}, - {101, 2}, }; -static arc arcs_81_1[1] = { +static arc arcs_83_1[1] = { {101, 2}, }; -static arc arcs_81_2[1] = { +static arc arcs_83_2[1] = { {66, 3}, }; -static arc arcs_81_3[1] = { +static arc arcs_83_3[1] = { {102, 4}, }; -static arc arcs_81_4[1] = { +static arc arcs_83_4[1] = { {112, 5}, }; -static arc arcs_81_5[2] = { - {171, 6}, +static arc arcs_83_5[2] = { + {174, 6}, {0, 5}, }; -static arc arcs_81_6[1] = { +static arc arcs_83_6[1] = { {0, 6}, }; -static state states_81[7] = { - {2, arcs_81_0}, - {1, arcs_81_1}, - {1, arcs_81_2}, - {1, arcs_81_3}, - {1, arcs_81_4}, - {2, arcs_81_5}, - {1, arcs_81_6}, +static state states_83[7] = { + {1, arcs_83_0}, + {1, arcs_83_1}, + {1, arcs_83_2}, + {1, arcs_83_3}, + {1, arcs_83_4}, + {2, arcs_83_5}, + {1, arcs_83_6}, +}; +static arc arcs_84_0[1] = { + {101, 1}, }; -static arc arcs_82_0[1] = { +static arc arcs_84_1[1] = { + {66, 2}, +}; +static arc arcs_84_2[1] = { + {102, 3}, +}; +static arc arcs_84_3[1] = { + {112, 4}, +}; +static arc arcs_84_4[2] = { + {174, 5}, + {0, 4}, +}; +static arc arcs_84_5[1] = { + {0, 5}, +}; +static state states_84[6] = { + {1, arcs_84_0}, + {1, arcs_84_1}, + {1, arcs_84_2}, + {1, arcs_84_3}, + {2, arcs_84_4}, + {1, arcs_84_5}, +}; +static arc arcs_85_0[1] = { {97, 1}, }; -static arc arcs_82_1[1] = { +static arc arcs_85_1[1] = { {114, 2}, }; -static arc arcs_82_2[2] = { - {171, 3}, +static arc arcs_85_2[2] = { + {174, 3}, {0, 2}, }; -static arc arcs_82_3[1] = { +static arc arcs_85_3[1] = { {0, 3}, }; -static state states_82[4] = { - {1, arcs_82_0}, - {1, arcs_82_1}, - {2, arcs_82_2}, - {1, arcs_82_3}, +static state states_85[4] = { + {1, arcs_85_0}, + {1, arcs_85_1}, + {2, arcs_85_2}, + {1, arcs_85_3}, }; -static arc arcs_83_0[1] = { +static arc arcs_86_0[1] = { {23, 1}, }; -static arc arcs_83_1[1] = { +static arc arcs_86_1[1] = { {0, 1}, }; -static state states_83[2] = { - {1, arcs_83_0}, - {1, arcs_83_1}, +static state states_86[2] = { + {1, arcs_86_0}, + {1, arcs_86_1}, }; -static arc arcs_84_0[1] = { - {174, 1}, +static arc arcs_87_0[1] = { + {177, 1}, }; -static arc arcs_84_1[2] = { - {175, 2}, +static arc arcs_87_1[2] = { + {178, 2}, {0, 1}, }; -static arc arcs_84_2[1] = { +static arc arcs_87_2[1] = { {0, 2}, }; -static state states_84[3] = { - {1, arcs_84_0}, - {2, arcs_84_1}, - {1, arcs_84_2}, +static state states_87[3] = { + {1, arcs_87_0}, + {2, arcs_87_1}, + {1, arcs_87_2}, }; -static arc arcs_85_0[2] = { +static arc arcs_88_0[2] = { {77, 1}, {9, 2}, }; -static arc arcs_85_1[1] = { +static arc arcs_88_1[1] = { {26, 2}, }; -static arc arcs_85_2[1] = { +static arc arcs_88_2[1] = { {0, 2}, }; -static state states_85[3] = { - {2, arcs_85_0}, - {1, arcs_85_1}, - {1, arcs_85_2}, +static state states_88[3] = { + {2, arcs_88_0}, + {1, arcs_88_1}, + {1, arcs_88_2}, }; -static dfa dfas[86] = { +static dfa dfas[89] = { {256, "single_input", 0, 3, states_0, - "\004\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\102"}, + "\004\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\120\076\010\002"}, {257, "file_input", 0, 2, states_1, - "\204\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\102"}, + "\204\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\120\076\010\002"}, {258, "eval_input", 0, 3, states_2, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, {259, "decorator", 0, 7, states_3, - "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {260, "decorators", 0, 2, states_4, - "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {261, "decorated", 0, 3, states_5, - "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {262, "async_funcdef", 0, 3, states_6, - "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {263, "funcdef", 0, 8, states_7, - "\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {264, "parameters", 0, 4, states_8, - "\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {265, "typedargslist", 0, 19, states_9, - "\000\000\200\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {266, "tfpdef", 0, 4, states_10, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {267, "varargslist", 0, 19, states_11, - "\000\000\200\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {268, "vfpdef", 0, 2, states_12, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {269, "stmt", 0, 2, states_13, - "\000\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\102"}, + "\000\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\120\076\010\002"}, {270, "simple_stmt", 0, 4, states_14, - "\000\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\100"}, + "\000\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\120\076\000\002"}, {271, "small_stmt", 0, 2, states_15, - "\000\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\100"}, + "\000\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\120\076\000\002"}, {272, "expr_stmt", 0, 6, states_16, - "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, {273, "annassign", 0, 5, states_17, - "\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {274, "testlist_star_expr", 0, 3, states_18, - "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, {275, "augassign", 0, 2, states_19, - "\000\000\000\000\000\000\360\377\001\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\360\377\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {276, "del_stmt", 0, 3, states_20, - "\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {277, "pass_stmt", 0, 2, states_21, - "\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {278, "flow_stmt", 0, 2, states_22, - "\000\000\000\000\000\000\000\000\000\036\000\000\000\000\000\000\000\000\000\000\000\100"}, + "\000\000\000\000\000\000\000\000\000\036\000\000\000\000\000\000\000\000\000\000\000\000\002"}, {279, "break_stmt", 0, 2, states_23, - "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {280, "continue_stmt", 0, 2, states_24, - "\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {281, "return_stmt", 0, 3, states_25, - "\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {282, "yield_stmt", 0, 2, states_26, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002"}, {283, "raise_stmt", 0, 5, states_27, - "\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {284, "import_stmt", 0, 2, states_28, - "\000\000\000\000\000\000\000\000\000\040\001\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\040\001\000\000\000\000\000\000\000\000\000\000\000\000"}, {285, "import_name", 0, 3, states_29, - "\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000"}, {286, "import_from", 0, 8, states_30, - "\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {287, "import_as_name", 0, 4, states_31, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {288, "dotted_as_name", 0, 4, states_32, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {289, "import_as_names", 0, 3, states_33, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {290, "dotted_as_names", 0, 2, states_34, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {291, "dotted_name", 0, 2, states_35, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {292, "global_stmt", 0, 3, states_36, - "\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000"}, {293, "nonlocal_stmt", 0, 3, states_37, - "\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000"}, {294, "assert_stmt", 0, 5, states_38, - "\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000"}, {295, "compound_stmt", 0, 2, states_39, - "\000\010\140\000\000\000\000\000\000\000\000\000\262\004\000\000\000\000\000\000\000\002"}, + "\000\010\140\000\000\000\000\000\000\000\000\000\262\004\000\000\000\000\000\000\000\010\000"}, {296, "async_stmt", 0, 3, states_40, - "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {297, "if_stmt", 0, 8, states_41, - "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000"}, {298, "while_stmt", 0, 8, states_42, - "\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"}, {299, "for_stmt", 0, 10, states_43, - "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"}, {300, "try_stmt", 0, 13, states_44, - "\000\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000"}, {301, "with_stmt", 0, 5, states_45, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000"}, {302, "with_item", 0, 4, states_46, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, {303, "except_clause", 0, 5, states_47, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"}, {304, "suite", 0, 5, states_48, - "\004\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\100"}, + "\004\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\120\076\000\002"}, {305, "test", 0, 6, states_49, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, {306, "test_nocond", 0, 2, states_50, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, {307, "lambdef", 0, 5, states_51, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000"}, {308, "lambdef_nocond", 0, 5, states_52, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000"}, {309, "or_test", 0, 2, states_53, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\120\076\000\000"}, {310, "and_test", 0, 2, states_54, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\120\076\000\000"}, {311, "not_test", 0, 3, states_55, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\120\076\000\000"}, {312, "comparison", 0, 2, states_56, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, {313, "comp_op", 0, 4, states_57, - "\000\000\000\000\000\000\000\000\000\000\000\000\100\000\000\362\017\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\100\000\000\362\017\000\000\000\000\000\000"}, {314, "star_expr", 0, 3, states_58, - "\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {315, "expr", 0, 2, states_59, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, {316, "xor_expr", 0, 2, states_60, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, {317, "and_expr", 0, 2, states_61, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, {318, "shift_expr", 0, 2, states_62, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, {319, "arith_expr", 0, 2, states_63, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, {320, "term", 0, 2, states_64, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, {321, "factor", 0, 3, states_65, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, {322, "power", 0, 4, states_66, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\200\050\037\000"}, - {323, "atom_expr", 0, 3, states_67, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\200\050\037\000"}, - {324, "atom", 0, 9, states_68, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\050\037\000"}, - {325, "testlist_comp", 0, 5, states_69, - "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, - {326, "trailer", 0, 7, states_70, - "\000\040\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\010\000\000"}, - {327, "subscriptlist", 0, 3, states_71, - "\000\040\200\010\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, - {328, "subscript", 0, 5, states_72, - "\000\040\200\010\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, - {329, "sliceop", 0, 3, states_73, - "\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {330, "exprlist", 0, 3, states_74, - "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, - {331, "testlist", 0, 3, states_75, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, - {332, "dictorsetmaker", 0, 14, states_76, - "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, - {333, "classdef", 0, 8, states_77, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002"}, - {334, "arglist", 0, 3, states_78, - "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, - {335, "argument", 0, 4, states_79, - "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, - {336, "comp_iter", 0, 2, states_80, - "\000\000\040\000\000\000\000\000\000\000\000\000\042\000\000\000\000\000\000\000\000\000"}, - {337, "comp_for", 0, 7, states_81, - "\000\000\040\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"}, - {338, "comp_if", 0, 4, states_82, - "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000"}, - {339, "encoding_decl", 0, 2, states_83, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {340, "yield_expr", 0, 3, states_84, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100"}, - {341, "yield_arg", 0, 3, states_85, - "\000\040\200\000\000\000\000\000\000\040\010\000\000\000\020\002\000\300\220\050\037\000"}, -}; -static label labels[176] = { + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\200\120\076\000\000"}, + {323, "await_expr", 0, 3, states_67, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\200\120\076\000\000"}, + {324, "atom_expr", 0, 2, states_68, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\120\076\000\000"}, + {325, "atom", 0, 9, states_69, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\120\076\000\000"}, + {326, "testlist_comp", 0, 5, states_70, + "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, + {327, "trailer", 0, 7, states_71, + "\000\040\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\020\000\000\000"}, + {328, "subscriptlist", 0, 3, states_72, + "\000\040\200\010\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, + {329, "subscript", 0, 5, states_73, + "\000\040\200\010\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, + {330, "sliceop", 0, 3, states_74, + "\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + {331, "exprlist", 0, 3, states_75, + "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, + {332, "testlist", 0, 3, states_76, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, + {333, "dictorsetmaker", 0, 14, states_77, + "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, + {334, "classdef", 0, 8, states_78, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010\000"}, + {335, "arglist", 0, 3, states_79, + "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, + {336, "argument", 0, 4, states_80, + "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, + {337, "comp_for_or_async", 0, 2, states_81, + "\000\000\040\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"}, + {338, "comp_iter", 0, 2, states_82, + "\000\000\040\000\000\000\000\000\000\000\000\000\042\000\000\000\000\000\000\000\000\000\000"}, + {339, "comp_async_for", 0, 7, states_83, + "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + {340, "comp_for", 0, 6, states_84, + "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"}, + {341, "comp_if", 0, 4, states_85, + "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000"}, + {342, "encoding_decl", 0, 2, states_86, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + {343, "yield_expr", 0, 3, states_87, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002"}, + {344, "yield_arg", 0, 3, states_88, + "\000\040\200\000\000\000\000\000\000\040\010\000\000\000\020\002\000\300\220\120\076\000\000"}, +}; +static label labels[179] = { {0, "EMPTY"}, {256, 0}, {4, 0}, @@ -2087,19 +2145,19 @@ static label labels[176] = { {269, 0}, {0, 0}, {258, 0}, - {331, 0}, + {332, 0}, {259, 0}, {49, 0}, {291, 0}, {7, 0}, - {334, 0}, + {335, 0}, {8, 0}, {260, 0}, {261, 0}, - {333, 0}, + {334, 0}, {263, 0}, {262, 0}, - {55, 0}, + {1, "async"}, {1, "def"}, {1, 0}, {264, 0}, @@ -2128,7 +2186,7 @@ static label labels[176] = { {274, 0}, {273, 0}, {275, 0}, - {340, 0}, + {343, 0}, {314, 0}, {36, 0}, {37, 0}, @@ -2144,7 +2202,7 @@ static label labels[176] = { {46, 0}, {48, 0}, {1, "del"}, - {330, 0}, + {331, 0}, {1, "pass"}, {279, 0}, {280, 0}, @@ -2229,35 +2287,38 @@ static label labels[176] = { {31, 0}, {322, 0}, {323, 0}, - {54, 0}, + {1, "await"}, {324, 0}, - {326, 0}, {325, 0}, + {327, 0}, + {326, 0}, {9, 0}, {10, 0}, {25, 0}, - {332, 0}, + {333, 0}, {26, 0}, {2, 0}, {3, 0}, {1, "None"}, {1, "True"}, {1, "False"}, - {337, 0}, - {327, 0}, + {340, 0}, + {339, 0}, {328, 0}, {329, 0}, + {330, 0}, {1, "class"}, - {335, 0}, {336, 0}, + {337, 0}, {338, 0}, - {339, 0}, - {1, "yield"}, {341, 0}, + {342, 0}, + {1, "yield"}, + {344, 0}, }; grammar _PyParser_Grammar = { - 86, + 89, dfas, - {176, labels}, + {179, labels}, 256 }; From 8e16e6b3263e595e06c67b588cd12c5ccda80dd2 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 16 Apr 2017 11:20:01 -0700 Subject: [PATCH 02/26] remove asyncio test that is now a SyntaxError --- Lib/test/test_asyncio/test_tasks.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index 7ff56b560b692e..e23963a62215f5 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -231,12 +231,6 @@ def test_ensure_future_neither(self): with self.assertRaises(TypeError): asyncio.ensure_future('ok') - def test_async_warning(self): - f = self.new_future(self.loop) - with self.assertWarnsRegex(DeprecationWarning, - 'function is deprecated, use ensure_'): - self.assertIs(f, asyncio.async(f)) - def test_get_stack(self): T = None From 81dae406d2d613b69ea9b6f8717c363ad90b17c1 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 16 Apr 2017 11:20:14 -0700 Subject: [PATCH 03/26] update syntax tests in test_coroutines --- Lib/test/test_coroutines.py | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py index 2b79a17ea703f5..74c481343493ff 100644 --- a/Lib/test/test_coroutines.py +++ b/Lib/test/test_coroutines.py @@ -394,18 +394,14 @@ def async(): pass ] for code in samples: - with self.subTest(code=code), self.assertWarnsRegex( - DeprecationWarning, - "'await' will become reserved keywords"): + with self.subTest(code=code), self.assertRaises(SyntaxError): compile(code, "", "exec") def test_badsyntax_3(self): - with self.assertRaises(DeprecationWarning): - with warnings.catch_warnings(): - warnings.simplefilter("error") - compile("async = 1", "", "exec") + with self.assertRaises(SyntaxError): + compile("async = 1", "", "exec") - def test_goodsyntax_1(self): + def test_badsyntax_4(self): # Tests for issue 24619 samples = [ @@ -454,14 +450,8 @@ async def bar(): return await_ ] for code in samples: - with self.subTest(code=code): - loc = {} - - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - exec(code, loc, loc) - - self.assertEqual(loc['foo'](10), 11) + with self.subTest(code=code), self.assertRaises(SyntaxError): + compile(code, "", "exec") class TokenizerRegrTest(unittest.TestCase): From 9e65b472d848891028b774c0484ddeebeb4f6d04 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 16 Apr 2017 11:20:37 -0700 Subject: [PATCH 04/26] regenerate symbol.py --- Lib/symbol.py | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/Lib/symbol.py b/Lib/symbol.py index d9f01e081a7595..2c995a6199e989 100755 --- a/Lib/symbol.py +++ b/Lib/symbol.py @@ -77,25 +77,28 @@ term = 320 factor = 321 power = 322 -atom_expr = 323 -atom = 324 -testlist_comp = 325 -trailer = 326 -subscriptlist = 327 -subscript = 328 -sliceop = 329 -exprlist = 330 -testlist = 331 -dictorsetmaker = 332 -classdef = 333 -arglist = 334 -argument = 335 -comp_iter = 336 -comp_for = 337 -comp_if = 338 -encoding_decl = 339 -yield_expr = 340 -yield_arg = 341 +await_expr = 323 +atom_expr = 324 +atom = 325 +testlist_comp = 326 +trailer = 327 +subscriptlist = 328 +subscript = 329 +sliceop = 330 +exprlist = 331 +testlist = 332 +dictorsetmaker = 333 +classdef = 334 +arglist = 335 +argument = 336 +comp_for_or_async = 337 +comp_iter = 338 +comp_async_for = 339 +comp_for = 340 +comp_if = 341 +encoding_decl = 342 +yield_expr = 343 +yield_arg = 344 #--end constants-- sym_name = {} From f850135ce088dbd7eafc30ad03dc59d4a9f1737e Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 16 Apr 2017 11:29:02 -0700 Subject: [PATCH 05/26] fix tokenize.py --- Lib/test/test_tokenize.py | 28 +++++++++--------- Lib/tokenize.py | 62 +-------------------------------------- 2 files changed, 15 insertions(+), 75 deletions(-) diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py index 21eee6de2d13cb..3520a67bd42b11 100644 --- a/Lib/test/test_tokenize.py +++ b/Lib/test/test_tokenize.py @@ -759,7 +759,7 @@ def test_async(self): """) self.check_tokenize("async def foo(): pass", """\ - ASYNC 'async' (1, 0) (1, 5) + NAME 'async' (1, 0) (1, 5) NAME 'def' (1, 6) (1, 9) NAME 'foo' (1, 10) (1, 13) OP '(' (1, 13) (1, 14) @@ -776,7 +776,7 @@ def foo(await): await async += 1 ''', """\ - ASYNC 'async' (1, 0) (1, 5) + NAME 'async' (1, 0) (1, 5) NAME 'def' (1, 6) (1, 9) NAME 'foo' (1, 10) (1, 13) OP '(' (1, 13) (1, 14) @@ -787,12 +787,12 @@ def foo(await): NAME 'def' (2, 2) (2, 5) NAME 'foo' (2, 6) (2, 9) OP '(' (2, 9) (2, 10) - AWAIT 'await' (2, 10) (2, 15) + NAME 'await' (2, 10) (2, 15) OP ')' (2, 15) (2, 16) OP ':' (2, 16) (2, 17) NEWLINE '\\n' (2, 17) (2, 18) INDENT ' ' (3, 0) (3, 4) - AWAIT 'await' (3, 4) (3, 9) + NAME 'await' (3, 4) (3, 9) OP '=' (3, 10) (3, 11) NUMBER '1' (3, 12) (3, 13) NEWLINE '\\n' (3, 13) (3, 14) @@ -802,7 +802,7 @@ def foo(await): OP ':' (4, 6) (4, 7) NEWLINE '\\n' (4, 7) (4, 8) INDENT ' ' (5, 0) (5, 4) - AWAIT 'await' (5, 4) (5, 9) + NAME 'await' (5, 4) (5, 9) NEWLINE '\\n' (5, 9) (5, 10) DEDENT '' (6, 0) (6, 0) DEDENT '' (6, 0) (6, 0) @@ -815,7 +815,7 @@ def foo(await): self.check_tokenize('''\ async def foo(): async for i in 1: pass''', """\ - ASYNC 'async' (1, 0) (1, 5) + NAME 'async' (1, 0) (1, 5) NAME 'def' (1, 6) (1, 9) NAME 'foo' (1, 10) (1, 13) OP '(' (1, 13) (1, 14) @@ -823,7 +823,7 @@ async def foo(): OP ':' (1, 15) (1, 16) NEWLINE '\\n' (1, 16) (1, 17) INDENT ' ' (2, 0) (2, 2) - ASYNC 'async' (2, 2) (2, 7) + NAME 'async' (2, 2) (2, 7) NAME 'for' (2, 8) (2, 11) NAME 'i' (2, 12) (2, 13) NAME 'in' (2, 14) (2, 16) @@ -834,14 +834,14 @@ async def foo(): """) self.check_tokenize('''async def foo(async): await''', """\ - ASYNC 'async' (1, 0) (1, 5) + NAME 'async' (1, 0) (1, 5) NAME 'def' (1, 6) (1, 9) NAME 'foo' (1, 10) (1, 13) OP '(' (1, 13) (1, 14) - ASYNC 'async' (1, 14) (1, 19) + NAME 'async' (1, 14) (1, 19) OP ')' (1, 19) (1, 20) OP ':' (1, 20) (1, 21) - AWAIT 'await' (1, 22) (1, 27) + NAME 'await' (1, 22) (1, 27) """) self.check_tokenize('''\ @@ -866,7 +866,7 @@ async def bar(): pass OP ':' (3, 11) (3, 12) NAME 'pass' (3, 13) (3, 17) NEWLINE '\\n' (3, 17) (3, 18) - ASYNC 'async' (4, 2) (4, 7) + NAME 'async' (4, 2) (4, 7) NAME 'def' (4, 8) (4, 11) NAME 'bar' (4, 12) (4, 15) OP '(' (4, 15) (4, 16) @@ -888,7 +888,7 @@ def baz(): pass async def bar(): pass await = 2''', """\ - ASYNC 'async' (1, 0) (1, 5) + NAME 'async' (1, 0) (1, 5) NAME 'def' (1, 6) (1, 9) NAME 'f' (1, 10) (1, 11) OP '(' (1, 11) (1, 12) @@ -904,7 +904,7 @@ async def bar(): pass OP ':' (3, 11) (3, 12) NAME 'pass' (3, 13) (3, 17) NEWLINE '\\n' (3, 17) (3, 18) - ASYNC 'async' (4, 2) (4, 7) + NAME 'async' (4, 2) (4, 7) NAME 'def' (4, 8) (4, 11) NAME 'bar' (4, 12) (4, 15) OP '(' (4, 15) (4, 16) @@ -913,7 +913,7 @@ async def bar(): pass NAME 'pass' (4, 19) (4, 23) NEWLINE '\\n' (4, 23) (4, 24) NL '\\n' (5, 0) (5, 1) - AWAIT 'await' (6, 2) (6, 7) + NAME 'await' (6, 2) (6, 7) OP '=' (6, 8) (6, 9) NUMBER '2' (6, 10) (6, 11) DEDENT '' (7, 0) (7, 0) diff --git a/Lib/tokenize.py b/Lib/tokenize.py index 5fa4152609378a..f5c6ac7f5e0559 100644 --- a/Lib/tokenize.py +++ b/Lib/tokenize.py @@ -491,12 +491,6 @@ def _tokenize(readline, encoding): contline = None indents = [0] - # 'stashed' and 'async_*' are used for async/await parsing - stashed = None - async_def = False - async_def_indent = 0 - async_def_nl = False - if encoding is not None: if encoding == "utf-8-sig": # BOM will already have been stripped. @@ -571,18 +565,8 @@ def _tokenize(readline, encoding): ("", lnum, pos, line)) indents = indents[:-1] - if async_def and async_def_indent >= indents[-1]: - async_def = False - async_def_nl = False - async_def_indent = 0 - yield TokenInfo(DEDENT, '', (lnum, pos), (lnum, pos), line) - if async_def and async_def_nl and async_def_indent >= indents[-1]: - async_def = False - async_def_nl = False - async_def_indent = 0 - else: # continued statement if not line: raise TokenError("EOF in multi-line statement", (lnum, 0)) @@ -601,21 +585,13 @@ def _tokenize(readline, encoding): (initial == '.' and token != '.' and token != '...')): yield TokenInfo(NUMBER, token, spos, epos, line) elif initial in '\r\n': - if stashed: - yield stashed - stashed = None if parenlev > 0: yield TokenInfo(NL, token, spos, epos, line) else: yield TokenInfo(NEWLINE, token, spos, epos, line) - if async_def: - async_def_nl = True elif initial == '#': assert not token.endswith("\n") - if stashed: - yield stashed - stashed = None yield TokenInfo(COMMENT, token, spos, epos, line) elif token in triple_quoted: @@ -662,36 +638,7 @@ def _tokenize(readline, encoding): yield TokenInfo(STRING, token, spos, epos, line) elif initial.isidentifier(): # ordinary name - if token in ('async', 'await'): - if async_def: - yield TokenInfo( - ASYNC if token == 'async' else AWAIT, - token, spos, epos, line) - continue - - tok = TokenInfo(NAME, token, spos, epos, line) - if token == 'async' and not stashed: - stashed = tok - continue - - if token == 'def': - if (stashed - and stashed.type == NAME - and stashed.string == 'async'): - - async_def = True - async_def_indent = indents[-1] - - yield TokenInfo(ASYNC, stashed.string, - stashed.start, stashed.end, - stashed.line) - stashed = None - - if stashed: - yield stashed - stashed = None - - yield tok + yield TokenInfo(NAME, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 else: @@ -699,19 +646,12 @@ def _tokenize(readline, encoding): parenlev += 1 elif initial in ')]}': parenlev -= 1 - if stashed: - yield stashed - stashed = None yield TokenInfo(OP, token, spos, epos, line) else: yield TokenInfo(ERRORTOKEN, line[pos], (lnum, pos), (lnum, pos+1), line) pos += 1 - if stashed: - yield stashed - stashed = None - for indent in indents[1:]: # pop remaining indent levels yield TokenInfo(DEDENT, '', (lnum, 0), (lnum, 0), '') yield TokenInfo(ENDMARKER, '', (lnum, 0), (lnum, 0), '') From f95c99229f8016d953d2b1cda9990a5877dc37c6 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 16 Apr 2017 11:32:46 -0700 Subject: [PATCH 06/26] fewer nested lists allowed Maybe because I added await_expr --- Lib/test/test_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index 70cabb28598218..86d08a939e25c6 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -762,7 +762,7 @@ def _nested_expression(self, level): def test_deeply_nested_list(self): # XXX used to be 99 levels in 2.x - e = self._nested_expression(93) + e = self._nested_expression(88) st = parser.expr(e) st.compile() From 5c8bddcdd983940c423db0bd37d86dab6e7e56c5 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 16 Apr 2017 11:35:38 -0700 Subject: [PATCH 07/26] regenerate keyword.py --- Lib/keyword.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/keyword.py b/Lib/keyword.py index 6e1e882a91e700..431991dcf4ace6 100755 --- a/Lib/keyword.py +++ b/Lib/keyword.py @@ -20,6 +20,8 @@ 'and', 'as', 'assert', + 'async', + 'await', 'break', 'class', 'continue', From ac04cffb41b5253a3f18c2fc41b42237f9d4d07c Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 16 Apr 2017 11:51:18 -0700 Subject: [PATCH 08/26] fix lib2to3 --- Lib/lib2to3/Grammar.txt | 25 ++++++----- Lib/lib2to3/pgen2/token.py | 6 +-- Lib/lib2to3/pgen2/tokenize.py | 76 +------------------------------- Lib/lib2to3/tests/test_parser.py | 26 ++++++----- 4 files changed, 33 insertions(+), 100 deletions(-) diff --git a/Lib/lib2to3/Grammar.txt b/Lib/lib2to3/Grammar.txt index ded032522bada4..c63ca2eb9d54c0 100644 --- a/Lib/lib2to3/Grammar.txt +++ b/Lib/lib2to3/Grammar.txt @@ -34,7 +34,7 @@ eval_input: testlist NEWLINE* ENDMARKER decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE decorators: decorator+ decorated: decorators (classdef | funcdef | async_funcdef) -async_funcdef: ASYNC funcdef +async_funcdef: 'async' funcdef funcdef: 'def' NAME parameters ['->' test] ':' suite parameters: '(' [typedargslist] ')' typedargslist: ((tfpdef ['=' test] ',')* @@ -85,7 +85,7 @@ exec_stmt: 'exec' expr ['in' test [',' test]] assert_stmt: 'assert' test [',' test] compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated | async_stmt -async_stmt: ASYNC (funcdef | with_stmt | for_stmt) +async_stmt: 'async' (funcdef | with_stmt | for_stmt) if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] while_stmt: 'while' test ':' suite ['else' ':' suite] for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] @@ -123,15 +123,16 @@ and_expr: shift_expr ('&' shift_expr)* shift_expr: arith_expr (('<<'|'>>') arith_expr)* arith_expr: term (('+'|'-') term)* term: factor (('*'|'@'|'/'|'%'|'//') factor)* -factor: ('+'|'-'|'~') factor | power -power: [AWAIT] atom trailer* ['**' factor] +factor: ('+'|'-'|'~') factor | await_expr +await_expr: 'await' power | power +power: atom trailer* ['**' factor] atom: ('(' [yield_expr|testlist_gexp] ')' | '[' [listmaker] ']' | '{' [dictsetmaker] '}' | '`' testlist1 '`' | NAME | NUMBER | STRING+ | '.' '.' '.') -listmaker: (test|star_expr) ( old_comp_for | (',' (test|star_expr))* [','] ) -testlist_gexp: (test|star_expr) ( old_comp_for | (',' (test|star_expr))* [','] ) +listmaker: (test|star_expr) ( old_comp_for | comp_async_for | (',' (test|star_expr))* [','] ) +testlist_gexp: (test|star_expr) ( old_comp_for | comp_async_for | (',' (test|star_expr))* [','] ) lambdef: 'lambda' [varargslist] ':' test trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME subscriptlist: subscript (',' subscript)* [','] @@ -140,9 +141,9 @@ sliceop: ':' [test] exprlist: (expr|star_expr) (',' (expr|star_expr))* [','] testlist: test (',' test)* [','] dictsetmaker: ( ((test ':' test | '**' expr) - (comp_for | (',' (test ':' test | '**' expr))* [','])) | + (comp_for | comp_async_for | (',' (test ':' test | '**' expr))* [','])) | ((test | star_expr) - (comp_for | (',' (test | star_expr))* [','])) ) + (comp_for | comp_async_for | (',' (test | star_expr))* [','])) ) classdef: 'class' NAME ['(' [arglist] ')'] ':' suite @@ -155,13 +156,15 @@ arglist: argument (',' argument)* [','] # Illegal combinations and orderings are blocked in ast.c: # multiple (test comp_for) arguments are blocked; keyword unpackings # that precede iterable unpackings are blocked; etc. -argument: ( test [comp_for] | +argument: ( test [comp_for_or_async] | test '=' test | '**' expr | star_expr ) -comp_iter: comp_for | comp_if -comp_for: [ASYNC] 'for' exprlist 'in' or_test [comp_iter] +comp_for_or_async: comp_async_for | comp_for +comp_iter: comp_async_for | comp_for | comp_if +comp_async_for: 'async' 'for' exprlist 'in' testlist_safe [comp_iter] +comp_for: 'for' exprlist 'in' testlist_safe [comp_iter] comp_if: 'if' old_test [comp_iter] # As noted above, testlist_safe extends the syntax allowed in list diff --git a/Lib/lib2to3/pgen2/token.py b/Lib/lib2to3/pgen2/token.py index 1a679554d2db4e..7599396611b232 100755 --- a/Lib/lib2to3/pgen2/token.py +++ b/Lib/lib2to3/pgen2/token.py @@ -62,10 +62,8 @@ COMMENT = 53 NL = 54 RARROW = 55 -AWAIT = 56 -ASYNC = 57 -ERRORTOKEN = 58 -N_TOKENS = 59 +ERRORTOKEN = 56 +N_TOKENS = 57 NT_OFFSET = 256 #--end constants-- diff --git a/Lib/lib2to3/pgen2/tokenize.py b/Lib/lib2to3/pgen2/tokenize.py index 45afc5f4e53fcf..14560e4fddff62 100644 --- a/Lib/lib2to3/pgen2/tokenize.py +++ b/Lib/lib2to3/pgen2/tokenize.py @@ -234,7 +234,7 @@ def compat(self, token, iterable): for tok in iterable: toknum, tokval = tok[:2] - if toknum in (NAME, NUMBER, ASYNC, AWAIT): + if toknum in (NAME, NUMBER): tokval += ' ' if toknum == INDENT: @@ -380,12 +380,6 @@ def generate_tokens(readline): contline = None indents = [0] - # 'stashed' and 'async_*' are used for async/await parsing - stashed = None - async_def = False - async_def_indent = 0 - async_def_nl = False - while 1: # loop over lines in stream try: line = readline() @@ -426,10 +420,6 @@ def generate_tokens(readline): pos = pos + 1 if pos == max: break - if stashed: - yield stashed - stashed = None - if line[pos] in '#\r\n': # skip comments or blank lines if line[pos] == '#': comment_token = line[pos:].rstrip('\r\n') @@ -453,18 +443,8 @@ def generate_tokens(readline): ("", lnum, pos, line)) indents = indents[:-1] - if async_def and async_def_indent >= indents[-1]: - async_def = False - async_def_nl = False - async_def_indent = 0 - yield (DEDENT, '', (lnum, pos), (lnum, pos), line) - if async_def and async_def_nl and async_def_indent >= indents[-1]: - async_def = False - async_def_nl = False - async_def_indent = 0 - else: # continued statement if not line: raise TokenError("EOF in multi-line statement", (lnum, 0)) @@ -484,18 +464,10 @@ def generate_tokens(readline): newline = NEWLINE if parenlev > 0: newline = NL - elif async_def: - async_def_nl = True - if stashed: - yield stashed - stashed = None yield (newline, token, spos, epos, line) elif initial == '#': assert not token.endswith("\n") - if stashed: - yield stashed - stashed = None yield (COMMENT, token, spos, epos, line) elif token in triple_quoted: endprog = endprogs[token] @@ -503,9 +475,6 @@ def generate_tokens(readline): if endmatch: # all on one line pos = endmatch.end(0) token = line[start:pos] - if stashed: - yield stashed - stashed = None yield (STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines @@ -523,63 +492,22 @@ def generate_tokens(readline): contline = line break else: # ordinary string - if stashed: - yield stashed - stashed = None yield (STRING, token, spos, epos, line) elif initial in namechars: # ordinary name - if token in ('async', 'await'): - if async_def: - yield (ASYNC if token == 'async' else AWAIT, - token, spos, epos, line) - continue - - tok = (NAME, token, spos, epos, line) - if token == 'async' and not stashed: - stashed = tok - continue - - if token == 'def': - if (stashed - and stashed[0] == NAME - and stashed[1] == 'async'): - - async_def = True - async_def_indent = indents[-1] - - yield (ASYNC, stashed[1], - stashed[2], stashed[3], - stashed[4]) - stashed = None - - if stashed: - yield stashed - stashed = None - - yield tok + yield (NAME, token, spos, epos, line) elif initial == '\\': # continued stmt # This yield is new; needed for better idempotency: - if stashed: - yield stashed - stashed = None yield (NL, token, spos, (lnum, pos), line) continued = 1 else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 - if stashed: - yield stashed - stashed = None yield (OP, token, spos, epos, line) else: yield (ERRORTOKEN, line[pos], (lnum, pos), (lnum, pos+1), line) pos = pos + 1 - if stashed: - yield stashed - stashed = None - for indent in indents[1:]: # pop remaining indent levels yield (DEDENT, '', (lnum, 0), (lnum, 0), '') yield (ENDMARKER, '', (lnum, 0), (lnum, 0), '') diff --git a/Lib/lib2to3/tests/test_parser.py b/Lib/lib2to3/tests/test_parser.py index 2efcb80c2f94a9..dc94a69036a56d 100644 --- a/Lib/lib2to3/tests/test_parser.py +++ b/Lib/lib2to3/tests/test_parser.py @@ -167,34 +167,34 @@ def foo(): pass async def foo(): await x """) - self.invalid_syntax("await x") - self.invalid_syntax("""def foo(): - await x""") + self.validate("await x") + self.validate("""def foo(): + await x""") - self.invalid_syntax("""def foo(): + self.validate("""def foo(): def foo(): pass async def foo(): pass await x """) def test_async_var(self): - self.validate("""async = 1""") - self.validate("""await = 1""") - self.validate("""def async(): pass""") + self.invalid_syntax("""async = 1""") + self.invalid_syntax("""await = 1""") + self.invalid_syntax("""def async(): pass""") def test_async_with(self): self.validate("""async def foo(): async for a in b: pass""") - self.invalid_syntax("""def foo(): - async for a in b: pass""") + self.validate("""def foo(): + async for a in b: pass""") def test_async_for(self): self.validate("""async def foo(): async with a: pass""") - self.invalid_syntax("""def foo(): - async with a: pass""") + self.validate("""def foo(): + async with a: pass""") class TestRaiseChanges(GrammarTest): @@ -477,3 +477,7 @@ def diff(fn, result): os.remove("@") except OSError: pass + + +if __name__ == '__main__': + unittest.main() From 8af009faf4236d4c8557d50fff5c292f196fda99 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 22 Apr 2017 16:15:42 -0700 Subject: [PATCH 09/26] add some docs --- Doc/library/token.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/library/token.rst b/Doc/library/token.rst index b7ca9dbca722f8..f6a96b9d22b2a5 100644 --- a/Doc/library/token.rst +++ b/Doc/library/token.rst @@ -98,8 +98,6 @@ The token constants are: RARROW ELLIPSIS OP - AWAIT - ASYNC ERRORTOKEN N_TOKENS NT_OFFSET @@ -129,9 +127,11 @@ the :mod:`tokenize` module. .. versionchanged:: 3.5 - Added :data:`AWAIT` and :data:`ASYNC` tokens. Starting with - Python 3.7, "async" and "await" will be tokenized as :data:`NAME` - tokens, and :data:`AWAIT` and :data:`ASYNC` will be removed. + Added :data:`AWAIT` and :data:`ASYNC` tokens. .. versionchanged:: 3.7 Added :data:`COMMENT`, :data:`NL` and :data:`ENCODING` tokens. + +.. versionchanged:: 3.7 + Removed :data:`AWAIT` and :data:`ASYNC` tokens again. "async" and + "await" are now tokenized as :data:`NAME` tokens. From 428925381e2c7f455ddc6d30d99dfd79c8eaab94 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 19 May 2017 15:05:49 -0700 Subject: [PATCH 10/26] fix test_parser.py --- Lib/test/test_parser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index 86d08a939e25c6..e98fdbd2fb561e 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -679,16 +679,16 @@ def test_missing_import_source(self): def test_illegal_encoding(self): # Illegal encoding declaration tree = \ - (339, + (342, (257, (0, ''))) self.check_bad_tree(tree, "missed encoding") tree = \ - (339, + (342, (257, (0, '')), b'iso-8859-1') self.check_bad_tree(tree, "non-string encoding") tree = \ - (339, + (342, (257, (0, '')), '\udcff') with self.assertRaises(UnicodeEncodeError): From cf2f46738bf3aeaf147ce6618f25a7a91cdc8bae Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Fri, 19 May 2017 15:12:01 -0700 Subject: [PATCH 11/26] attempt to get pydoc to work --- Doc/tools/extensions/pyspecific.py | 6 +++--- Lib/pydoc.py | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index e8c88760a87ba6..00acd4f55b8b95 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -272,9 +272,9 @@ def run(self): # Support for building "topic help" for pydoc pydoc_topic_labels = [ - 'assert', 'assignment', 'atom-identifiers', 'atom-literals', - 'attribute-access', 'attribute-references', 'augassign', 'binary', - 'bitwise', 'bltin-code-objects', 'bltin-ellipsis-object', + 'assert', 'assignment', 'async', 'atom-identifiers', 'atom-literals', + 'attribute-access', 'attribute-references', 'augassign', 'await', + 'binary', 'bitwise', 'bltin-code-objects', 'bltin-ellipsis-object', 'bltin-null-object', 'bltin-type-objects', 'booleans', 'break', 'callable-types', 'calls', 'class', 'comparisons', 'compound', 'context-managers', 'continue', 'conversions', 'customization', 'debugger', diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 8dc3c0ace3c94e..01f7a32f454e51 100644 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1703,7 +1703,7 @@ class Helper: # in pydoc_data/topics.py. # # CAUTION: if you change one of these dictionaries, be sure to adapt the - # list of needed labels in Doc/tools/pyspecific.py and + # list of needed labels in Doc/tools/extensions/pyspecific.py and # regenerate the pydoc_data/topics.py file by running # make pydoc-topics # in Doc/ and copying the output file into the Lib/ directory. @@ -1715,6 +1715,8 @@ class Helper: 'and': 'BOOLEAN', 'as': 'with', 'assert': ('assert', ''), + 'async': ('async', ''), + 'await': ('await', ''), 'break': ('break', 'while for'), 'class': ('class', 'CLASSES SPECIALMETHODS'), 'continue': ('continue', 'while for'), From c824937457d186e8f389736e856e3bbf4fcface5 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 20 Jul 2017 22:03:54 -0700 Subject: [PATCH 12/26] add blurb --- .../Core and Builtins/2017-07-20-22-03-44.bpo-30406._kr47t.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2017-07-20-22-03-44.bpo-30406._kr47t.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2017-07-20-22-03-44.bpo-30406._kr47t.rst b/Misc/NEWS.d/next/Core and Builtins/2017-07-20-22-03-44.bpo-30406._kr47t.rst new file mode 100644 index 00000000000000..079887733f8f1d --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2017-07-20-22-03-44.bpo-30406._kr47t.rst @@ -0,0 +1 @@ +``async`` and ``await`` are now proper keywords, as specified in PEP 492. From ca856050976f6b2ef76e4848cca71734bc718913 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 20 Jul 2017 23:27:19 -0700 Subject: [PATCH 13/26] run make patchcheck to fix whitespace --- Include/token.h | 118 ++++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/Include/token.h b/Include/token.h index 39a5dd7924db4c..dc79910397d3b2 100644 --- a/Include/token.h +++ b/Include/token.h @@ -9,75 +9,75 @@ extern "C" { #undef TILDE /* Prevent clash of our definition with system macro. Ex AIX, ioctl.h */ -#define ENDMARKER 0 -#define NAME 1 -#define NUMBER 2 -#define STRING 3 -#define NEWLINE 4 -#define INDENT 5 -#define DEDENT 6 -#define LPAR 7 -#define RPAR 8 -#define LSQB 9 -#define RSQB 10 -#define COLON 11 -#define COMMA 12 -#define SEMI 13 -#define PLUS 14 -#define MINUS 15 -#define STAR 16 -#define SLASH 17 -#define VBAR 18 -#define AMPER 19 -#define LESS 20 -#define GREATER 21 -#define EQUAL 22 -#define DOT 23 -#define PERCENT 24 -#define LBRACE 25 -#define RBRACE 26 -#define EQEQUAL 27 -#define NOTEQUAL 28 -#define LESSEQUAL 29 -#define GREATEREQUAL 30 -#define TILDE 31 -#define CIRCUMFLEX 32 -#define LEFTSHIFT 33 -#define RIGHTSHIFT 34 -#define DOUBLESTAR 35 -#define PLUSEQUAL 36 -#define MINEQUAL 37 -#define STAREQUAL 38 -#define SLASHEQUAL 39 -#define PERCENTEQUAL 40 -#define AMPEREQUAL 41 -#define VBAREQUAL 42 -#define CIRCUMFLEXEQUAL 43 -#define LEFTSHIFTEQUAL 44 -#define RIGHTSHIFTEQUAL 45 -#define DOUBLESTAREQUAL 46 -#define DOUBLESLASH 47 +#define ENDMARKER 0 +#define NAME 1 +#define NUMBER 2 +#define STRING 3 +#define NEWLINE 4 +#define INDENT 5 +#define DEDENT 6 +#define LPAR 7 +#define RPAR 8 +#define LSQB 9 +#define RSQB 10 +#define COLON 11 +#define COMMA 12 +#define SEMI 13 +#define PLUS 14 +#define MINUS 15 +#define STAR 16 +#define SLASH 17 +#define VBAR 18 +#define AMPER 19 +#define LESS 20 +#define GREATER 21 +#define EQUAL 22 +#define DOT 23 +#define PERCENT 24 +#define LBRACE 25 +#define RBRACE 26 +#define EQEQUAL 27 +#define NOTEQUAL 28 +#define LESSEQUAL 29 +#define GREATEREQUAL 30 +#define TILDE 31 +#define CIRCUMFLEX 32 +#define LEFTSHIFT 33 +#define RIGHTSHIFT 34 +#define DOUBLESTAR 35 +#define PLUSEQUAL 36 +#define MINEQUAL 37 +#define STAREQUAL 38 +#define SLASHEQUAL 39 +#define PERCENTEQUAL 40 +#define AMPEREQUAL 41 +#define VBAREQUAL 42 +#define CIRCUMFLEXEQUAL 43 +#define LEFTSHIFTEQUAL 44 +#define RIGHTSHIFTEQUAL 45 +#define DOUBLESTAREQUAL 46 +#define DOUBLESLASH 47 #define DOUBLESLASHEQUAL 48 #define AT 49 -#define ATEQUAL 50 +#define ATEQUAL 50 #define RARROW 51 #define ELLIPSIS 52 /* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */ -#define OP 53 -#define ERRORTOKEN 54 +#define OP 53 +#define ERRORTOKEN 54 /* These aren't used by the C tokenizer but are needed for tokenize.py */ -#define COMMENT 55 -#define NL 56 -#define ENCODING 57 -#define N_TOKENS 58 +#define COMMENT 55 +#define NL 56 +#define ENCODING 57 +#define N_TOKENS 58 /* Special definitions for cooperation with parser */ -#define NT_OFFSET 256 +#define NT_OFFSET 256 -#define ISTERMINAL(x) ((x) < NT_OFFSET) -#define ISNONTERMINAL(x) ((x) >= NT_OFFSET) -#define ISEOF(x) ((x) == ENDMARKER) +#define ISTERMINAL(x) ((x) < NT_OFFSET) +#define ISNONTERMINAL(x) ((x) >= NT_OFFSET) +#define ISEOF(x) ((x) == ENDMARKER) PyAPI_DATA(const char *) _PyParser_TokenNames[]; /* Token names */ From 505a66d38ef6adba4572dd6969f1f4434dcf6ab2 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 22 Jul 2017 08:41:32 -0700 Subject: [PATCH 14/26] remove obsolete code from forbidden_name --- Python/ast.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/Python/ast.c b/Python/ast.c index 5422ffe5e6ffcc..e4eea49444b572 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -949,28 +949,6 @@ forbidden_name(struct compiling *c, identifier name, const node *n, ast_error(c, n, "assignment to keyword"); return 1; } - if (_PyUnicode_EqualToASCIIString(name, "async") || - _PyUnicode_EqualToASCIIString(name, "await")) - { - PyObject *message = PyUnicode_FromString( - "'async' and 'await' will become reserved keywords" - " in Python 3.7"); - int ret; - if (message == NULL) { - return 1; - } - ret = PyErr_WarnExplicitObject( - PyExc_DeprecationWarning, - message, - c->c_filename, - LINENO(n), - NULL, - NULL); - Py_DECREF(message); - if (ret < 0) { - return 1; - } - } if (full_checks) { const char * const *p; for (p = FORBIDDEN; *p; p++) { From 57fb8ede5cc3320909f7e05a3149073061362e15 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 22 Jul 2017 09:05:54 -0700 Subject: [PATCH 15/26] attempt to make it work without await_expr --- Grammar/Grammar | 5 +- Include/graminit.h | 43 ++- Lib/test/test_parser.py | 6 +- Python/ast.c | 43 +-- Python/graminit.c | 677 ++++++++++++++++++++-------------------- 5 files changed, 374 insertions(+), 400 deletions(-) diff --git a/Grammar/Grammar b/Grammar/Grammar index ed52842ae8f231..f02f7863d4310d 100644 --- a/Grammar/Grammar +++ b/Grammar/Grammar @@ -102,9 +102,8 @@ shift_expr: arith_expr (('<<'|'>>') arith_expr)* arith_expr: term (('+'|'-') term)* term: factor (('*'|'@'|'/'|'%'|'//') factor)* factor: ('+'|'-'|'~') factor | power -power: await_expr ['**' factor] -await_expr: 'await' atom_expr | atom_expr -atom_expr: atom trailer* +power: atom_expr ['**' factor] +atom_expr: ['await'] atom trailer* atom: ('(' [yield_expr|testlist_comp] ')' | '[' [testlist_comp] ']' | '{' [dictorsetmaker] '}' | diff --git a/Include/graminit.h b/Include/graminit.h index 9be336f3f909c8..d84f2aef3a0220 100644 --- a/Include/graminit.h +++ b/Include/graminit.h @@ -67,25 +67,24 @@ #define term 320 #define factor 321 #define power 322 -#define await_expr 323 -#define atom_expr 324 -#define atom 325 -#define testlist_comp 326 -#define trailer 327 -#define subscriptlist 328 -#define subscript 329 -#define sliceop 330 -#define exprlist 331 -#define testlist 332 -#define dictorsetmaker 333 -#define classdef 334 -#define arglist 335 -#define argument 336 -#define comp_for_or_async 337 -#define comp_iter 338 -#define comp_async_for 339 -#define comp_for 340 -#define comp_if 341 -#define encoding_decl 342 -#define yield_expr 343 -#define yield_arg 344 +#define atom_expr 323 +#define atom 324 +#define testlist_comp 325 +#define trailer 326 +#define subscriptlist 327 +#define subscript 328 +#define sliceop 329 +#define exprlist 330 +#define testlist 331 +#define dictorsetmaker 332 +#define classdef 333 +#define arglist 334 +#define argument 335 +#define comp_for_or_async 336 +#define comp_iter 337 +#define comp_async_for 338 +#define comp_for 339 +#define comp_if 340 +#define encoding_decl 341 +#define yield_expr 342 +#define yield_arg 343 diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index e98fdbd2fb561e..86d08a939e25c6 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -679,16 +679,16 @@ def test_missing_import_source(self): def test_illegal_encoding(self): # Illegal encoding declaration tree = \ - (342, + (339, (257, (0, ''))) self.check_bad_tree(tree, "missed encoding") tree = \ - (342, + (339, (257, (0, '')), b'iso-8859-1') self.check_bad_tree(tree, "non-string encoding") tree = \ - (342, + (339, (257, (0, '')), '\udcff') with self.assertRaises(UnicodeEncodeError): diff --git a/Python/ast.c b/Python/ast.c index e4eea49444b572..d0aa6f4b38eef0 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -2447,19 +2447,27 @@ ast_for_factor(struct compiling *c, const node *n) static expr_ty ast_for_atom_expr(struct compiling *c, const node *n) { - int i, nch; + int i, nch, start = 0; expr_ty e, tmp; REQ(n, atom_expr); nch = NCH(n); - e = ast_for_atom(c, CHILD(n, 0)); + if (TYPE(CHILD(n, 0)) == NAME && strcmp(STR(CHILD(n, 0)), "await") == 0) { + start = 1; + assert(nch > 1); + } + + e = ast_for_atom(c, CHILD(n, start)); if (!e) return NULL; if (nch == 1) return e; + if (start && nch == 2) { + return Await(e, LINENO(n), n->n_col_offset, c->c_arena); + } - for (i = 1; i < nch; i++) { + for (i = start + 1; i < nch; i++) { node *ch = CHILD(n, i); if (TYPE(ch) != trailer) break; @@ -2471,30 +2479,11 @@ ast_for_atom_expr(struct compiling *c, const node *n) e = tmp; } - return e; -} - -static expr_ty -ast_for_await_expr(struct compiling* c, const node *n) -{ - int nch, start; - expr_ty e; - - REQ(n, await_expr); - nch = NCH(n); - - if (nch == 2) { - start = 1; - } else { - assert(nch == 1); - start = 0; + if (start) { + /* there was an AWAIT */ + return Await(e, LINENO(n), n->n_col_offset, c->c_arena); } - e = ast_for_atom_expr(c, CHILD(n, start)); - if (!e) - return NULL; - if (nch == 1) - return e; - return Await(e, LINENO(n), n->n_col_offset, c->c_arena); + return e; } static expr_ty @@ -2504,7 +2493,7 @@ ast_for_power(struct compiling *c, const node *n) */ expr_ty e; REQ(n, power); - e = ast_for_await_expr(c, CHILD(n, 0)); + e = ast_for_atom_expr(c, CHILD(n, 0)); if (!e) return NULL; if (NCH(n) == 1) diff --git a/Python/graminit.c b/Python/graminit.c index 5ff3ba6a26a917..3c880d70761dad 100644 --- a/Python/graminit.c +++ b/Python/graminit.c @@ -1440,528 +1440,518 @@ static arc arcs_67_0[2] = { static arc arcs_67_1[1] = { {152, 2}, }; -static arc arcs_67_2[1] = { +static arc arcs_67_2[2] = { + {153, 2}, {0, 2}, }; static state states_67[3] = { {2, arcs_67_0}, {1, arcs_67_1}, - {1, arcs_67_2}, + {2, arcs_67_2}, }; -static arc arcs_68_0[1] = { - {153, 1}, -}; -static arc arcs_68_1[2] = { - {154, 1}, - {0, 1}, -}; -static state states_68[2] = { - {1, arcs_68_0}, - {2, arcs_68_1}, -}; -static arc arcs_69_0[10] = { +static arc arcs_68_0[10] = { {13, 1}, - {156, 2}, - {158, 3}, + {155, 2}, + {157, 3}, {23, 4}, - {161, 4}, - {162, 5}, + {160, 4}, + {161, 5}, {83, 4}, + {162, 4}, {163, 4}, {164, 4}, - {165, 4}, }; -static arc arcs_69_1[3] = { +static arc arcs_68_1[3] = { {50, 6}, - {155, 6}, + {154, 6}, {15, 4}, }; -static arc arcs_69_2[2] = { - {155, 7}, - {157, 4}, +static arc arcs_68_2[2] = { + {154, 7}, + {156, 4}, }; -static arc arcs_69_3[2] = { - {159, 8}, - {160, 4}, +static arc arcs_68_3[2] = { + {158, 8}, + {159, 4}, }; -static arc arcs_69_4[1] = { +static arc arcs_68_4[1] = { {0, 4}, }; -static arc arcs_69_5[2] = { - {162, 5}, +static arc arcs_68_5[2] = { + {161, 5}, {0, 5}, }; -static arc arcs_69_6[1] = { +static arc arcs_68_6[1] = { {15, 4}, }; -static arc arcs_69_7[1] = { - {157, 4}, +static arc arcs_68_7[1] = { + {156, 4}, }; -static arc arcs_69_8[1] = { - {160, 4}, +static arc arcs_68_8[1] = { + {159, 4}, }; -static state states_69[9] = { - {10, arcs_69_0}, - {3, arcs_69_1}, - {2, arcs_69_2}, - {2, arcs_69_3}, - {1, arcs_69_4}, - {2, arcs_69_5}, - {1, arcs_69_6}, - {1, arcs_69_7}, - {1, arcs_69_8}, -}; -static arc arcs_70_0[2] = { +static state states_68[9] = { + {10, arcs_68_0}, + {3, arcs_68_1}, + {2, arcs_68_2}, + {2, arcs_68_3}, + {1, arcs_68_4}, + {2, arcs_68_5}, + {1, arcs_68_6}, + {1, arcs_68_7}, + {1, arcs_68_8}, +}; +static arc arcs_69_0[2] = { {26, 1}, {51, 1}, }; -static arc arcs_70_1[4] = { +static arc arcs_69_1[4] = { + {165, 2}, {166, 2}, - {167, 2}, {32, 3}, {0, 1}, }; -static arc arcs_70_2[1] = { +static arc arcs_69_2[1] = { {0, 2}, }; -static arc arcs_70_3[3] = { +static arc arcs_69_3[3] = { {26, 4}, {51, 4}, {0, 3}, }; -static arc arcs_70_4[2] = { +static arc arcs_69_4[2] = { {32, 3}, {0, 4}, }; -static state states_70[5] = { - {2, arcs_70_0}, - {4, arcs_70_1}, - {1, arcs_70_2}, - {3, arcs_70_3}, - {2, arcs_70_4}, +static state states_69[5] = { + {2, arcs_69_0}, + {4, arcs_69_1}, + {1, arcs_69_2}, + {3, arcs_69_3}, + {2, arcs_69_4}, }; -static arc arcs_71_0[3] = { +static arc arcs_70_0[3] = { {13, 1}, - {156, 2}, + {155, 2}, {82, 3}, }; -static arc arcs_71_1[2] = { +static arc arcs_70_1[2] = { {14, 4}, {15, 5}, }; -static arc arcs_71_2[1] = { - {168, 6}, +static arc arcs_70_2[1] = { + {167, 6}, }; -static arc arcs_71_3[1] = { +static arc arcs_70_3[1] = { {23, 5}, }; -static arc arcs_71_4[1] = { +static arc arcs_70_4[1] = { {15, 5}, }; -static arc arcs_71_5[1] = { +static arc arcs_70_5[1] = { {0, 5}, }; -static arc arcs_71_6[1] = { - {157, 5}, +static arc arcs_70_6[1] = { + {156, 5}, }; -static state states_71[7] = { - {3, arcs_71_0}, - {2, arcs_71_1}, - {1, arcs_71_2}, - {1, arcs_71_3}, - {1, arcs_71_4}, - {1, arcs_71_5}, - {1, arcs_71_6}, +static state states_70[7] = { + {3, arcs_70_0}, + {2, arcs_70_1}, + {1, arcs_70_2}, + {1, arcs_70_3}, + {1, arcs_70_4}, + {1, arcs_70_5}, + {1, arcs_70_6}, }; -static arc arcs_72_0[1] = { - {169, 1}, +static arc arcs_71_0[1] = { + {168, 1}, }; -static arc arcs_72_1[2] = { +static arc arcs_71_1[2] = { {32, 2}, {0, 1}, }; -static arc arcs_72_2[2] = { - {169, 1}, +static arc arcs_71_2[2] = { + {168, 1}, {0, 2}, }; -static state states_72[3] = { - {1, arcs_72_0}, - {2, arcs_72_1}, - {2, arcs_72_2}, +static state states_71[3] = { + {1, arcs_71_0}, + {2, arcs_71_1}, + {2, arcs_71_2}, }; -static arc arcs_73_0[2] = { +static arc arcs_72_0[2] = { {26, 1}, {27, 2}, }; -static arc arcs_73_1[2] = { +static arc arcs_72_1[2] = { {27, 2}, {0, 1}, }; -static arc arcs_73_2[3] = { +static arc arcs_72_2[3] = { {26, 3}, - {170, 4}, + {169, 4}, {0, 2}, }; -static arc arcs_73_3[2] = { - {170, 4}, +static arc arcs_72_3[2] = { + {169, 4}, {0, 3}, }; -static arc arcs_73_4[1] = { +static arc arcs_72_4[1] = { {0, 4}, }; -static state states_73[5] = { - {2, arcs_73_0}, - {2, arcs_73_1}, - {3, arcs_73_2}, - {2, arcs_73_3}, - {1, arcs_73_4}, +static state states_72[5] = { + {2, arcs_72_0}, + {2, arcs_72_1}, + {3, arcs_72_2}, + {2, arcs_72_3}, + {1, arcs_72_4}, }; -static arc arcs_74_0[1] = { +static arc arcs_73_0[1] = { {27, 1}, }; -static arc arcs_74_1[2] = { +static arc arcs_73_1[2] = { {26, 2}, {0, 1}, }; -static arc arcs_74_2[1] = { +static arc arcs_73_2[1] = { {0, 2}, }; -static state states_74[3] = { - {1, arcs_74_0}, - {2, arcs_74_1}, - {1, arcs_74_2}, +static state states_73[3] = { + {1, arcs_73_0}, + {2, arcs_73_1}, + {1, arcs_73_2}, }; -static arc arcs_75_0[2] = { +static arc arcs_74_0[2] = { {108, 1}, {51, 1}, }; -static arc arcs_75_1[2] = { +static arc arcs_74_1[2] = { {32, 2}, {0, 1}, }; -static arc arcs_75_2[3] = { +static arc arcs_74_2[3] = { {108, 1}, {51, 1}, {0, 2}, }; -static state states_75[3] = { - {2, arcs_75_0}, - {2, arcs_75_1}, - {3, arcs_75_2}, +static state states_74[3] = { + {2, arcs_74_0}, + {2, arcs_74_1}, + {3, arcs_74_2}, }; -static arc arcs_76_0[1] = { +static arc arcs_75_0[1] = { {26, 1}, }; -static arc arcs_76_1[2] = { +static arc arcs_75_1[2] = { {32, 2}, {0, 1}, }; -static arc arcs_76_2[2] = { +static arc arcs_75_2[2] = { {26, 1}, {0, 2}, }; -static state states_76[3] = { - {1, arcs_76_0}, - {2, arcs_76_1}, - {2, arcs_76_2}, +static state states_75[3] = { + {1, arcs_75_0}, + {2, arcs_75_1}, + {2, arcs_75_2}, }; -static arc arcs_77_0[3] = { +static arc arcs_76_0[3] = { {26, 1}, {34, 2}, {51, 3}, }; -static arc arcs_77_1[5] = { +static arc arcs_76_1[5] = { {27, 4}, + {165, 5}, {166, 5}, - {167, 5}, {32, 6}, {0, 1}, }; -static arc arcs_77_2[1] = { +static arc arcs_76_2[1] = { {108, 7}, }; -static arc arcs_77_3[4] = { +static arc arcs_76_3[4] = { + {165, 5}, {166, 5}, - {167, 5}, {32, 6}, {0, 3}, }; -static arc arcs_77_4[1] = { +static arc arcs_76_4[1] = { {26, 7}, }; -static arc arcs_77_5[1] = { +static arc arcs_76_5[1] = { {0, 5}, }; -static arc arcs_77_6[3] = { +static arc arcs_76_6[3] = { {26, 8}, {51, 8}, {0, 6}, }; -static arc arcs_77_7[4] = { +static arc arcs_76_7[4] = { + {165, 5}, {166, 5}, - {167, 5}, {32, 9}, {0, 7}, }; -static arc arcs_77_8[2] = { +static arc arcs_76_8[2] = { {32, 6}, {0, 8}, }; -static arc arcs_77_9[3] = { +static arc arcs_76_9[3] = { {26, 10}, {34, 11}, {0, 9}, }; -static arc arcs_77_10[1] = { +static arc arcs_76_10[1] = { {27, 12}, }; -static arc arcs_77_11[1] = { +static arc arcs_76_11[1] = { {108, 13}, }; -static arc arcs_77_12[1] = { +static arc arcs_76_12[1] = { {26, 13}, }; -static arc arcs_77_13[2] = { +static arc arcs_76_13[2] = { {32, 9}, {0, 13}, }; -static state states_77[14] = { - {3, arcs_77_0}, - {5, arcs_77_1}, - {1, arcs_77_2}, - {4, arcs_77_3}, - {1, arcs_77_4}, - {1, arcs_77_5}, - {3, arcs_77_6}, - {4, arcs_77_7}, - {2, arcs_77_8}, - {3, arcs_77_9}, - {1, arcs_77_10}, - {1, arcs_77_11}, - {1, arcs_77_12}, - {2, arcs_77_13}, -}; -static arc arcs_78_0[1] = { - {171, 1}, -}; -static arc arcs_78_1[1] = { +static state states_76[14] = { + {3, arcs_76_0}, + {5, arcs_76_1}, + {1, arcs_76_2}, + {4, arcs_76_3}, + {1, arcs_76_4}, + {1, arcs_76_5}, + {3, arcs_76_6}, + {4, arcs_76_7}, + {2, arcs_76_8}, + {3, arcs_76_9}, + {1, arcs_76_10}, + {1, arcs_76_11}, + {1, arcs_76_12}, + {2, arcs_76_13}, +}; +static arc arcs_77_0[1] = { + {170, 1}, +}; +static arc arcs_77_1[1] = { {23, 2}, }; -static arc arcs_78_2[2] = { +static arc arcs_77_2[2] = { {13, 3}, {27, 4}, }; -static arc arcs_78_3[2] = { +static arc arcs_77_3[2] = { {14, 5}, {15, 6}, }; -static arc arcs_78_4[1] = { +static arc arcs_77_4[1] = { {28, 7}, }; -static arc arcs_78_5[1] = { +static arc arcs_77_5[1] = { {15, 6}, }; -static arc arcs_78_6[1] = { +static arc arcs_77_6[1] = { {27, 4}, }; -static arc arcs_78_7[1] = { +static arc arcs_77_7[1] = { {0, 7}, }; -static state states_78[8] = { - {1, arcs_78_0}, - {1, arcs_78_1}, - {2, arcs_78_2}, - {2, arcs_78_3}, - {1, arcs_78_4}, - {1, arcs_78_5}, - {1, arcs_78_6}, - {1, arcs_78_7}, +static state states_77[8] = { + {1, arcs_77_0}, + {1, arcs_77_1}, + {2, arcs_77_2}, + {2, arcs_77_3}, + {1, arcs_77_4}, + {1, arcs_77_5}, + {1, arcs_77_6}, + {1, arcs_77_7}, }; -static arc arcs_79_0[1] = { - {172, 1}, +static arc arcs_78_0[1] = { + {171, 1}, }; -static arc arcs_79_1[2] = { +static arc arcs_78_1[2] = { {32, 2}, {0, 1}, }; -static arc arcs_79_2[2] = { - {172, 1}, +static arc arcs_78_2[2] = { + {171, 1}, {0, 2}, }; -static state states_79[3] = { - {1, arcs_79_0}, - {2, arcs_79_1}, - {2, arcs_79_2}, +static state states_78[3] = { + {1, arcs_78_0}, + {2, arcs_78_1}, + {2, arcs_78_2}, }; -static arc arcs_80_0[3] = { +static arc arcs_79_0[3] = { {26, 1}, {34, 2}, {33, 2}, }; -static arc arcs_80_1[3] = { - {173, 3}, +static arc arcs_79_1[3] = { + {172, 3}, {31, 2}, {0, 1}, }; -static arc arcs_80_2[1] = { +static arc arcs_79_2[1] = { {26, 3}, }; -static arc arcs_80_3[1] = { +static arc arcs_79_3[1] = { {0, 3}, }; -static state states_80[4] = { - {3, arcs_80_0}, - {3, arcs_80_1}, - {1, arcs_80_2}, - {1, arcs_80_3}, +static state states_79[4] = { + {3, arcs_79_0}, + {3, arcs_79_1}, + {1, arcs_79_2}, + {1, arcs_79_3}, }; -static arc arcs_81_0[2] = { - {167, 1}, +static arc arcs_80_0[2] = { {166, 1}, + {165, 1}, }; -static arc arcs_81_1[1] = { +static arc arcs_80_1[1] = { {0, 1}, }; -static state states_81[2] = { - {2, arcs_81_0}, - {1, arcs_81_1}, +static state states_80[2] = { + {2, arcs_80_0}, + {1, arcs_80_1}, }; -static arc arcs_82_0[3] = { - {167, 1}, +static arc arcs_81_0[3] = { {166, 1}, - {175, 1}, + {165, 1}, + {174, 1}, }; -static arc arcs_82_1[1] = { +static arc arcs_81_1[1] = { {0, 1}, }; -static state states_82[2] = { - {3, arcs_82_0}, - {1, arcs_82_1}, +static state states_81[2] = { + {3, arcs_81_0}, + {1, arcs_81_1}, }; -static arc arcs_83_0[1] = { +static arc arcs_82_0[1] = { {21, 1}, }; -static arc arcs_83_1[1] = { +static arc arcs_82_1[1] = { {101, 2}, }; -static arc arcs_83_2[1] = { +static arc arcs_82_2[1] = { {66, 3}, }; -static arc arcs_83_3[1] = { +static arc arcs_82_3[1] = { {102, 4}, }; -static arc arcs_83_4[1] = { +static arc arcs_82_4[1] = { {112, 5}, }; -static arc arcs_83_5[2] = { - {174, 6}, +static arc arcs_82_5[2] = { + {173, 6}, {0, 5}, }; -static arc arcs_83_6[1] = { +static arc arcs_82_6[1] = { {0, 6}, }; -static state states_83[7] = { - {1, arcs_83_0}, - {1, arcs_83_1}, - {1, arcs_83_2}, - {1, arcs_83_3}, - {1, arcs_83_4}, - {2, arcs_83_5}, - {1, arcs_83_6}, +static state states_82[7] = { + {1, arcs_82_0}, + {1, arcs_82_1}, + {1, arcs_82_2}, + {1, arcs_82_3}, + {1, arcs_82_4}, + {2, arcs_82_5}, + {1, arcs_82_6}, }; -static arc arcs_84_0[1] = { +static arc arcs_83_0[1] = { {101, 1}, }; -static arc arcs_84_1[1] = { +static arc arcs_83_1[1] = { {66, 2}, }; -static arc arcs_84_2[1] = { +static arc arcs_83_2[1] = { {102, 3}, }; -static arc arcs_84_3[1] = { +static arc arcs_83_3[1] = { {112, 4}, }; -static arc arcs_84_4[2] = { - {174, 5}, +static arc arcs_83_4[2] = { + {173, 5}, {0, 4}, }; -static arc arcs_84_5[1] = { +static arc arcs_83_5[1] = { {0, 5}, }; -static state states_84[6] = { - {1, arcs_84_0}, - {1, arcs_84_1}, - {1, arcs_84_2}, - {1, arcs_84_3}, - {2, arcs_84_4}, - {1, arcs_84_5}, +static state states_83[6] = { + {1, arcs_83_0}, + {1, arcs_83_1}, + {1, arcs_83_2}, + {1, arcs_83_3}, + {2, arcs_83_4}, + {1, arcs_83_5}, }; -static arc arcs_85_0[1] = { +static arc arcs_84_0[1] = { {97, 1}, }; -static arc arcs_85_1[1] = { +static arc arcs_84_1[1] = { {114, 2}, }; -static arc arcs_85_2[2] = { - {174, 3}, +static arc arcs_84_2[2] = { + {173, 3}, {0, 2}, }; -static arc arcs_85_3[1] = { +static arc arcs_84_3[1] = { {0, 3}, }; -static state states_85[4] = { - {1, arcs_85_0}, - {1, arcs_85_1}, - {2, arcs_85_2}, - {1, arcs_85_3}, +static state states_84[4] = { + {1, arcs_84_0}, + {1, arcs_84_1}, + {2, arcs_84_2}, + {1, arcs_84_3}, }; -static arc arcs_86_0[1] = { +static arc arcs_85_0[1] = { {23, 1}, }; -static arc arcs_86_1[1] = { +static arc arcs_85_1[1] = { {0, 1}, }; -static state states_86[2] = { - {1, arcs_86_0}, - {1, arcs_86_1}, +static state states_85[2] = { + {1, arcs_85_0}, + {1, arcs_85_1}, }; -static arc arcs_87_0[1] = { - {177, 1}, +static arc arcs_86_0[1] = { + {176, 1}, }; -static arc arcs_87_1[2] = { - {178, 2}, +static arc arcs_86_1[2] = { + {177, 2}, {0, 1}, }; -static arc arcs_87_2[1] = { +static arc arcs_86_2[1] = { {0, 2}, }; -static state states_87[3] = { - {1, arcs_87_0}, - {2, arcs_87_1}, - {1, arcs_87_2}, +static state states_86[3] = { + {1, arcs_86_0}, + {2, arcs_86_1}, + {1, arcs_86_2}, }; -static arc arcs_88_0[2] = { +static arc arcs_87_0[2] = { {77, 1}, {9, 2}, }; -static arc arcs_88_1[1] = { +static arc arcs_87_1[1] = { {26, 2}, }; -static arc arcs_88_2[1] = { +static arc arcs_87_2[1] = { {0, 2}, }; -static state states_88[3] = { - {2, arcs_88_0}, - {1, arcs_88_1}, - {1, arcs_88_2}, +static state states_87[3] = { + {2, arcs_87_0}, + {1, arcs_87_1}, + {1, arcs_87_2}, }; -static dfa dfas[89] = { +static dfa dfas[88] = { {256, "single_input", 0, 3, states_0, - "\004\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\120\076\010\002"}, + "\004\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\004\001"}, {257, "file_input", 0, 2, states_1, - "\204\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\120\076\010\002"}, + "\204\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\004\001"}, {258, "eval_input", 0, 3, states_2, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {259, "decorator", 0, 7, states_3, "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {260, "decorators", 0, 2, states_4, @@ -1983,17 +1973,17 @@ static dfa dfas[89] = { {268, "vfpdef", 0, 2, states_12, "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {269, "stmt", 0, 2, states_13, - "\000\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\120\076\010\002"}, + "\000\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\004\001"}, {270, "simple_stmt", 0, 4, states_14, - "\000\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\120\076\000\002"}, + "\000\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\000\001"}, {271, "small_stmt", 0, 2, states_15, - "\000\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\120\076\000\002"}, + "\000\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\000\001"}, {272, "expr_stmt", 0, 6, states_16, - "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, + "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {273, "annassign", 0, 5, states_17, "\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {274, "testlist_star_expr", 0, 3, states_18, - "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, + "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {275, "augassign", 0, 2, states_19, "\000\000\000\000\000\000\360\377\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {276, "del_stmt", 0, 3, states_20, @@ -2001,7 +1991,7 @@ static dfa dfas[89] = { {277, "pass_stmt", 0, 2, states_21, "\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {278, "flow_stmt", 0, 2, states_22, - "\000\000\000\000\000\000\000\000\000\036\000\000\000\000\000\000\000\000\000\000\000\000\002"}, + "\000\000\000\000\000\000\000\000\000\036\000\000\000\000\000\000\000\000\000\000\000\000\001"}, {279, "break_stmt", 0, 2, states_23, "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {280, "continue_stmt", 0, 2, states_24, @@ -2009,7 +1999,7 @@ static dfa dfas[89] = { {281, "return_stmt", 0, 3, states_25, "\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {282, "yield_stmt", 0, 2, states_26, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"}, {283, "raise_stmt", 0, 5, states_27, "\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {284, "import_stmt", 0, 2, states_28, @@ -2035,7 +2025,7 @@ static dfa dfas[89] = { {294, "assert_stmt", 0, 5, states_38, "\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000"}, {295, "compound_stmt", 0, 2, states_39, - "\000\010\140\000\000\000\000\000\000\000\000\000\262\004\000\000\000\000\000\000\000\010\000"}, + "\000\010\140\000\000\000\000\000\000\000\000\000\262\004\000\000\000\000\000\000\000\004\000"}, {296, "async_stmt", 0, 3, states_40, "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {297, "if_stmt", 0, 8, states_41, @@ -2049,93 +2039,91 @@ static dfa dfas[89] = { {301, "with_stmt", 0, 5, states_45, "\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000"}, {302, "with_item", 0, 4, states_46, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {303, "except_clause", 0, 5, states_47, "\000\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"}, {304, "suite", 0, 5, states_48, - "\004\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\120\076\000\002"}, + "\004\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\000\001"}, {305, "test", 0, 6, states_49, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {306, "test_nocond", 0, 2, states_50, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {307, "lambdef", 0, 5, states_51, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000"}, {308, "lambdef_nocond", 0, 5, states_52, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000"}, {309, "or_test", 0, 2, states_53, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\120\076\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000\000"}, {310, "and_test", 0, 2, states_54, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\120\076\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000\000"}, {311, "not_test", 0, 3, states_55, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\120\076\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000\000"}, {312, "comparison", 0, 2, states_56, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {313, "comp_op", 0, 4, states_57, "\000\000\000\000\000\000\000\000\000\000\000\000\100\000\000\362\017\000\000\000\000\000\000"}, {314, "star_expr", 0, 3, states_58, "\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {315, "expr", 0, 2, states_59, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {316, "xor_expr", 0, 2, states_60, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {317, "and_expr", 0, 2, states_61, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {318, "shift_expr", 0, 2, states_62, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {319, "arith_expr", 0, 2, states_63, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {320, "term", 0, 2, states_64, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {321, "factor", 0, 3, states_65, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {322, "power", 0, 4, states_66, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\200\120\076\000\000"}, - {323, "await_expr", 0, 3, states_67, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\200\120\076\000\000"}, - {324, "atom_expr", 0, 2, states_68, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\120\076\000\000"}, - {325, "atom", 0, 9, states_69, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\120\076\000\000"}, - {326, "testlist_comp", 0, 5, states_70, - "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, - {327, "trailer", 0, 7, states_71, - "\000\040\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\020\000\000\000"}, - {328, "subscriptlist", 0, 3, states_72, - "\000\040\200\010\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, - {329, "subscript", 0, 5, states_73, - "\000\040\200\010\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, - {330, "sliceop", 0, 3, states_74, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\200\050\037\000\000"}, + {323, "atom_expr", 0, 3, states_67, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\200\050\037\000\000"}, + {324, "atom", 0, 9, states_68, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\050\037\000\000"}, + {325, "testlist_comp", 0, 5, states_69, + "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + {326, "trailer", 0, 7, states_70, + "\000\040\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\010\000\000\000"}, + {327, "subscriptlist", 0, 3, states_71, + "\000\040\200\010\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + {328, "subscript", 0, 5, states_72, + "\000\040\200\010\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + {329, "sliceop", 0, 3, states_73, "\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {331, "exprlist", 0, 3, states_75, - "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\000\000\000\300\220\120\076\000\000"}, - {332, "testlist", 0, 3, states_76, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, - {333, "dictorsetmaker", 0, 14, states_77, - "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, - {334, "classdef", 0, 8, states_78, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010\000"}, - {335, "arglist", 0, 3, states_79, - "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, - {336, "argument", 0, 4, states_80, - "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\120\076\000\000"}, - {337, "comp_for_or_async", 0, 2, states_81, + {330, "exprlist", 0, 3, states_74, + "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, + {331, "testlist", 0, 3, states_75, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + {332, "dictorsetmaker", 0, 14, states_76, + "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + {333, "classdef", 0, 8, states_77, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000"}, + {334, "arglist", 0, 3, states_78, + "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + {335, "argument", 0, 4, states_79, + "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + {336, "comp_for_or_async", 0, 2, states_80, "\000\000\040\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"}, - {338, "comp_iter", 0, 2, states_82, + {337, "comp_iter", 0, 2, states_81, "\000\000\040\000\000\000\000\000\000\000\000\000\042\000\000\000\000\000\000\000\000\000\000"}, - {339, "comp_async_for", 0, 7, states_83, + {338, "comp_async_for", 0, 7, states_82, "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {340, "comp_for", 0, 6, states_84, + {339, "comp_for", 0, 6, states_83, "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"}, - {341, "comp_if", 0, 4, states_85, + {340, "comp_if", 0, 4, states_84, "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000"}, - {342, "encoding_decl", 0, 2, states_86, + {341, "encoding_decl", 0, 2, states_85, "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {343, "yield_expr", 0, 3, states_87, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002"}, - {344, "yield_arg", 0, 3, states_88, - "\000\040\200\000\000\000\000\000\000\040\010\000\000\000\020\002\000\300\220\120\076\000\000"}, + {342, "yield_expr", 0, 3, states_86, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"}, + {343, "yield_arg", 0, 3, states_87, + "\000\040\200\000\000\000\000\000\000\040\010\000\000\000\020\002\000\300\220\050\037\000\000"}, }; -static label labels[179] = { +static label labels[178] = { {0, "EMPTY"}, {256, 0}, {4, 0}, @@ -2145,16 +2133,16 @@ static label labels[179] = { {269, 0}, {0, 0}, {258, 0}, - {332, 0}, + {331, 0}, {259, 0}, {49, 0}, {291, 0}, {7, 0}, - {335, 0}, + {334, 0}, {8, 0}, {260, 0}, {261, 0}, - {334, 0}, + {333, 0}, {263, 0}, {262, 0}, {1, "async"}, @@ -2186,7 +2174,7 @@ static label labels[179] = { {274, 0}, {273, 0}, {275, 0}, - {343, 0}, + {342, 0}, {314, 0}, {36, 0}, {37, 0}, @@ -2202,7 +2190,7 @@ static label labels[179] = { {46, 0}, {48, 0}, {1, "del"}, - {331, 0}, + {330, 0}, {1, "pass"}, {279, 0}, {280, 0}, @@ -2289,36 +2277,35 @@ static label labels[179] = { {323, 0}, {1, "await"}, {324, 0}, - {325, 0}, - {327, 0}, {326, 0}, + {325, 0}, {9, 0}, {10, 0}, {25, 0}, - {333, 0}, + {332, 0}, {26, 0}, {2, 0}, {3, 0}, {1, "None"}, {1, "True"}, {1, "False"}, - {340, 0}, {339, 0}, + {338, 0}, + {327, 0}, {328, 0}, {329, 0}, - {330, 0}, {1, "class"}, + {335, 0}, {336, 0}, {337, 0}, - {338, 0}, + {340, 0}, {341, 0}, - {342, 0}, {1, "yield"}, - {344, 0}, + {343, 0}, }; grammar _PyParser_Grammar = { - 89, + 88, dfas, - {179, labels}, + {178, labels}, 256 }; From e987d5073ac8ab230c1f9259aa68ccacbfb7ae21 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 22 Jul 2017 09:28:48 -0700 Subject: [PATCH 16/26] undo async_for-related changes test_parser still fails for some reason --- Grammar/Grammar | 14 +- Include/graminit.h | 14 +- Python/ast.c | 36 ++--- Python/graminit.c | 384 ++++++++++++++++++++------------------------- 4 files changed, 196 insertions(+), 252 deletions(-) diff --git a/Grammar/Grammar b/Grammar/Grammar index f02f7863d4310d..5beb068eb01d5b 100644 --- a/Grammar/Grammar +++ b/Grammar/Grammar @@ -108,7 +108,7 @@ atom: ('(' [yield_expr|testlist_comp] ')' | '[' [testlist_comp] ']' | '{' [dictorsetmaker] '}' | NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False') -testlist_comp: (test|star_expr) ( comp_for | comp_async_for | (',' (test|star_expr))* [','] ) +testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] ) trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME subscriptlist: subscript (',' subscript)* [','] subscript: test | [test] ':' [test] [sliceop] @@ -116,9 +116,9 @@ sliceop: ':' [test] exprlist: (expr|star_expr) (',' (expr|star_expr))* [','] testlist: test (',' test)* [','] dictorsetmaker: ( ((test ':' test | '**' expr) - (comp_for | comp_async_for | (',' (test ':' test | '**' expr))* [','])) | + (comp_for | (',' (test ':' test | '**' expr))* [','])) | ((test | star_expr) - (comp_for | comp_async_for | (',' (test | star_expr))* [','])) ) + (comp_for | (',' (test | star_expr))* [','])) ) classdef: 'class' NAME ['(' [arglist] ')'] ':' suite @@ -133,15 +133,13 @@ arglist: argument (',' argument)* [','] # Illegal combinations and orderings are blocked in ast.c: # multiple (test comp_for) arguments are blocked; keyword unpackings # that precede iterable unpackings are blocked; etc. -argument: ( test [comp_for_or_async] | +argument: ( test [comp_for] | test '=' test | '**' test | '*' test ) -comp_for_or_async: comp_async_for | comp_for -comp_iter: comp_async_for | comp_for | comp_if -comp_async_for: 'async' 'for' exprlist 'in' or_test [comp_iter] -comp_for: 'for' exprlist 'in' or_test [comp_iter] +comp_iter: comp_for | comp_if +comp_for: ['async'] 'for' exprlist 'in' or_test [comp_iter] comp_if: 'if' test_nocond [comp_iter] # not used in grammar, but may appear in "node" passed from Parser to Compiler diff --git a/Include/graminit.h b/Include/graminit.h index d84f2aef3a0220..e9b4a9385956b1 100644 --- a/Include/graminit.h +++ b/Include/graminit.h @@ -80,11 +80,9 @@ #define classdef 333 #define arglist 334 #define argument 335 -#define comp_for_or_async 336 -#define comp_iter 337 -#define comp_async_for 338 -#define comp_for 339 -#define comp_if 340 -#define encoding_decl 341 -#define yield_expr 342 -#define yield_arg 343 +#define comp_iter 336 +#define comp_for 337 +#define comp_if 338 +#define encoding_decl 339 +#define yield_expr 340 +#define yield_arg 341 diff --git a/Python/ast.c b/Python/ast.c index d0aa6f4b38eef0..dc1bda1c6cc8af 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -1761,8 +1761,8 @@ count_comp_fors(struct compiling *c, const node *n) count_comp_for: is_async = 0; n_fors++; - assert(TYPE(n) == comp_for || TYPE(n) == comp_async_for); - if (TYPE(n) == comp_async_for) { + REQ(n, comp_for); + if (TYPE(CHILD(n, 0)) == NAME && strcmp(STR(CHILD(n, 0)), "async") == 0) { is_async = 1; } if (NCH(n) == (5 + is_async)) { @@ -1774,7 +1774,7 @@ count_comp_fors(struct compiling *c, const node *n) count_comp_iter: REQ(n, comp_iter); n = CHILD(n, 0); - if (TYPE(n) == comp_for || TYPE(n) == comp_async_for) + if (TYPE(n) == comp_for) goto count_comp_for; else if (TYPE(n) == comp_if) { if (NCH(n) == 3) { @@ -1803,7 +1803,7 @@ count_comp_ifs(struct compiling *c, const node *n) while (1) { REQ(n, comp_iter); - if (TYPE(CHILD(n, 0)) == comp_for || TYPE(CHILD(n, 0)) == comp_async_for) + if (TYPE(CHILD(n, 0)) == comp_for) return n_ifs; n = CHILD(n, 0); REQ(n, comp_if); @@ -1835,9 +1835,9 @@ ast_for_comprehension(struct compiling *c, const node *n) node *for_ch; int is_async = 0; - assert(TYPE(n) == comp_for || TYPE(n) == comp_async_for); + REQ(n, comp_for); - if (TYPE(n) == comp_async_for) { + if (TYPE(CHILD(n, 0)) == NAME && strcmp(STR(CHILD(n, 0)), "async") == 0) { is_async = 1; } @@ -1887,7 +1887,7 @@ ast_for_comprehension(struct compiling *c, const node *n) if (NCH(n) == 3) n = CHILD(n, 2); } - /* on exit, must guarantee that n is a comp_for or comp_async_for */ + /* on exit, must guarantee that n is a comp_for */ if (TYPE(n) == comp_iter) n = CHILD(n, 0); comp->ifs = ifs; @@ -1917,11 +1917,7 @@ ast_for_itercomp(struct compiling *c, const node *n, int type) return NULL; } - ch = CHILD(n, 1); - if (TYPE(ch) == comp_for_or_async) - ch = CHILD(ch, 0); - - comps = ast_for_comprehension(c, ch); + comps = ast_for_comprehension(c, CHILD(n, 1)); if (!comps) return NULL; @@ -2154,7 +2150,7 @@ ast_for_atom(struct compiling *c, const node *n) return ast_for_expr(c, ch); /* testlist_comp: test ( comp_for | (',' test)* [','] ) */ - if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == comp_for || TYPE(CHILD(ch, 1)) == comp_async_for)) + if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == comp_for)) return ast_for_genexp(c, ch); return ast_for_testlist(c, ch); @@ -2194,13 +2190,12 @@ ast_for_atom(struct compiling *c, const node *n) res = ast_for_setdisplay(c, ch); } else if (NCH(ch) > 1 && - (TYPE(CHILD(ch, 1)) == comp_for || TYPE(CHILD(ch, 1)) == comp_async_for)) { + TYPE(CHILD(ch, 1)) == comp_for) { /* It's a set comprehension. */ res = ast_for_setcomp(c, ch); } else if (NCH(ch) > 3 - is_dict && - (TYPE(CHILD(ch, 3 - is_dict)) == comp_for || - TYPE(CHILD(ch, 3 - is_dict)) == comp_async_for)) { + TYPE(CHILD(ch, 3 - is_dict)) == comp_for) { /* It's a dictionary comprehension. */ if (is_dict) { ast_error(c, n, "dict unpacking cannot be used in " @@ -2483,7 +2478,9 @@ ast_for_atom_expr(struct compiling *c, const node *n) /* there was an AWAIT */ return Await(e, LINENO(n), n->n_col_offset, c->c_arena); } - return e; + else { + return e; + } } static expr_ty @@ -2713,7 +2710,7 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func) if (TYPE(ch) == argument) { if (NCH(ch) == 1) nargs++; - else if (TYPE(CHILD(ch, 1)) == comp_for_or_async) + else if (TYPE(CHILD(ch, 1)) == comp_for) ngens++; else if (TYPE(CHILD(ch, 0)) == STAR) nargs++; @@ -2794,7 +2791,7 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func) asdl_seq_SET(keywords, nkeywords++, kw); ndoublestars++; } - else if (TYPE(CHILD(ch, 1)) == comp_for_or_async) { + else if (TYPE(CHILD(ch, 1)) == comp_for) { /* the lone generator expression */ e = ast_for_genexp(c, ch); if (!e) @@ -2861,7 +2858,6 @@ ast_for_testlist(struct compiling *c, const node* n) if (TYPE(n) == testlist_comp) { if (NCH(n) > 1) assert(TYPE(CHILD(n, 1)) != comp_for); - assert(TYPE(CHILD(n, 1)) != comp_async_for); } else { assert(TYPE(n) == testlist || diff --git a/Python/graminit.c b/Python/graminit.c index 3c880d70761dad..a4fd2ee7ba2657 100644 --- a/Python/graminit.c +++ b/Python/graminit.c @@ -1505,9 +1505,8 @@ static arc arcs_69_0[2] = { {26, 1}, {51, 1}, }; -static arc arcs_69_1[4] = { +static arc arcs_69_1[3] = { {165, 2}, - {166, 2}, {32, 3}, {0, 1}, }; @@ -1525,7 +1524,7 @@ static arc arcs_69_4[2] = { }; static state states_69[5] = { {2, arcs_69_0}, - {4, arcs_69_1}, + {3, arcs_69_1}, {1, arcs_69_2}, {3, arcs_69_3}, {2, arcs_69_4}, @@ -1540,7 +1539,7 @@ static arc arcs_70_1[2] = { {15, 5}, }; static arc arcs_70_2[1] = { - {167, 6}, + {166, 6}, }; static arc arcs_70_3[1] = { {23, 5}, @@ -1564,14 +1563,14 @@ static state states_70[7] = { {1, arcs_70_6}, }; static arc arcs_71_0[1] = { - {168, 1}, + {167, 1}, }; static arc arcs_71_1[2] = { {32, 2}, {0, 1}, }; static arc arcs_71_2[2] = { - {168, 1}, + {167, 1}, {0, 2}, }; static state states_71[3] = { @@ -1589,11 +1588,11 @@ static arc arcs_72_1[2] = { }; static arc arcs_72_2[3] = { {26, 3}, - {169, 4}, + {168, 4}, {0, 2}, }; static arc arcs_72_3[2] = { - {169, 4}, + {168, 4}, {0, 3}, }; static arc arcs_72_4[1] = { @@ -1660,19 +1659,17 @@ static arc arcs_76_0[3] = { {34, 2}, {51, 3}, }; -static arc arcs_76_1[5] = { +static arc arcs_76_1[4] = { {27, 4}, {165, 5}, - {166, 5}, {32, 6}, {0, 1}, }; static arc arcs_76_2[1] = { {108, 7}, }; -static arc arcs_76_3[4] = { +static arc arcs_76_3[3] = { {165, 5}, - {166, 5}, {32, 6}, {0, 3}, }; @@ -1687,9 +1684,8 @@ static arc arcs_76_6[3] = { {51, 8}, {0, 6}, }; -static arc arcs_76_7[4] = { +static arc arcs_76_7[3] = { {165, 5}, - {166, 5}, {32, 9}, {0, 7}, }; @@ -1717,13 +1713,13 @@ static arc arcs_76_13[2] = { }; static state states_76[14] = { {3, arcs_76_0}, - {5, arcs_76_1}, + {4, arcs_76_1}, {1, arcs_76_2}, - {4, arcs_76_3}, + {3, arcs_76_3}, {1, arcs_76_4}, {1, arcs_76_5}, {3, arcs_76_6}, - {4, arcs_76_7}, + {3, arcs_76_7}, {2, arcs_76_8}, {3, arcs_76_9}, {1, arcs_76_10}, @@ -1732,7 +1728,7 @@ static state states_76[14] = { {2, arcs_76_13}, }; static arc arcs_77_0[1] = { - {170, 1}, + {169, 1}, }; static arc arcs_77_1[1] = { {23, 2}, @@ -1768,14 +1764,14 @@ static state states_77[8] = { {1, arcs_77_7}, }; static arc arcs_78_0[1] = { - {171, 1}, + {170, 1}, }; static arc arcs_78_1[2] = { {32, 2}, {0, 1}, }; static arc arcs_78_2[2] = { - {171, 1}, + {170, 1}, {0, 2}, }; static state states_78[3] = { @@ -1789,7 +1785,7 @@ static arc arcs_79_0[3] = { {33, 2}, }; static arc arcs_79_1[3] = { - {172, 3}, + {165, 3}, {31, 2}, {0, 1}, }; @@ -1806,8 +1802,8 @@ static state states_79[4] = { {1, arcs_79_3}, }; static arc arcs_80_0[2] = { - {166, 1}, {165, 1}, + {172, 1}, }; static arc arcs_80_1[1] = { {0, 1}, @@ -1816,314 +1812,272 @@ static state states_80[2] = { {2, arcs_80_0}, {1, arcs_80_1}, }; -static arc arcs_81_0[3] = { - {166, 1}, - {165, 1}, - {174, 1}, -}; -static arc arcs_81_1[1] = { - {0, 1}, -}; -static state states_81[2] = { - {3, arcs_81_0}, - {1, arcs_81_1}, -}; -static arc arcs_82_0[1] = { +static arc arcs_81_0[2] = { {21, 1}, + {101, 2}, }; -static arc arcs_82_1[1] = { +static arc arcs_81_1[1] = { {101, 2}, }; -static arc arcs_82_2[1] = { +static arc arcs_81_2[1] = { {66, 3}, }; -static arc arcs_82_3[1] = { +static arc arcs_81_3[1] = { {102, 4}, }; -static arc arcs_82_4[1] = { +static arc arcs_81_4[1] = { {112, 5}, }; -static arc arcs_82_5[2] = { - {173, 6}, +static arc arcs_81_5[2] = { + {171, 6}, {0, 5}, }; -static arc arcs_82_6[1] = { +static arc arcs_81_6[1] = { {0, 6}, }; -static state states_82[7] = { - {1, arcs_82_0}, - {1, arcs_82_1}, - {1, arcs_82_2}, - {1, arcs_82_3}, - {1, arcs_82_4}, - {2, arcs_82_5}, - {1, arcs_82_6}, -}; -static arc arcs_83_0[1] = { - {101, 1}, -}; -static arc arcs_83_1[1] = { - {66, 2}, -}; -static arc arcs_83_2[1] = { - {102, 3}, -}; -static arc arcs_83_3[1] = { - {112, 4}, -}; -static arc arcs_83_4[2] = { - {173, 5}, - {0, 4}, -}; -static arc arcs_83_5[1] = { - {0, 5}, -}; -static state states_83[6] = { - {1, arcs_83_0}, - {1, arcs_83_1}, - {1, arcs_83_2}, - {1, arcs_83_3}, - {2, arcs_83_4}, - {1, arcs_83_5}, +static state states_81[7] = { + {2, arcs_81_0}, + {1, arcs_81_1}, + {1, arcs_81_2}, + {1, arcs_81_3}, + {1, arcs_81_4}, + {2, arcs_81_5}, + {1, arcs_81_6}, }; -static arc arcs_84_0[1] = { +static arc arcs_82_0[1] = { {97, 1}, }; -static arc arcs_84_1[1] = { +static arc arcs_82_1[1] = { {114, 2}, }; -static arc arcs_84_2[2] = { - {173, 3}, +static arc arcs_82_2[2] = { + {171, 3}, {0, 2}, }; -static arc arcs_84_3[1] = { +static arc arcs_82_3[1] = { {0, 3}, }; -static state states_84[4] = { - {1, arcs_84_0}, - {1, arcs_84_1}, - {2, arcs_84_2}, - {1, arcs_84_3}, +static state states_82[4] = { + {1, arcs_82_0}, + {1, arcs_82_1}, + {2, arcs_82_2}, + {1, arcs_82_3}, }; -static arc arcs_85_0[1] = { +static arc arcs_83_0[1] = { {23, 1}, }; -static arc arcs_85_1[1] = { +static arc arcs_83_1[1] = { {0, 1}, }; -static state states_85[2] = { - {1, arcs_85_0}, - {1, arcs_85_1}, +static state states_83[2] = { + {1, arcs_83_0}, + {1, arcs_83_1}, }; -static arc arcs_86_0[1] = { - {176, 1}, +static arc arcs_84_0[1] = { + {174, 1}, }; -static arc arcs_86_1[2] = { - {177, 2}, +static arc arcs_84_1[2] = { + {175, 2}, {0, 1}, }; -static arc arcs_86_2[1] = { +static arc arcs_84_2[1] = { {0, 2}, }; -static state states_86[3] = { - {1, arcs_86_0}, - {2, arcs_86_1}, - {1, arcs_86_2}, +static state states_84[3] = { + {1, arcs_84_0}, + {2, arcs_84_1}, + {1, arcs_84_2}, }; -static arc arcs_87_0[2] = { +static arc arcs_85_0[2] = { {77, 1}, {9, 2}, }; -static arc arcs_87_1[1] = { +static arc arcs_85_1[1] = { {26, 2}, }; -static arc arcs_87_2[1] = { +static arc arcs_85_2[1] = { {0, 2}, }; -static state states_87[3] = { - {2, arcs_87_0}, - {1, arcs_87_1}, - {1, arcs_87_2}, +static state states_85[3] = { + {2, arcs_85_0}, + {1, arcs_85_1}, + {1, arcs_85_2}, }; -static dfa dfas[88] = { +static dfa dfas[86] = { {256, "single_input", 0, 3, states_0, - "\004\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\004\001"}, + "\004\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\102"}, {257, "file_input", 0, 2, states_1, - "\204\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\004\001"}, + "\204\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\102"}, {258, "eval_input", 0, 3, states_2, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, {259, "decorator", 0, 7, states_3, - "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {260, "decorators", 0, 2, states_4, - "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {261, "decorated", 0, 3, states_5, - "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {262, "async_funcdef", 0, 3, states_6, - "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {263, "funcdef", 0, 8, states_7, - "\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {264, "parameters", 0, 4, states_8, - "\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {265, "typedargslist", 0, 19, states_9, - "\000\000\200\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {266, "tfpdef", 0, 4, states_10, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {267, "varargslist", 0, 19, states_11, - "\000\000\200\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {268, "vfpdef", 0, 2, states_12, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {269, "stmt", 0, 2, states_13, - "\000\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\004\001"}, + "\000\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\102"}, {270, "simple_stmt", 0, 4, states_14, - "\000\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\000\001"}, + "\000\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\100"}, {271, "small_stmt", 0, 2, states_15, - "\000\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\000\001"}, + "\000\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\100"}, {272, "expr_stmt", 0, 6, states_16, - "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, {273, "annassign", 0, 5, states_17, - "\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {274, "testlist_star_expr", 0, 3, states_18, - "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, {275, "augassign", 0, 2, states_19, - "\000\000\000\000\000\000\360\377\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\360\377\001\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {276, "del_stmt", 0, 3, states_20, - "\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {277, "pass_stmt", 0, 2, states_21, - "\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {278, "flow_stmt", 0, 2, states_22, - "\000\000\000\000\000\000\000\000\000\036\000\000\000\000\000\000\000\000\000\000\000\000\001"}, + "\000\000\000\000\000\000\000\000\000\036\000\000\000\000\000\000\000\000\000\000\000\100"}, {279, "break_stmt", 0, 2, states_23, - "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000"}, {280, "continue_stmt", 0, 2, states_24, - "\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000"}, {281, "return_stmt", 0, 3, states_25, - "\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000"}, {282, "yield_stmt", 0, 2, states_26, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100"}, {283, "raise_stmt", 0, 5, states_27, - "\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000"}, {284, "import_stmt", 0, 2, states_28, - "\000\000\000\000\000\000\000\000\000\040\001\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\040\001\000\000\000\000\000\000\000\000\000\000\000"}, {285, "import_name", 0, 3, states_29, - "\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000"}, {286, "import_from", 0, 8, states_30, - "\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000"}, {287, "import_as_name", 0, 4, states_31, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {288, "dotted_as_name", 0, 4, states_32, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {289, "import_as_names", 0, 3, states_33, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {290, "dotted_as_names", 0, 2, states_34, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {291, "dotted_name", 0, 2, states_35, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {292, "global_stmt", 0, 3, states_36, - "\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000"}, {293, "nonlocal_stmt", 0, 3, states_37, - "\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000"}, {294, "assert_stmt", 0, 5, states_38, - "\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000"}, {295, "compound_stmt", 0, 2, states_39, - "\000\010\140\000\000\000\000\000\000\000\000\000\262\004\000\000\000\000\000\000\000\004\000"}, + "\000\010\140\000\000\000\000\000\000\000\000\000\262\004\000\000\000\000\000\000\000\002"}, {296, "async_stmt", 0, 3, states_40, - "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {297, "if_stmt", 0, 8, states_41, - "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000"}, {298, "while_stmt", 0, 8, states_42, - "\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000"}, {299, "for_stmt", 0, 10, states_43, - "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"}, {300, "try_stmt", 0, 13, states_44, - "\000\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000"}, {301, "with_stmt", 0, 5, states_45, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000"}, {302, "with_item", 0, 4, states_46, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, {303, "except_clause", 0, 5, states_47, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"}, {304, "suite", 0, 5, states_48, - "\004\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\000\001"}, + "\004\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\100"}, {305, "test", 0, 6, states_49, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, {306, "test_nocond", 0, 2, states_50, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, {307, "lambdef", 0, 5, states_51, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000"}, {308, "lambdef_nocond", 0, 5, states_52, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000"}, {309, "or_test", 0, 2, states_53, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000"}, {310, "and_test", 0, 2, states_54, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000"}, {311, "not_test", 0, 3, states_55, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000"}, {312, "comparison", 0, 2, states_56, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, {313, "comp_op", 0, 4, states_57, - "\000\000\000\000\000\000\000\000\000\000\000\000\100\000\000\362\017\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\100\000\000\362\017\000\000\000\000\000"}, {314, "star_expr", 0, 3, states_58, - "\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {315, "expr", 0, 2, states_59, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, {316, "xor_expr", 0, 2, states_60, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, {317, "and_expr", 0, 2, states_61, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, {318, "shift_expr", 0, 2, states_62, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, {319, "arith_expr", 0, 2, states_63, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, {320, "term", 0, 2, states_64, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, {321, "factor", 0, 3, states_65, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, {322, "power", 0, 4, states_66, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\200\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\200\050\037\000"}, {323, "atom_expr", 0, 3, states_67, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\200\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\200\050\037\000"}, {324, "atom", 0, 9, states_68, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\050\037\000"}, {325, "testlist_comp", 0, 5, states_69, - "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, {326, "trailer", 0, 7, states_70, - "\000\040\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\010\000\000\000"}, + "\000\040\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\010\000\000"}, {327, "subscriptlist", 0, 3, states_71, - "\000\040\200\010\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + "\000\040\200\010\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, {328, "subscript", 0, 5, states_72, - "\000\040\200\010\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + "\000\040\200\010\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, {329, "sliceop", 0, 3, states_73, - "\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {330, "exprlist", 0, 3, states_74, - "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, + "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, {331, "testlist", 0, 3, states_75, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, {332, "dictorsetmaker", 0, 14, states_76, - "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, {333, "classdef", 0, 8, states_77, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002"}, {334, "arglist", 0, 3, states_78, - "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, + "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, {335, "argument", 0, 4, states_79, - "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, - {336, "comp_for_or_async", 0, 2, states_80, - "\000\000\040\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"}, - {337, "comp_iter", 0, 2, states_81, - "\000\000\040\000\000\000\000\000\000\000\000\000\042\000\000\000\000\000\000\000\000\000\000"}, - {338, "comp_async_for", 0, 7, states_82, - "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {339, "comp_for", 0, 6, states_83, - "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"}, - {340, "comp_if", 0, 4, states_84, - "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000"}, - {341, "encoding_decl", 0, 2, states_85, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {342, "yield_expr", 0, 3, states_86, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"}, - {343, "yield_arg", 0, 3, states_87, - "\000\040\200\000\000\000\000\000\000\040\010\000\000\000\020\002\000\300\220\050\037\000\000"}, -}; -static label labels[178] = { + "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + {336, "comp_iter", 0, 2, states_80, + "\000\000\040\000\000\000\000\000\000\000\000\000\042\000\000\000\000\000\000\000\000\000"}, + {337, "comp_for", 0, 7, states_81, + "\000\000\040\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"}, + {338, "comp_if", 0, 4, states_82, + "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000"}, + {339, "encoding_decl", 0, 2, states_83, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + {340, "yield_expr", 0, 3, states_84, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100"}, + {341, "yield_arg", 0, 3, states_85, + "\000\040\200\000\000\000\000\000\000\040\010\000\000\000\020\002\000\300\220\050\037\000"}, +}; +static label labels[176] = { {0, "EMPTY"}, {256, 0}, {4, 0}, @@ -2174,7 +2128,7 @@ static label labels[178] = { {274, 0}, {273, 0}, {275, 0}, - {342, 0}, + {340, 0}, {314, 0}, {36, 0}, {37, 0}, @@ -2289,23 +2243,21 @@ static label labels[178] = { {1, "None"}, {1, "True"}, {1, "False"}, - {339, 0}, - {338, 0}, + {337, 0}, {327, 0}, {328, 0}, {329, 0}, {1, "class"}, {335, 0}, {336, 0}, - {337, 0}, - {340, 0}, - {341, 0}, + {338, 0}, + {339, 0}, {1, "yield"}, - {343, 0}, + {341, 0}, }; grammar _PyParser_Grammar = { - 88, + 86, dfas, - {178, labels}, + {176, labels}, 256 }; From dacf3e6fcc5851922ec9e5e3f132ff3336146e2a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 22 Jul 2017 10:45:53 -0700 Subject: [PATCH 17/26] minor CR fixes --- Lib/test/test_coroutines.py | 2 -- .../Core and Builtins/2017-07-20-22-03-44.bpo-30406._kr47t.rst | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py index 74c481343493ff..ebd880bab0c752 100644 --- a/Lib/test/test_coroutines.py +++ b/Lib/test/test_coroutines.py @@ -402,8 +402,6 @@ def test_badsyntax_3(self): compile("async = 1", "", "exec") def test_badsyntax_4(self): - # Tests for issue 24619 - samples = [ '''def foo(await): async def foo(): pass diff --git a/Misc/NEWS.d/next/Core and Builtins/2017-07-20-22-03-44.bpo-30406._kr47t.rst b/Misc/NEWS.d/next/Core and Builtins/2017-07-20-22-03-44.bpo-30406._kr47t.rst index 079887733f8f1d..caf56f03783c48 100644 --- a/Misc/NEWS.d/next/Core and Builtins/2017-07-20-22-03-44.bpo-30406._kr47t.rst +++ b/Misc/NEWS.d/next/Core and Builtins/2017-07-20-22-03-44.bpo-30406._kr47t.rst @@ -1 +1 @@ -``async`` and ``await`` are now proper keywords, as specified in PEP 492. +Make ``async`` and ``await`` proper keywords, as specified in PEP 492. From d31627a9b552efa4ed21fc5b5dcf6d4c1a3a8e76 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 26 Sep 2017 20:55:40 -0700 Subject: [PATCH 18/26] closer to yuri's code --- Include/token.h | 118 ++++++++++++++++++++++++------------------------ Python/ast.c | 6 ++- 2 files changed, 63 insertions(+), 61 deletions(-) diff --git a/Include/token.h b/Include/token.h index dc79910397d3b2..7c4bdd7bc387b1 100644 --- a/Include/token.h +++ b/Include/token.h @@ -9,75 +9,75 @@ extern "C" { #undef TILDE /* Prevent clash of our definition with system macro. Ex AIX, ioctl.h */ -#define ENDMARKER 0 -#define NAME 1 -#define NUMBER 2 -#define STRING 3 -#define NEWLINE 4 -#define INDENT 5 -#define DEDENT 6 -#define LPAR 7 -#define RPAR 8 -#define LSQB 9 -#define RSQB 10 -#define COLON 11 -#define COMMA 12 -#define SEMI 13 -#define PLUS 14 -#define MINUS 15 -#define STAR 16 -#define SLASH 17 -#define VBAR 18 -#define AMPER 19 -#define LESS 20 -#define GREATER 21 -#define EQUAL 22 -#define DOT 23 -#define PERCENT 24 -#define LBRACE 25 -#define RBRACE 26 -#define EQEQUAL 27 -#define NOTEQUAL 28 -#define LESSEQUAL 29 -#define GREATEREQUAL 30 -#define TILDE 31 -#define CIRCUMFLEX 32 -#define LEFTSHIFT 33 -#define RIGHTSHIFT 34 -#define DOUBLESTAR 35 -#define PLUSEQUAL 36 -#define MINEQUAL 37 -#define STAREQUAL 38 -#define SLASHEQUAL 39 -#define PERCENTEQUAL 40 -#define AMPEREQUAL 41 -#define VBAREQUAL 42 -#define CIRCUMFLEXEQUAL 43 -#define LEFTSHIFTEQUAL 44 -#define RIGHTSHIFTEQUAL 45 -#define DOUBLESTAREQUAL 46 -#define DOUBLESLASH 47 +#define ENDMARKER 0 +#define NAME 1 +#define NUMBER 2 +#define STRING 3 +#define NEWLINE 4 +#define INDENT 5 +#define DEDENT 6 +#define LPAR 7 +#define RPAR 8 +#define LSQB 9 +#define RSQB 10 +#define COLON 11 +#define COMMA 12 +#define SEMI 13 +#define PLUS 14 +#define MINUS 15 +#define STAR 16 +#define SLASH 17 +#define VBAR 18 +#define AMPER 19 +#define LESS 20 +#define GREATER 21 +#define EQUAL 22 +#define DOT 23 +#define PERCENT 24 +#define LBRACE 25 +#define RBRACE 26 +#define EQEQUAL 27 +#define NOTEQUAL 28 +#define LESSEQUAL 29 +#define GREATEREQUAL 30 +#define TILDE 31 +#define CIRCUMFLEX 32 +#define LEFTSHIFT 33 +#define RIGHTSHIFT 34 +#define DOUBLESTAR 35 +#define PLUSEQUAL 36 +#define MINEQUAL 37 +#define STAREQUAL 38 +#define SLASHEQUAL 39 +#define PERCENTEQUAL 40 +#define AMPEREQUAL 41 +#define VBAREQUAL 42 +#define CIRCUMFLEXEQUAL 43 +#define LEFTSHIFTEQUAL 44 +#define RIGHTSHIFTEQUAL 45 +#define DOUBLESTAREQUAL 46 +#define DOUBLESLASH 47 #define DOUBLESLASHEQUAL 48 #define AT 49 -#define ATEQUAL 50 +#define ATEQUAL 50 #define RARROW 51 #define ELLIPSIS 52 /* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */ -#define OP 53 -#define ERRORTOKEN 54 +#define OP 53 +#define ERRORTOKEN 54 /* These aren't used by the C tokenizer but are needed for tokenize.py */ -#define COMMENT 55 -#define NL 56 -#define ENCODING 57 -#define N_TOKENS 58 +#define COMMENT 55 +#define NL 56 +#define ENCODING 57 +#define N_TOKENS 58 /* Special definitions for cooperation with parser */ -#define NT_OFFSET 256 +#define NT_OFFSET 256 -#define ISTERMINAL(x) ((x) < NT_OFFSET) -#define ISNONTERMINAL(x) ((x) >= NT_OFFSET) -#define ISEOF(x) ((x) == ENDMARKER) +#define ISTERMINAL(x) ((x) < NT_OFFSET) +#define ISNONTERMINAL(x) ((x) >= NT_OFFSET) +#define ISEOF(x) ((x) == ENDMARKER) PyAPI_DATA(const char *) _PyParser_TokenNames[]; /* Token names */ diff --git a/Python/ast.c b/Python/ast.c index dc1bda1c6cc8af..e29a57feebf1d2 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -1623,6 +1623,7 @@ ast_for_async_funcdef(struct compiling *c, const node *n, asdl_seq *decorator_se /* async_funcdef: 'async' funcdef */ REQ(n, async_funcdef); REQ(CHILD(n, 0), NAME); + assert(strcmp(STR(CHILD(n, 0)), "async") == 0); REQ(CHILD(n, 1), funcdef); return ast_for_funcdef_impl(c, CHILD(n, 1), decorator_seq, @@ -1644,6 +1645,7 @@ ast_for_async_stmt(struct compiling *c, const node *n) /* async_stmt: 'async' (funcdef | with_stmt | for_stmt) */ REQ(n, async_stmt); REQ(CHILD(n, 0), NAME); + assert(strcmp(STR(CHILD(n, 0)), "async") == 0); switch (TYPE(CHILD(n, 1))) { case funcdef: @@ -2475,7 +2477,7 @@ ast_for_atom_expr(struct compiling *c, const node *n) } if (start) { - /* there was an AWAIT */ + /* there was an 'await' */ return Await(e, LINENO(n), n->n_col_offset, c->c_arena); } else { @@ -2540,7 +2542,7 @@ ast_for_expr(struct compiling *c, const node *n) term: factor (('*'|'@'|'/'|'%'|'//') factor)* factor: ('+'|'-'|'~') factor | power power: atom_expr ['**' factor] - atom_expr: [AWAIT] atom trailer* + atom_expr: ['await'] atom trailer* yield_expr: 'yield' [yield_arg] */ From ef28dea93b4b79a6f6566db3fd99a511bbad921e Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 27 Aug 2017 13:26:16 -0700 Subject: [PATCH 19/26] undo unnecessary change --- Lib/test/test_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index 86d08a939e25c6..70cabb28598218 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -762,7 +762,7 @@ def _nested_expression(self, level): def test_deeply_nested_list(self): # XXX used to be 99 levels in 2.x - e = self._nested_expression(88) + e = self._nested_expression(93) st = parser.expr(e) st.compile() From 499aa4024b279b6684acf579482afeccc2bb4208 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 26 Sep 2017 21:16:55 -0700 Subject: [PATCH 20/26] fix whitespace (make patchcheck) --- Include/token.h | 118 ++++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/Include/token.h b/Include/token.h index 7c4bdd7bc387b1..cd1cd00f09c460 100644 --- a/Include/token.h +++ b/Include/token.h @@ -9,75 +9,75 @@ extern "C" { #undef TILDE /* Prevent clash of our definition with system macro. Ex AIX, ioctl.h */ -#define ENDMARKER 0 -#define NAME 1 -#define NUMBER 2 -#define STRING 3 -#define NEWLINE 4 -#define INDENT 5 -#define DEDENT 6 -#define LPAR 7 -#define RPAR 8 -#define LSQB 9 -#define RSQB 10 -#define COLON 11 -#define COMMA 12 -#define SEMI 13 -#define PLUS 14 -#define MINUS 15 -#define STAR 16 -#define SLASH 17 -#define VBAR 18 -#define AMPER 19 -#define LESS 20 -#define GREATER 21 -#define EQUAL 22 -#define DOT 23 -#define PERCENT 24 -#define LBRACE 25 -#define RBRACE 26 -#define EQEQUAL 27 -#define NOTEQUAL 28 -#define LESSEQUAL 29 -#define GREATEREQUAL 30 -#define TILDE 31 -#define CIRCUMFLEX 32 -#define LEFTSHIFT 33 -#define RIGHTSHIFT 34 -#define DOUBLESTAR 35 -#define PLUSEQUAL 36 -#define MINEQUAL 37 -#define STAREQUAL 38 -#define SLASHEQUAL 39 -#define PERCENTEQUAL 40 -#define AMPEREQUAL 41 -#define VBAREQUAL 42 -#define CIRCUMFLEXEQUAL 43 -#define LEFTSHIFTEQUAL 44 -#define RIGHTSHIFTEQUAL 45 -#define DOUBLESTAREQUAL 46 -#define DOUBLESLASH 47 +#define ENDMARKER 0 +#define NAME 1 +#define NUMBER 2 +#define STRING 3 +#define NEWLINE 4 +#define INDENT 5 +#define DEDENT 6 +#define LPAR 7 +#define RPAR 8 +#define LSQB 9 +#define RSQB 10 +#define COLON 11 +#define COMMA 12 +#define SEMI 13 +#define PLUS 14 +#define MINUS 15 +#define STAR 16 +#define SLASH 17 +#define VBAR 18 +#define AMPER 19 +#define LESS 20 +#define GREATER 21 +#define EQUAL 22 +#define DOT 23 +#define PERCENT 24 +#define LBRACE 25 +#define RBRACE 26 +#define EQEQUAL 27 +#define NOTEQUAL 28 +#define LESSEQUAL 29 +#define GREATEREQUAL 30 +#define TILDE 31 +#define CIRCUMFLEX 32 +#define LEFTSHIFT 33 +#define RIGHTSHIFT 34 +#define DOUBLESTAR 35 +#define PLUSEQUAL 36 +#define MINEQUAL 37 +#define STAREQUAL 38 +#define SLASHEQUAL 39 +#define PERCENTEQUAL 40 +#define AMPEREQUAL 41 +#define VBAREQUAL 42 +#define CIRCUMFLEXEQUAL 43 +#define LEFTSHIFTEQUAL 44 +#define RIGHTSHIFTEQUAL 45 +#define DOUBLESTAREQUAL 46 +#define DOUBLESLASH 47 #define DOUBLESLASHEQUAL 48 #define AT 49 -#define ATEQUAL 50 +#define ATEQUAL 50 #define RARROW 51 #define ELLIPSIS 52 /* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */ -#define OP 53 -#define ERRORTOKEN 54 +#define OP 53 +#define ERRORTOKEN 54 /* These aren't used by the C tokenizer but are needed for tokenize.py */ -#define COMMENT 55 -#define NL 56 -#define ENCODING 57 -#define N_TOKENS 58 +#define COMMENT 55 +#define NL 56 +#define ENCODING 57 +#define N_TOKENS 58 /* Special definitions for cooperation with parser */ -#define NT_OFFSET 256 +#define NT_OFFSET 256 -#define ISTERMINAL(x) ((x) < NT_OFFSET) -#define ISNONTERMINAL(x) ((x) >= NT_OFFSET) -#define ISEOF(x) ((x) == ENDMARKER) +#define ISTERMINAL(x) ((x) < NT_OFFSET) +#define ISNONTERMINAL(x) ((x) >= NT_OFFSET) +#define ISEOF(x) ((x) == ENDMARKER) PyAPI_DATA(const char *) _PyParser_TokenNames[]; /* Token names */ From 7c664e36b89efd98d9e6806d3da200d48e3aa4f4 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 26 Sep 2017 21:43:11 -0700 Subject: [PATCH 21/26] fix test_symbol --- Lib/symbol.py | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/Lib/symbol.py b/Lib/symbol.py index 2c995a6199e989..d9f01e081a7595 100755 --- a/Lib/symbol.py +++ b/Lib/symbol.py @@ -77,28 +77,25 @@ term = 320 factor = 321 power = 322 -await_expr = 323 -atom_expr = 324 -atom = 325 -testlist_comp = 326 -trailer = 327 -subscriptlist = 328 -subscript = 329 -sliceop = 330 -exprlist = 331 -testlist = 332 -dictorsetmaker = 333 -classdef = 334 -arglist = 335 -argument = 336 -comp_for_or_async = 337 -comp_iter = 338 -comp_async_for = 339 -comp_for = 340 -comp_if = 341 -encoding_decl = 342 -yield_expr = 343 -yield_arg = 344 +atom_expr = 323 +atom = 324 +testlist_comp = 325 +trailer = 326 +subscriptlist = 327 +subscript = 328 +sliceop = 329 +exprlist = 330 +testlist = 331 +dictorsetmaker = 332 +classdef = 333 +arglist = 334 +argument = 335 +comp_iter = 336 +comp_for = 337 +comp_if = 338 +encoding_decl = 339 +yield_expr = 340 +yield_arg = 341 #--end constants-- sym_name = {} From 5659c8ddee716f7ef9c4096f98bd6026e4a352cc Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 30 Sep 2017 09:21:46 -0700 Subject: [PATCH 22/26] use a separate sync_comp_for (suggested by Yury) --- Grammar/Grammar | 3 +- Include/graminit.h | 11 +- Lib/test/test_parser.py | 6 +- Python/ast.c | 37 +++-- Python/graminit.c | 309 +++++++++++++++++++++------------------- 5 files changed, 198 insertions(+), 168 deletions(-) diff --git a/Grammar/Grammar b/Grammar/Grammar index 5beb068eb01d5b..7d3dd0b86dc69a 100644 --- a/Grammar/Grammar +++ b/Grammar/Grammar @@ -139,7 +139,8 @@ argument: ( test [comp_for] | '*' test ) comp_iter: comp_for | comp_if -comp_for: ['async'] 'for' exprlist 'in' or_test [comp_iter] +sync_comp_for: 'for' exprlist 'in' or_test [comp_iter] +comp_for: ['async'] sync_comp_for comp_if: 'if' test_nocond [comp_iter] # not used in grammar, but may appear in "node" passed from Parser to Compiler diff --git a/Include/graminit.h b/Include/graminit.h index e9b4a9385956b1..bdfe821ad71686 100644 --- a/Include/graminit.h +++ b/Include/graminit.h @@ -81,8 +81,9 @@ #define arglist 334 #define argument 335 #define comp_iter 336 -#define comp_for 337 -#define comp_if 338 -#define encoding_decl 339 -#define yield_expr 340 -#define yield_arg 341 +#define sync_comp_for 337 +#define comp_for 338 +#define comp_if 339 +#define encoding_decl 340 +#define yield_expr 341 +#define yield_arg 342 diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index 70cabb28598218..647d391c7984e5 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -679,16 +679,16 @@ def test_missing_import_source(self): def test_illegal_encoding(self): # Illegal encoding declaration tree = \ - (339, + (340, (257, (0, ''))) self.check_bad_tree(tree, "missed encoding") tree = \ - (339, + (340, (257, (0, '')), b'iso-8859-1') self.check_bad_tree(tree, "non-string encoding") tree = \ - (339, + (340, (257, (0, '')), '\udcff') with self.assertRaises(UnicodeEncodeError): diff --git a/Python/ast.c b/Python/ast.c index e29a57feebf1d2..6989965efabbad 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -1758,17 +1758,23 @@ static int count_comp_fors(struct compiling *c, const node *n) { int n_fors = 0; - int is_async; count_comp_for: - is_async = 0; n_fors++; REQ(n, comp_for); - if (TYPE(CHILD(n, 0)) == NAME && strcmp(STR(CHILD(n, 0)), "async") == 0) { - is_async = 1; + if (NCH(n) == 2) { + REQ(CHILD(n, 0), NAME); + assert(strcmp(STR(CHILD(n, 0)), "async") == 0); + n = CHILD(n, 1); } - if (NCH(n) == (5 + is_async)) { - n = CHILD(n, 4 + is_async); + else if (NCH(n) == 1) { + n = CHILD(n, 0); + } + else { + goto error; + } + if (NCH(n) == (5)) { + n = CHILD(n, 4); } else { return n_fors; @@ -1787,6 +1793,7 @@ count_comp_fors(struct compiling *c, const node *n) return n_fors; } + error: /* Should never be reached */ PyErr_SetString(PyExc_SystemError, "logic error in count_comp_fors"); @@ -1835,19 +1842,27 @@ ast_for_comprehension(struct compiling *c, const node *n) asdl_seq *t; expr_ty expression, first; node *for_ch; + node *sync_n; int is_async = 0; REQ(n, comp_for); - if (TYPE(CHILD(n, 0)) == NAME && strcmp(STR(CHILD(n, 0)), "async") == 0) { + if (NCH(n) == 2) { is_async = 1; + REQ(CHILD(n, 0), NAME); + assert(strcmp(STR(CHILD(n, 0)), "async") == 0); + sync_n = CHILD(n, 1); + } + else { + sync_n = CHILD(n, 0); } + REQ(sync_n, sync_comp_for); - for_ch = CHILD(n, 1 + is_async); + for_ch = CHILD(sync_n, 1); t = ast_for_exprlist(c, for_ch, Store); if (!t) return NULL; - expression = ast_for_expr(c, CHILD(n, 3 + is_async)); + expression = ast_for_expr(c, CHILD(sync_n, 3)); if (!expression) return NULL; @@ -1864,11 +1879,11 @@ ast_for_comprehension(struct compiling *c, const node *n) if (!comp) return NULL; - if (NCH(n) == (5 + is_async)) { + if (NCH(sync_n) == 5) { int j, n_ifs; asdl_seq *ifs; - n = CHILD(n, 4 + is_async); + n = CHILD(sync_n, 4); n_ifs = count_comp_ifs(c, n); if (n_ifs == -1) return NULL; diff --git a/Python/graminit.c b/Python/graminit.c index a4fd2ee7ba2657..8e89ccea3bab6a 100644 --- a/Python/graminit.c +++ b/Python/graminit.c @@ -1812,272 +1812,284 @@ static state states_80[2] = { {2, arcs_80_0}, {1, arcs_80_1}, }; -static arc arcs_81_0[2] = { - {21, 1}, - {101, 2}, +static arc arcs_81_0[1] = { + {101, 1}, }; static arc arcs_81_1[1] = { - {101, 2}, + {66, 2}, }; static arc arcs_81_2[1] = { - {66, 3}, + {102, 3}, }; static arc arcs_81_3[1] = { - {102, 4}, + {112, 4}, }; -static arc arcs_81_4[1] = { - {112, 5}, +static arc arcs_81_4[2] = { + {171, 5}, + {0, 4}, }; -static arc arcs_81_5[2] = { - {171, 6}, +static arc arcs_81_5[1] = { {0, 5}, }; -static arc arcs_81_6[1] = { - {0, 6}, -}; -static state states_81[7] = { - {2, arcs_81_0}, +static state states_81[6] = { + {1, arcs_81_0}, {1, arcs_81_1}, {1, arcs_81_2}, {1, arcs_81_3}, - {1, arcs_81_4}, - {2, arcs_81_5}, - {1, arcs_81_6}, + {2, arcs_81_4}, + {1, arcs_81_5}, }; -static arc arcs_82_0[1] = { - {97, 1}, +static arc arcs_82_0[2] = { + {21, 1}, + {173, 2}, }; static arc arcs_82_1[1] = { - {114, 2}, + {173, 2}, }; -static arc arcs_82_2[2] = { - {171, 3}, +static arc arcs_82_2[1] = { {0, 2}, }; -static arc arcs_82_3[1] = { - {0, 3}, -}; -static state states_82[4] = { - {1, arcs_82_0}, +static state states_82[3] = { + {2, arcs_82_0}, {1, arcs_82_1}, - {2, arcs_82_2}, - {1, arcs_82_3}, + {1, arcs_82_2}, }; static arc arcs_83_0[1] = { - {23, 1}, + {97, 1}, }; static arc arcs_83_1[1] = { - {0, 1}, + {114, 2}, +}; +static arc arcs_83_2[2] = { + {171, 3}, + {0, 2}, +}; +static arc arcs_83_3[1] = { + {0, 3}, }; -static state states_83[2] = { +static state states_83[4] = { {1, arcs_83_0}, {1, arcs_83_1}, + {2, arcs_83_2}, + {1, arcs_83_3}, }; static arc arcs_84_0[1] = { - {174, 1}, + {23, 1}, }; -static arc arcs_84_1[2] = { - {175, 2}, +static arc arcs_84_1[1] = { {0, 1}, }; -static arc arcs_84_2[1] = { +static state states_84[2] = { + {1, arcs_84_0}, + {1, arcs_84_1}, +}; +static arc arcs_85_0[1] = { + {175, 1}, +}; +static arc arcs_85_1[2] = { + {176, 2}, + {0, 1}, +}; +static arc arcs_85_2[1] = { {0, 2}, }; -static state states_84[3] = { - {1, arcs_84_0}, - {2, arcs_84_1}, - {1, arcs_84_2}, +static state states_85[3] = { + {1, arcs_85_0}, + {2, arcs_85_1}, + {1, arcs_85_2}, }; -static arc arcs_85_0[2] = { +static arc arcs_86_0[2] = { {77, 1}, {9, 2}, }; -static arc arcs_85_1[1] = { +static arc arcs_86_1[1] = { {26, 2}, }; -static arc arcs_85_2[1] = { +static arc arcs_86_2[1] = { {0, 2}, }; -static state states_85[3] = { - {2, arcs_85_0}, - {1, arcs_85_1}, - {1, arcs_85_2}, +static state states_86[3] = { + {2, arcs_86_0}, + {1, arcs_86_1}, + {1, arcs_86_2}, }; -static dfa dfas[86] = { +static dfa dfas[87] = { {256, "single_input", 0, 3, states_0, - "\004\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\102"}, + "\004\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\202\000"}, {257, "file_input", 0, 2, states_1, - "\204\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\102"}, + "\204\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\202\000"}, {258, "eval_input", 0, 3, states_2, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {259, "decorator", 0, 7, states_3, - "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {260, "decorators", 0, 2, states_4, - "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {261, "decorated", 0, 3, states_5, - "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {262, "async_funcdef", 0, 3, states_6, - "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {263, "funcdef", 0, 8, states_7, - "\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\100\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {264, "parameters", 0, 4, states_8, - "\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {265, "typedargslist", 0, 19, states_9, - "\000\000\200\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {266, "tfpdef", 0, 4, states_10, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {267, "varargslist", 0, 19, states_11, - "\000\000\200\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {268, "vfpdef", 0, 2, states_12, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {269, "stmt", 0, 2, states_13, - "\000\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\102"}, + "\000\050\340\000\002\000\000\000\012\076\011\007\262\004\020\002\000\300\220\050\037\202\000"}, {270, "simple_stmt", 0, 4, states_14, - "\000\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\100"}, + "\000\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\200\000"}, {271, "small_stmt", 0, 2, states_15, - "\000\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\100"}, + "\000\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\200\000"}, {272, "expr_stmt", 0, 6, states_16, - "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {273, "annassign", 0, 5, states_17, - "\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {274, "testlist_star_expr", 0, 3, states_18, - "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {275, "augassign", 0, 2, states_19, - "\000\000\000\000\000\000\360\377\001\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\360\377\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {276, "del_stmt", 0, 3, states_20, - "\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {277, "pass_stmt", 0, 2, states_21, - "\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {278, "flow_stmt", 0, 2, states_22, - "\000\000\000\000\000\000\000\000\000\036\000\000\000\000\000\000\000\000\000\000\000\100"}, + "\000\000\000\000\000\000\000\000\000\036\000\000\000\000\000\000\000\000\000\000\000\200\000"}, {279, "break_stmt", 0, 2, states_23, - "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {280, "continue_stmt", 0, 2, states_24, - "\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {281, "return_stmt", 0, 3, states_25, - "\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {282, "yield_stmt", 0, 2, states_26, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\200\000"}, {283, "raise_stmt", 0, 5, states_27, - "\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {284, "import_stmt", 0, 2, states_28, - "\000\000\000\000\000\000\000\000\000\040\001\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\040\001\000\000\000\000\000\000\000\000\000\000\000\000"}, {285, "import_name", 0, 3, states_29, - "\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000"}, {286, "import_from", 0, 8, states_30, - "\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {287, "import_as_name", 0, 4, states_31, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {288, "dotted_as_name", 0, 4, states_32, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {289, "import_as_names", 0, 3, states_33, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {290, "dotted_as_names", 0, 2, states_34, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {291, "dotted_name", 0, 2, states_35, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {292, "global_stmt", 0, 3, states_36, - "\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000"}, {293, "nonlocal_stmt", 0, 3, states_37, - "\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000"}, {294, "assert_stmt", 0, 5, states_38, - "\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000"}, {295, "compound_stmt", 0, 2, states_39, - "\000\010\140\000\000\000\000\000\000\000\000\000\262\004\000\000\000\000\000\000\000\002"}, + "\000\010\140\000\000\000\000\000\000\000\000\000\262\004\000\000\000\000\000\000\000\002\000"}, {296, "async_stmt", 0, 3, states_40, - "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {297, "if_stmt", 0, 8, states_41, - "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000"}, {298, "while_stmt", 0, 8, states_42, - "\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"}, {299, "for_stmt", 0, 10, states_43, - "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"}, {300, "try_stmt", 0, 13, states_44, - "\000\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000"}, {301, "with_stmt", 0, 5, states_45, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000"}, {302, "with_item", 0, 4, states_46, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {303, "except_clause", 0, 5, states_47, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"}, {304, "suite", 0, 5, states_48, - "\004\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\100"}, + "\004\040\200\000\002\000\000\000\012\076\011\007\000\000\020\002\000\300\220\050\037\200\000"}, {305, "test", 0, 6, states_49, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {306, "test_nocond", 0, 2, states_50, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {307, "lambdef", 0, 5, states_51, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000"}, {308, "lambdef_nocond", 0, 5, states_52, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000"}, {309, "or_test", 0, 2, states_53, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000\000"}, {310, "and_test", 0, 2, states_54, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000\000"}, {311, "not_test", 0, 3, states_55, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\002\000\300\220\050\037\000\000"}, {312, "comparison", 0, 2, states_56, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {313, "comp_op", 0, 4, states_57, - "\000\000\000\000\000\000\000\000\000\000\000\000\100\000\000\362\017\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\100\000\000\362\017\000\000\000\000\000\000"}, {314, "star_expr", 0, 3, states_58, - "\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {315, "expr", 0, 2, states_59, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {316, "xor_expr", 0, 2, states_60, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {317, "and_expr", 0, 2, states_61, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {318, "shift_expr", 0, 2, states_62, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {319, "arith_expr", 0, 2, states_63, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {320, "term", 0, 2, states_64, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {321, "factor", 0, 3, states_65, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {322, "power", 0, 4, states_66, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\200\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\200\050\037\000\000"}, {323, "atom_expr", 0, 3, states_67, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\200\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\200\050\037\000\000"}, {324, "atom", 0, 9, states_68, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\050\037\000\000"}, {325, "testlist_comp", 0, 5, states_69, - "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {326, "trailer", 0, 7, states_70, - "\000\040\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\010\000\000"}, + "\000\040\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\010\000\000\000"}, {327, "subscriptlist", 0, 3, states_71, - "\000\040\200\010\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\010\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {328, "subscript", 0, 5, states_72, - "\000\040\200\010\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\010\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {329, "sliceop", 0, 3, states_73, - "\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {330, "exprlist", 0, 3, states_74, - "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000"}, + "\000\040\200\000\002\000\000\000\000\000\010\000\000\000\000\000\000\300\220\050\037\000\000"}, {331, "testlist", 0, 3, states_75, - "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\000\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {332, "dictorsetmaker", 0, 14, states_76, - "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {333, "classdef", 0, 8, states_77, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000"}, {334, "arglist", 0, 3, states_78, - "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {335, "argument", 0, 4, states_79, - "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000"}, + "\000\040\200\000\006\000\000\000\000\000\010\000\000\000\020\002\000\300\220\050\037\000\000"}, {336, "comp_iter", 0, 2, states_80, - "\000\000\040\000\000\000\000\000\000\000\000\000\042\000\000\000\000\000\000\000\000\000"}, - {337, "comp_for", 0, 7, states_81, - "\000\000\040\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"}, - {338, "comp_if", 0, 4, states_82, - "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000"}, - {339, "encoding_decl", 0, 2, states_83, - "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {340, "yield_expr", 0, 3, states_84, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\100"}, - {341, "yield_arg", 0, 3, states_85, - "\000\040\200\000\000\000\000\000\000\040\010\000\000\000\020\002\000\300\220\050\037\000"}, -}; -static label labels[176] = { + "\000\000\040\000\000\000\000\000\000\000\000\000\042\000\000\000\000\000\000\000\000\000\000"}, + {337, "sync_comp_for", 0, 6, states_81, + "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"}, + {338, "comp_for", 0, 3, states_82, + "\000\000\040\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000"}, + {339, "comp_if", 0, 4, states_83, + "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000"}, + {340, "encoding_decl", 0, 2, states_84, + "\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + {341, "yield_expr", 0, 3, states_85, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\200\000"}, + {342, "yield_arg", 0, 3, states_86, + "\000\040\200\000\000\000\000\000\000\040\010\000\000\000\020\002\000\300\220\050\037\000\000"}, +}; +static label labels[177] = { {0, "EMPTY"}, {256, 0}, {4, 0}, @@ -2128,7 +2140,7 @@ static label labels[176] = { {274, 0}, {273, 0}, {275, 0}, - {340, 0}, + {341, 0}, {314, 0}, {36, 0}, {37, 0}, @@ -2243,21 +2255,22 @@ static label labels[176] = { {1, "None"}, {1, "True"}, {1, "False"}, - {337, 0}, + {338, 0}, {327, 0}, {328, 0}, {329, 0}, {1, "class"}, {335, 0}, {336, 0}, - {338, 0}, {339, 0}, + {337, 0}, + {340, 0}, {1, "yield"}, - {341, 0}, + {342, 0}, }; grammar _PyParser_Grammar = { - 86, + 87, dfas, - {176, labels}, + {177, labels}, 256 }; From 2413e3ee6a47c4dd9553843a88f49e5536a1ea0e Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 30 Sep 2017 09:43:56 -0700 Subject: [PATCH 23/26] regenerate symbol.py --- Lib/symbol.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Lib/symbol.py b/Lib/symbol.py index d9f01e081a7595..dc7dcba5e4d0b5 100755 --- a/Lib/symbol.py +++ b/Lib/symbol.py @@ -91,11 +91,12 @@ arglist = 334 argument = 335 comp_iter = 336 -comp_for = 337 -comp_if = 338 -encoding_decl = 339 -yield_expr = 340 -yield_arg = 341 +sync_comp_for = 337 +comp_for = 338 +comp_if = 339 +encoding_decl = 340 +yield_expr = 341 +yield_arg = 342 #--end constants-- sym_name = {} From cdbc7d5c3ce1e4adc61364888fd7ecbaf0badaf6 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 30 Sep 2017 09:46:11 -0700 Subject: [PATCH 24/26] simplify lib2to3 changes --- Lib/lib2to3/Grammar.txt | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Lib/lib2to3/Grammar.txt b/Lib/lib2to3/Grammar.txt index c63ca2eb9d54c0..be07973d3c1a22 100644 --- a/Lib/lib2to3/Grammar.txt +++ b/Lib/lib2to3/Grammar.txt @@ -123,16 +123,15 @@ and_expr: shift_expr ('&' shift_expr)* shift_expr: arith_expr (('<<'|'>>') arith_expr)* arith_expr: term (('+'|'-') term)* term: factor (('*'|'@'|'/'|'%'|'//') factor)* -factor: ('+'|'-'|'~') factor | await_expr -await_expr: 'await' power | power -power: atom trailer* ['**' factor] +factor: ('+'|'-'|'~') factor | power +power: ['await'] atom trailer* ['**' factor] atom: ('(' [yield_expr|testlist_gexp] ')' | '[' [listmaker] ']' | '{' [dictsetmaker] '}' | '`' testlist1 '`' | NAME | NUMBER | STRING+ | '.' '.' '.') -listmaker: (test|star_expr) ( old_comp_for | comp_async_for | (',' (test|star_expr))* [','] ) -testlist_gexp: (test|star_expr) ( old_comp_for | comp_async_for | (',' (test|star_expr))* [','] ) +listmaker: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] ) +testlist_gexp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] ) lambdef: 'lambda' [varargslist] ':' test trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME subscriptlist: subscript (',' subscript)* [','] @@ -141,9 +140,9 @@ sliceop: ':' [test] exprlist: (expr|star_expr) (',' (expr|star_expr))* [','] testlist: test (',' test)* [','] dictsetmaker: ( ((test ':' test | '**' expr) - (comp_for | comp_async_for | (',' (test ':' test | '**' expr))* [','])) | + (comp_for | (',' (test ':' test | '**' expr))* [','])) | ((test | star_expr) - (comp_for | comp_async_for | (',' (test | star_expr))* [','])) ) + (comp_for | (',' (test | star_expr))* [','])) ) classdef: 'class' NAME ['(' [arglist] ')'] ':' suite @@ -156,15 +155,13 @@ arglist: argument (',' argument)* [','] # Illegal combinations and orderings are blocked in ast.c: # multiple (test comp_for) arguments are blocked; keyword unpackings # that precede iterable unpackings are blocked; etc. -argument: ( test [comp_for_or_async] | +argument: ( test [comp_for] | test '=' test | '**' expr | star_expr ) -comp_for_or_async: comp_async_for | comp_for -comp_iter: comp_async_for | comp_for | comp_if -comp_async_for: 'async' 'for' exprlist 'in' testlist_safe [comp_iter] -comp_for: 'for' exprlist 'in' testlist_safe [comp_iter] +comp_iter: comp_for | comp_if +comp_for: ['async'] 'for' exprlist 'in' testlist_safe [comp_iter] comp_if: 'if' old_test [comp_iter] # As noted above, testlist_safe extends the syntax allowed in list From 38ba8107df28693a40c9d75149f78dc892072d25 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 4 Oct 2017 20:35:24 -0700 Subject: [PATCH 25/26] remove "again" from wording intoken.rst --- Doc/library/token.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/token.rst b/Doc/library/token.rst index f6a96b9d22b2a5..373991027e4ca9 100644 --- a/Doc/library/token.rst +++ b/Doc/library/token.rst @@ -133,5 +133,5 @@ the :mod:`tokenize` module. Added :data:`COMMENT`, :data:`NL` and :data:`ENCODING` tokens. .. versionchanged:: 3.7 - Removed :data:`AWAIT` and :data:`ASYNC` tokens again. "async" and - "await" are now tokenized as :data:`NAME` tokens. + Removed :data:`AWAIT` and :data:`ASYNC` tokens. "async" and "await" are + now tokenized as :data:`NAME` tokens. From 78ddbde18fb6ec5145dc8d96cce6a91ea65960d2 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 5 Oct 2017 19:05:15 -0700 Subject: [PATCH 26/26] fix lib2to3 --- Lib/lib2to3/Grammar.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/lib2to3/Grammar.txt b/Lib/lib2to3/Grammar.txt index be07973d3c1a22..0bdfcafcf3cabb 100644 --- a/Lib/lib2to3/Grammar.txt +++ b/Lib/lib2to3/Grammar.txt @@ -130,8 +130,8 @@ atom: ('(' [yield_expr|testlist_gexp] ')' | '{' [dictsetmaker] '}' | '`' testlist1 '`' | NAME | NUMBER | STRING+ | '.' '.' '.') -listmaker: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] ) -testlist_gexp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] ) +listmaker: (test|star_expr) ( old_comp_for | (',' (test|star_expr))* [','] ) +testlist_gexp: (test|star_expr) ( old_comp_for | (',' (test|star_expr))* [','] ) lambdef: 'lambda' [varargslist] ':' test trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME subscriptlist: subscript (',' subscript)* [','] @@ -161,7 +161,7 @@ argument: ( test [comp_for] | star_expr ) comp_iter: comp_for | comp_if -comp_for: ['async'] 'for' exprlist 'in' testlist_safe [comp_iter] +comp_for: ['async'] 'for' exprlist 'in' or_test [comp_iter] comp_if: 'if' old_test [comp_iter] # As noted above, testlist_safe extends the syntax allowed in list @@ -180,7 +180,7 @@ comp_if: 'if' old_test [comp_iter] # # See https://bugs.python.org/issue27494 old_comp_iter: old_comp_for | old_comp_if -old_comp_for: [ASYNC] 'for' exprlist 'in' testlist_safe [old_comp_iter] +old_comp_for: ['async'] 'for' exprlist 'in' testlist_safe [old_comp_iter] old_comp_if: 'if' old_test [old_comp_iter] testlist1: test (',' test)*