diff options
author | Jelle Zijlstra <jelle.zijlstra@gmail.com> | 2017-10-06 03:24:46 (GMT) |
---|---|---|
committer | Yury Selivanov <yury@magic.io> | 2017-10-06 03:24:46 (GMT) |
commit | ac317700ce7439e38a8b420218d9a5035bba92ed (patch) | |
tree | ddeb7d90f2e90b73a37783b88ef77376d9d996f5 /Parser/tokenizer.c | |
parent | 2084b30e540d88b9fc752c5bdcc2f24334af4f2b (diff) | |
download | cpython-ac317700ce7439e38a8b420218d9a5035bba92ed.zip cpython-ac317700ce7439e38a8b420218d9a5035bba92ed.tar.gz cpython-ac317700ce7439e38a8b420218d9a5035bba92ed.tar.bz2 |
bpo-30406: Make async and await proper keywords (#1669)
Per PEP 492, 'async' and 'await' should become proper keywords in 3.7.
Diffstat (limited to 'Parser/tokenizer.c')
-rw-r--r-- | Parser/tokenizer.c | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 51f98e9..28254e1 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", "<ERRORTOKEN>", "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; } |