# HG changeset patch # User Bastien Orivel # Date 1465846874 -7200 # Node ID e59cd5754268b9f9f1da5533df2fc18310d7d238 # Parent 2d906d1cb9408e03581ad4a225e487702ea7e39e Add ast.Starred. diff --git a/src/ast_convert.rs b/src/ast_convert.rs --- a/src/ast_convert.rs +++ b/src/ast_convert.rs @@ -351,6 +351,7 @@ fn parse_expr(py: Python, ast: PyObject) let ifexp_type = ast_module.get(py, "IfExp").unwrap(); let dict_type = ast_module.get(py, "Dict").unwrap(); let subscript_type = ast_module.get(py, "Subscript").unwrap(); + let starred_type = ast_module.get(py, "Starred").unwrap(); assert!(is_instance(&ast, &ast_type)); @@ -523,6 +524,13 @@ fn parse_expr(py: Python, ast: PyObject) let slice = parse_slice(py, slice); expr::Subscript(Box::new(value), Box::new(slice), ctx) + } else if is_instance(&ast, &starred_type) { + let value = ast.getattr(py, "value").unwrap(); + let ctx = get_ctx(py, ast); + + let value = parse_expr(py, value); + + expr::Starred(Box::new(value), ctx) } 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 @@ -246,6 +246,7 @@ impl to_string_able for expr { ) }, expr::Subscript(value, slice, _) => format!("{}[{}]", value.to_string(), slice.to_string()), + expr::Starred(value, _) => format!("*{}", 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 @@ -109,7 +109,7 @@ pub enum expr { // the following expression can appear in assignment context Attribute(Box, String, expr_context), Subscript(Box, Box, expr_context), - //Starred(Box, expr_context), + Starred(Box, expr_context), Name(String, expr_context), List(Vec, expr_context), Tuple(Vec, expr_context), diff --git a/tests/test_parse_files/test_starred.py b/tests/test_parse_files/test_starred.py new file mode 100644 --- /dev/null +++ b/tests/test_parse_files/test_starred.py @@ -0,0 +1,1 @@ +*b = (1, 2)