# HG changeset patch # User Bastien Orivel # Date 1465834866 -7200 # Node ID 2a6629ea82b56786deb6b6508a0b4889e7f64134 # Parent 7ac23f4336b194e3627807805bc51a3e365e4a0c Add ast.Await. diff --git a/src/ast_convert.rs b/src/ast_convert.rs --- 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!() diff --git a/src/ast_dump.rs b/src/ast_dump.rs --- 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()), } } } diff --git a/src/python_ast.rs b/src/python_ast.rs --- a/src/python_ast.rs +++ b/src/python_ast.rs @@ -91,7 +91,7 @@ pub enum expr { //GeneratorExp(Box, Vec) // the grammar constrains where yield expressions can occur - //Await(expr value) + Await(Box), //Yield(expr? value) //YieldFrom(expr value) diff --git a/tests/test_parse_files/test_await.py b/tests/test_parse_files/test_await.py new file mode 100644 --- /dev/null +++ b/tests/test_parse_files/test_await.py @@ -0,0 +1,2 @@ +async def a(): + await b()