diff src/ast_convert.rs @ 21:7af637f444d1

Add ast.Delete
author Bastien Orivel <eijebong@bananium.fr>
date Fri, 03 Jun 2016 10:52:02 +0200
parents ace12d6b9855
children 5f1d285471af
line wrap: on
line diff
--- a/src/ast_convert.rs
+++ b/src/ast_convert.rs
@@ -20,12 +20,15 @@ fn get_ctx(py: Python, object: PyObject)
     let ast_module = py.import("ast").unwrap();
     let store_type = ast_module.get(py, "Store").unwrap();
     let load_type = ast_module.get(py, "Load").unwrap();
+    let del_type = ast_module.get(py, "Del").unwrap();
 
     let ctx = object.getattr(py, "ctx").unwrap();
     if is_instance(&ctx, &store_type) {
         expr_context::Store
     } else if is_instance(&ctx, &load_type) {
         expr_context::Load
+    } else if is_instance(&ctx, &del_type) {
+        expr_context::Del
     } else{
         unreachable!();
     }
@@ -426,6 +429,7 @@ fn parse_statement(py: Python, ast: PyOb
     let for_type = ast_module.get(py, "For").unwrap();
     let expr_type = ast_module.get(py, "Expr").unwrap();
     let break_type = ast_module.get(py, "Break").unwrap();
+    let delete_type = ast_module.get(py, "Delete").unwrap();
 
     assert!(is_instance(&ast, &ast_type));
 
@@ -554,6 +558,10 @@ fn parse_statement(py: Python, ast: PyOb
         stmt::Expr(value)
     } else if is_instance(&ast, &break_type) {
         stmt::Break
+    } else if is_instance(&ast, &delete_type) {
+        let targets = ast.getattr(py, "targets").unwrap();
+        let targets = parse_list(py, targets, parse_expr);
+        stmt::Delete(targets)
     } else {
         println!("stmt {}", ast);
         panic!()