summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2006-02-28 22:42:15 (GMT)
committerThomas Wouters <thomas@python.org>2006-02-28 22:42:15 (GMT)
commit8ae1295c5b6cfef0fc6db5c97fe68a0b40de8331 (patch)
tree9f4e563b80a5748e23c5e15b56502731a12501cc /Parser
parent6cba25666c278760a9fea024948b8add7d5c4b1a (diff)
downloadcpython-8ae1295c5b6cfef0fc6db5c97fe68a0b40de8331.zip
cpython-8ae1295c5b6cfef0fc6db5c97fe68a0b40de8331.tar.gz
cpython-8ae1295c5b6cfef0fc6db5c97fe68a0b40de8331.tar.bz2
Make 'as' an actual keyword when with's future statement is used. Not
actually necessary for functionality, but good for transition.
Diffstat (limited to 'Parser')
-rw-r--r--Parser/parser.c22
-rw-r--r--Parser/parsetok.c4
2 files changed, 14 insertions, 12 deletions
diff --git a/Parser/parser.c b/Parser/parser.c
index cad5ce2..4a5307c 100644
--- a/Parser/parser.c
+++ b/Parser/parser.c
@@ -144,18 +144,20 @@ classify(parser_state *ps, int type, char *str)
register label *l = g->g_ll.ll_label;
register int i;
for (i = n; i > 0; i--, l++) {
- if (l->lb_type == NAME && l->lb_str != NULL &&
- l->lb_str[0] == s[0] &&
- strcmp(l->lb_str, s) == 0) {
+ if (l->lb_type != NAME || l->lb_str == NULL ||
+ l->lb_str[0] != s[0] ||
+ strcmp(l->lb_str, s) != 0)
+ continue;
#ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD
- if (!(ps->p_flags & CO_FUTURE_WITH_STATEMENT) &&
- s[0] == 'w' &&
- strcmp(s, "with") == 0)
- break; /* not a keyword */
-#endif
- D(printf("It's a keyword\n"));
- return n - i;
+ if (!(ps->p_flags & CO_FUTURE_WITH_STATEMENT)) {
+ if (s[0] == 'w' && strcmp(s, "with") == 0)
+ break; /* not a keyword yet */
+ else if (s[0] == 'a' && strcmp(s, "as") == 0)
+ break; /* not a keyword yet */
}
+#endif
+ D(printf("It's a keyword\n"));
+ return n - i;
}
}
diff --git a/Parser/parsetok.c b/Parser/parsetok.c
index cf445e1..8b1f70c 100644
--- a/Parser/parsetok.c
+++ b/Parser/parsetok.c
@@ -176,8 +176,8 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
if (len == 4 && str[0] == 'w' && strcmp(str, "with") == 0)
warn(with_msg, err_ret->filename, tok->lineno);
else if (!(handling_import || handling_with) &&
- len == 2 &&
- str[0] == 'a' && strcmp(str, "as") == 0)
+ len == 2 && str[0] == 'a' &&
+ strcmp(str, "as") == 0)
warn(as_msg, err_ret->filename, tok->lineno);
}
else if (type == NAME &&