summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorJelle Zijlstra <jelle.zijlstra@gmail.com>2017-10-06 03:24:46 (GMT)
committerYury Selivanov <yury@magic.io>2017-10-06 03:24:46 (GMT)
commitac317700ce7439e38a8b420218d9a5035bba92ed (patch)
treeddeb7d90f2e90b73a37783b88ef77376d9d996f5 /Parser
parent2084b30e540d88b9fc752c5bdcc2f24334af4f2b (diff)
downloadcpython-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')
-rw-r--r--Parser/tokenizer.c63
-rw-r--r--Parser/tokenizer.h7
2 files changed, 0 insertions, 70 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;
}
diff --git a/Parser/tokenizer.h b/Parser/tokenizer.h
index 0ad3551..ad8b1c8 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);