mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
Add support for yield statements.
(Should be merged with descr branch.)
This commit is contained in:
parent
654c8db9a0
commit
02126f20b6
1 changed files with 17 additions and 1 deletions
|
@ -830,7 +830,7 @@ VALIDATER(trailer); VALIDATER(subscript);
|
||||||
VALIDATER(subscriptlist); VALIDATER(sliceop);
|
VALIDATER(subscriptlist); VALIDATER(sliceop);
|
||||||
VALIDATER(exprlist); VALIDATER(dictmaker);
|
VALIDATER(exprlist); VALIDATER(dictmaker);
|
||||||
VALIDATER(arglist); VALIDATER(argument);
|
VALIDATER(arglist); VALIDATER(argument);
|
||||||
VALIDATER(listmaker);
|
VALIDATER(listmaker); VALIDATER(yield_stmt);
|
||||||
|
|
||||||
#undef VALIDATER
|
#undef VALIDATER
|
||||||
|
|
||||||
|
@ -1538,6 +1538,18 @@ validate_raise_stmt(node *tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* yield_stmt: 'yield' testlist
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
validate_yield_stmt(node *tree)
|
||||||
|
{
|
||||||
|
return (validate_ntype(tree, yield_stmt)
|
||||||
|
&& validate_numnodes(tree, 2, "yield_stmt")
|
||||||
|
&& validate_name(CHILD(tree, 0), "yield")
|
||||||
|
&& validate_testlist(CHILD(tree, 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
validate_import_as_name(node *tree)
|
validate_import_as_name(node *tree)
|
||||||
{
|
{
|
||||||
|
@ -2555,6 +2567,7 @@ validate_node(node *tree)
|
||||||
res = (validate_numnodes(tree, 1, "flow_stmt")
|
res = (validate_numnodes(tree, 1, "flow_stmt")
|
||||||
&& ((TYPE(CHILD(tree, 0)) == break_stmt)
|
&& ((TYPE(CHILD(tree, 0)) == break_stmt)
|
||||||
|| (TYPE(CHILD(tree, 0)) == continue_stmt)
|
|| (TYPE(CHILD(tree, 0)) == continue_stmt)
|
||||||
|
|| (TYPE(CHILD(tree, 0)) == yield_stmt)
|
||||||
|| (TYPE(CHILD(tree, 0)) == return_stmt)
|
|| (TYPE(CHILD(tree, 0)) == return_stmt)
|
||||||
|| (TYPE(CHILD(tree, 0)) == raise_stmt)));
|
|| (TYPE(CHILD(tree, 0)) == raise_stmt)));
|
||||||
if (res)
|
if (res)
|
||||||
|
@ -2562,6 +2575,9 @@ validate_node(node *tree)
|
||||||
else if (nch == 1)
|
else if (nch == 1)
|
||||||
err_string("illegal flow_stmt type");
|
err_string("illegal flow_stmt type");
|
||||||
break;
|
break;
|
||||||
|
case yield_stmt:
|
||||||
|
res = validate_yield_stmt(tree);
|
||||||
|
break;
|
||||||
/*
|
/*
|
||||||
* Compound statements.
|
* Compound statements.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue