Mercurial > python-compiler.rs
changeset 73:2a6629ea82b5
Add ast.Await.
author | Bastien Orivel <eijebong@bananium.fr> |
---|---|
date | Mon, 13 Jun 2016 18:21:06 +0200 |
parents | 7ac23f4336b1 |
children | 97537c90d92d |
files | src/ast_convert.rs src/ast_dump.rs src/python_ast.rs tests/test_parse_files/test_await.py |
diffstat | 4 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ast_convert.rs +++ b/src/ast_convert.rs @@ -301,6 +301,7 @@ fn parse_expr(py: Python, ast: PyObject) let dictcomp_type = ast_module.get(py, "DictComp").unwrap(); 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(); assert!(is_instance(&ast, &ast_type)); @@ -402,6 +403,11 @@ fn parse_expr(py: Python, ast: PyObject) expr::Tuple(elts, get_ctx(py, ast)) } else if is_instance(&ast, &ellipsis_type) { expr::Ellipsis + } else if is_instance(&ast, &await_type) { + let value = ast.getattr(py, "value").unwrap(); + let value = parse_expr(py, value); + + expr::Await(Box::new(value)) } else { println!("expr {}", ast); unreachable!()
--- a/src/ast_dump.rs +++ b/src/ast_dump.rs @@ -186,6 +186,7 @@ impl to_string_able for expr { expr::DictComp(key, value, generators) => format!("{{{}: {} {}}}", key.to_string(), value.to_string(), vec_to_strings_vec(generators).join(" ")), expr::Tuple(elts, _) => format!("({})", vec_to_strings_vec(elts).join(", ")), expr::Ellipsis => format!("..."), + expr::Await(value) => format!("await {}", value.to_string()), } } }