mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
validate_listmaker(): Revise to match Skip's latest changes to the
Grammar file. This makes the test suite pass once again.
This commit is contained in:
parent
03c06ee7fc
commit
85bf3bb44a
1 changed files with 12 additions and 6 deletions
|
@ -2193,6 +2193,9 @@ validate_atom(node *tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* listmaker:
|
||||||
|
* test ( list_for | (',' test)* [','] )
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
validate_listmaker(node *tree)
|
validate_listmaker(node *tree)
|
||||||
{
|
{
|
||||||
|
@ -2207,19 +2210,22 @@ validate_listmaker(node *tree)
|
||||||
/*
|
/*
|
||||||
* list_iter | (',' test)* [',']
|
* list_iter | (',' test)* [',']
|
||||||
*/
|
*/
|
||||||
if (nch == 2 && TYPE(CHILD(tree, 1)) == list_iter)
|
if (nch == 2 && TYPE(CHILD(tree, 1)) == list_for)
|
||||||
ok = validate_list_iter(CHILD(tree, 1));
|
ok = validate_list_for(CHILD(tree, 1));
|
||||||
else {
|
else {
|
||||||
/* (',' test)* [','] */
|
/* (',' test)* [','] */
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while (ok && nch - i >= 2) {
|
while (ok && nch - i >= 2) {
|
||||||
ok = (validate_comma(CHILD(tree, i))
|
ok = (validate_comma(CHILD(tree, i))
|
||||||
&& validate_test(CHILD(tree, i+1)));
|
&& validate_test(CHILD(tree, i+1)));
|
||||||
if (ok)
|
i += 2;
|
||||||
i += 2;
|
}
|
||||||
|
if (ok && i == nch-1)
|
||||||
|
ok = validate_comma(CHILD(tree, i));
|
||||||
|
else if (i != nch) {
|
||||||
|
ok = 0;
|
||||||
|
err_string("illegal trailing nodes for listmaker");
|
||||||
}
|
}
|
||||||
if (ok && nch-i)
|
|
||||||
ok = validate_comma(CHILD(tree, nch-1));
|
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue