# HG changeset patch # User Bastien Orivel # Date 1465405306 -7200 # Node ID d9838e8b3ec5b6b87f62bab39b7c34d4a2e133a7 # Parent ded1907b7a6991abdad9dc801938d818c1b292cf Add ast.Ellipsis. diff --git a/src/ast_convert.rs b/src/ast_convert.rs --- a/src/ast_convert.rs +++ b/src/ast_convert.rs @@ -251,6 +251,7 @@ fn parse_expr(py: Python, ast: PyObject) let listcomp_type = ast_module.get(py, "ListComp").unwrap(); 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(); assert!(is_instance(&ast, &ast_type)); @@ -361,6 +362,8 @@ fn parse_expr(py: Python, ast: PyObject) let elts = ast.getattr(py, "elts").unwrap(); let elts = parse_list(py, elts, parse_expr); expr::Tuple(elts, get_ctx(py, ast)) + } else if is_instance(&ast, &ellipsis_type) { + expr::Ellipsis } 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 @@ -155,7 +155,8 @@ impl expr { expr::List(elts, ctx) => format!("[{}]", args_to_string(elts)), expr::ListComp(elt, generators) => format!("[{} {}]", elt.to_string(), generators_to_string(generators)), expr::DictComp(key, value, generators) => format!("{{{}: {} {}}}", key.to_string(), value.to_string(), generators_to_string(generators)), - expr::Tuple(elts, ctx) => format!("({})", args_to_string(elts)) + expr::Tuple(elts, ctx) => format!("({})", args_to_string(elts)), + expr::Ellipsis => format!("..."), } } } diff --git a/src/python_ast.rs b/src/python_ast.rs --- a/src/python_ast.rs +++ b/src/python_ast.rs @@ -103,7 +103,7 @@ pub enum expr { Str(String), //Bytes(String), NameConstant(String), - //Ellipsis, + Ellipsis, // the following expression can appear in assignment context Attribute(Box, String, expr_context), diff --git a/tests/test_parse_files/test_ellipsis.py b/tests/test_parse_files/test_ellipsis.py new file mode 100644 --- /dev/null +++ b/tests/test_parse_files/test_ellipsis.py @@ -0,0 +1,1 @@ +a = ...