Skip to content

Commit c155dd4

Browse files
committed
Disable the parser hacks that allowed the "yield" keyword to be enabled
by a future statement.
1 parent 558ba52 commit c155dd4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Parser/parser.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ PyParser_New(grammar *g, int start)
7979
if (ps == NULL)
8080
return NULL;
8181
ps->p_grammar = g;
82+
#if 0 /* future keyword */
8283
ps->p_generators = 0;
84+
#endif
8385
ps->p_tree = PyNode_New(start);
8486
if (ps->p_tree == NULL) {
8587
PyMem_DEL(ps);
@@ -145,10 +147,12 @@ classify(parser_state *ps, int type, char *str)
145147
if (l->lb_type == NAME && l->lb_str != NULL &&
146148
l->lb_str[0] == s[0] &&
147149
strcmp(l->lb_str, s) == 0) {
150+
#if 0 /* future keyword */
148151
if (!ps->p_generators &&
149152
s[0] == 'y' &&
150153
strcmp(s, "yield") == 0)
151154
break; /* not a keyword */
155+
#endif
152156
D(printf("It's a keyword\n"));
153157
return n - i;
154158
}
@@ -170,6 +174,7 @@ classify(parser_state *ps, int type, char *str)
170174
return -1;
171175
}
172176

177+
#if 0 /* future keyword */
173178
static void
174179
future_hack(parser_state *ps)
175180
{
@@ -191,6 +196,7 @@ future_hack(parser_state *ps)
191196
}
192197
}
193198
}
199+
#endif /* future keyword */
194200

195201
int
196202
PyParser_AddToken(register parser_state *ps, register int type, char *str,
@@ -249,10 +255,12 @@ PyParser_AddToken(register parser_state *ps, register int type, char *str,
249255
"Direct pop.\n",
250256
d->d_name,
251257
ps->p_stack.s_top->s_state));
258+
#if 0 /* future keyword */
252259
if (d->d_name[0] == 'i' &&
253260
strcmp(d->d_name,
254261
"import_stmt") == 0)
255262
future_hack(ps);
263+
#endif
256264
s_pop(&ps->p_stack);
257265
if (s_empty(&ps->p_stack)) {
258266
D(printf(" ACCEPT.\n"));
@@ -265,9 +273,11 @@ PyParser_AddToken(register parser_state *ps, register int type, char *str,
265273
}
266274

267275
if (s->s_accept) {
276+
#if 0 /* future keyword */
268277
if (d->d_name[0] == 'i' &&
269278
strcmp(d->d_name, "import_stmt") == 0)
270279
future_hack(ps);
280+
#endif
271281
/* Pop this dfa and try again */
272282
s_pop(&ps->p_stack);
273283
D(printf(" Pop ...\n"));

0 commit comments

Comments
 (0)