summaryrefslogtreecommitdiffstats
path: root/Parser/parser.c
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/parser.c
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/parser.c')
-rw-r--r--Parser/parser.c22
1 files changed, 12 insertions, 10 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;
}
}