diff options
author | Fred Drake <fdrake@acm.org> | 2001-07-17 02:59:15 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-07-17 02:59:15 (GMT) |
commit | 02126f20b627a4189f34c9758284ab367e9b7711 (patch) | |
tree | 215e67f75660e08eb81e681eabd6bd63c4aafe86 | |
parent | 654c8db9a0b93e4acdc2aaf27fae557a6d52ed21 (diff) | |
download | cpython-02126f20b627a4189f34c9758284ab367e9b7711.zip cpython-02126f20b627a4189f34c9758284ab367e9b7711.tar.gz cpython-02126f20b627a4189f34c9758284ab367e9b7711.tar.bz2 |
Add support for yield statements.
(Should be merged with descr branch.)
-rw-r--r-- | Modules/parsermodule.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c index 13fdfae..6ff98de 100644 --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -830,7 +830,7 @@ VALIDATER(trailer); VALIDATER(subscript); VALIDATER(subscriptlist); VALIDATER(sliceop); VALIDATER(exprlist); VALIDATER(dictmaker); VALIDATER(arglist); VALIDATER(argument); -VALIDATER(listmaker); +VALIDATER(listmaker); VALIDATER(yield_stmt); #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 validate_import_as_name(node *tree) { @@ -2555,6 +2567,7 @@ validate_node(node *tree) res = (validate_numnodes(tree, 1, "flow_stmt") && ((TYPE(CHILD(tree, 0)) == break_stmt) || (TYPE(CHILD(tree, 0)) == continue_stmt) + || (TYPE(CHILD(tree, 0)) == yield_stmt) || (TYPE(CHILD(tree, 0)) == return_stmt) || (TYPE(CHILD(tree, 0)) == raise_stmt))); if (res) @@ -2562,6 +2575,9 @@ validate_node(node *tree) else if (nch == 1) err_string("illegal flow_stmt type"); break; + case yield_stmt: + res = validate_yield_stmt(tree); + break; /* * Compound statements. */ |