Disable the parser hacks that allowed the "yield" keyword to be enabled
by a future statement.
This commit is contained in:
parent
558ba52f10
commit
c155dd4ca9
|
@ -79,7 +79,9 @@ PyParser_New(grammar *g, int start)
|
||||||
if (ps == NULL)
|
if (ps == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
ps->p_grammar = g;
|
ps->p_grammar = g;
|
||||||
|
#if 0 /* future keyword */
|
||||||
ps->p_generators = 0;
|
ps->p_generators = 0;
|
||||||
|
#endif
|
||||||
ps->p_tree = PyNode_New(start);
|
ps->p_tree = PyNode_New(start);
|
||||||
if (ps->p_tree == NULL) {
|
if (ps->p_tree == NULL) {
|
||||||
PyMem_DEL(ps);
|
PyMem_DEL(ps);
|
||||||
|
@ -145,10 +147,12 @@ classify(parser_state *ps, int type, char *str)
|
||||||
if (l->lb_type == NAME && l->lb_str != NULL &&
|
if (l->lb_type == NAME && l->lb_str != NULL &&
|
||||||
l->lb_str[0] == s[0] &&
|
l->lb_str[0] == s[0] &&
|
||||||
strcmp(l->lb_str, s) == 0) {
|
strcmp(l->lb_str, s) == 0) {
|
||||||
|
#if 0 /* future keyword */
|
||||||
if (!ps->p_generators &&
|
if (!ps->p_generators &&
|
||||||
s[0] == 'y' &&
|
s[0] == 'y' &&
|
||||||
strcmp(s, "yield") == 0)
|
strcmp(s, "yield") == 0)
|
||||||
break; /* not a keyword */
|
break; /* not a keyword */
|
||||||
|
#endif
|
||||||
D(printf("It's a keyword\n"));
|
D(printf("It's a keyword\n"));
|
||||||
return n - i;
|
return n - i;
|
||||||
}
|
}
|
||||||
|
@ -170,6 +174,7 @@ classify(parser_state *ps, int type, char *str)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 /* future keyword */
|
||||||
static void
|
static void
|
||||||
future_hack(parser_state *ps)
|
future_hack(parser_state *ps)
|
||||||
{
|
{
|
||||||
|
@ -191,6 +196,7 @@ future_hack(parser_state *ps)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* future keyword */
|
||||||
|
|
||||||
int
|
int
|
||||||
PyParser_AddToken(register parser_state *ps, register int type, char *str,
|
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,
|
||||||
"Direct pop.\n",
|
"Direct pop.\n",
|
||||||
d->d_name,
|
d->d_name,
|
||||||
ps->p_stack.s_top->s_state));
|
ps->p_stack.s_top->s_state));
|
||||||
|
#if 0 /* future keyword */
|
||||||
if (d->d_name[0] == 'i' &&
|
if (d->d_name[0] == 'i' &&
|
||||||
strcmp(d->d_name,
|
strcmp(d->d_name,
|
||||||
"import_stmt") == 0)
|
"import_stmt") == 0)
|
||||||
future_hack(ps);
|
future_hack(ps);
|
||||||
|
#endif
|
||||||
s_pop(&ps->p_stack);
|
s_pop(&ps->p_stack);
|
||||||
if (s_empty(&ps->p_stack)) {
|
if (s_empty(&ps->p_stack)) {
|
||||||
D(printf(" ACCEPT.\n"));
|
D(printf(" ACCEPT.\n"));
|
||||||
|
@ -265,9 +273,11 @@ PyParser_AddToken(register parser_state *ps, register int type, char *str,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->s_accept) {
|
if (s->s_accept) {
|
||||||
|
#if 0 /* future keyword */
|
||||||
if (d->d_name[0] == 'i' &&
|
if (d->d_name[0] == 'i' &&
|
||||||
strcmp(d->d_name, "import_stmt") == 0)
|
strcmp(d->d_name, "import_stmt") == 0)
|
||||||
future_hack(ps);
|
future_hack(ps);
|
||||||
|
#endif
|
||||||
/* Pop this dfa and try again */
|
/* Pop this dfa and try again */
|
||||||
s_pop(&ps->p_stack);
|
s_pop(&ps->p_stack);
|
||||||
D(printf(" Pop ...\n"));
|
D(printf(" Pop ...\n"));
|
||||||
|
|
Loading…
Reference in New Issue