mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
Disambiguate the grammar for backtick.
The old syntax suggested that a trailing comma was OK inside backticks, but in fact (due to ideosyncrasies of pgen) it was not. Fix the grammar to avoid the ambiguity. Fred: you may want to update the refman.
This commit is contained in:
parent
a0a6c5a042
commit
2d3b986480
5 changed files with 93 additions and 59 deletions
|
@ -844,6 +844,7 @@ VALIDATER(subscriptlist); VALIDATER(sliceop);
|
|||
VALIDATER(exprlist); VALIDATER(dictmaker);
|
||||
VALIDATER(arglist); VALIDATER(argument);
|
||||
VALIDATER(listmaker); VALIDATER(yield_stmt);
|
||||
VALIDATER(testlist1);
|
||||
|
||||
#undef VALIDATER
|
||||
|
||||
|
@ -1056,6 +1057,14 @@ validate_testlist(node *tree)
|
|||
}
|
||||
|
||||
|
||||
static int
|
||||
validate_testlist1(node *tree)
|
||||
{
|
||||
return (validate_repeating_list(tree, testlist1,
|
||||
validate_test, "testlist1"));
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
validate_testlist_safe(node *tree)
|
||||
{
|
||||
|
@ -2185,7 +2194,7 @@ validate_atom(node *tree)
|
|||
break;
|
||||
case BACKQUOTE:
|
||||
res = ((nch == 3)
|
||||
&& validate_testlist(CHILD(tree, 1))
|
||||
&& validate_testlist1(CHILD(tree, 1))
|
||||
&& validate_ntype(CHILD(tree, 2), BACKQUOTE));
|
||||
break;
|
||||
case NAME:
|
||||
|
@ -2671,6 +2680,9 @@ validate_node(node *tree)
|
|||
case testlist:
|
||||
res = validate_testlist(tree);
|
||||
break;
|
||||
case testlist1:
|
||||
res = validate_testlist1(tree);
|
||||
break;
|
||||
case test:
|
||||
res = validate_test(tree);
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue