diff src/ast_convert.rs @ 8:94ff501bf336

Add ast.AugAssign.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 31 May 2016 04:34:42 +0100
parents 680d15073f55
children fa7e285f88e7
line wrap: on
line diff
--- a/src/ast_convert.rs
+++ b/src/ast_convert.rs
@@ -255,6 +255,7 @@ fn parse_statement(py: Python, ast: PyOb
     let function_def_type = ast_module.get(py, "FunctionDef").unwrap();
     let global_type = ast_module.get(py, "Global").unwrap();
     let assign_type = ast_module.get(py, "Assign").unwrap();
+    let aug_assign_type = ast_module.get(py, "AugAssign").unwrap();
     let return_type = ast_module.get(py, "Return").unwrap();
     let import_from_type = ast_module.get(py, "ImportFrom").unwrap();
     let if_type = ast_module.get(py, "If").unwrap();
@@ -418,6 +419,16 @@ fn parse_statement(py: Python, ast: PyOb
         let value = parse_expr(py, value);
 
         Statement::Assign(arguments, value)
+    } else if is_instance(&ast, &aug_assign_type) {
+        let target = ast.getattr(py, "target").unwrap();
+        let op = ast.getattr(py, "op").unwrap();
+        let value = ast.getattr(py, "value").unwrap();
+
+        let target = parse_expr(py, target);
+        let op = parse_binop(py, op);
+        let value = parse_expr(py, value);
+
+        Statement::AugAssign(target, op, value)
     } else if is_instance(&ast, &import_from_type) {
         let module = ast.getattr(py, "module").unwrap();
         let names = ast.getattr(py, "names").unwrap();