Mercurial > python-compiler.rs
diff src/ast_convert.rs @ 74:97537c90d92d
Add ast.Yield.
author | Bastien Orivel <eijebong@bananium.fr> |
---|---|
date | Mon, 13 Jun 2016 18:25:02 +0200 |
parents | 2a6629ea82b5 |
children | 1abc8ca9f30b |
line wrap: on
line diff
--- a/src/ast_convert.rs +++ b/src/ast_convert.rs @@ -302,6 +302,7 @@ fn parse_expr(py: Python, ast: PyObject) let tuple_type = ast_module.get(py, "Tuple").unwrap(); let ellipsis_type = ast_module.get(py, "Ellipsis").unwrap(); let await_type = ast_module.get(py, "Await").unwrap(); + let yield_type = ast_module.get(py, "Yield").unwrap(); assert!(is_instance(&ast, &ast_type)); @@ -408,6 +409,11 @@ fn parse_expr(py: Python, ast: PyObject) let value = parse_expr(py, value); expr::Await(Box::new(value)) + } else if is_instance(&ast, &yield_type) { + let value = ast.getattr(py, "value").unwrap(); + let value = parse_optional_expr(py, value); + + expr::Yield(Box::new(value)) } else { println!("expr {}", ast); unreachable!()