Mercurial > python-compiler.rs
comparison 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 |
comparison
equal
deleted
inserted
replaced
7:680d15073f55 | 8:94ff501bf336 |
---|---|
253 let ast_type = ast_module.get(py, "AST").unwrap(); | 253 let ast_type = ast_module.get(py, "AST").unwrap(); |
254 let class_def_type = ast_module.get(py, "ClassDef").unwrap(); | 254 let class_def_type = ast_module.get(py, "ClassDef").unwrap(); |
255 let function_def_type = ast_module.get(py, "FunctionDef").unwrap(); | 255 let function_def_type = ast_module.get(py, "FunctionDef").unwrap(); |
256 let global_type = ast_module.get(py, "Global").unwrap(); | 256 let global_type = ast_module.get(py, "Global").unwrap(); |
257 let assign_type = ast_module.get(py, "Assign").unwrap(); | 257 let assign_type = ast_module.get(py, "Assign").unwrap(); |
258 let aug_assign_type = ast_module.get(py, "AugAssign").unwrap(); | |
258 let return_type = ast_module.get(py, "Return").unwrap(); | 259 let return_type = ast_module.get(py, "Return").unwrap(); |
259 let import_from_type = ast_module.get(py, "ImportFrom").unwrap(); | 260 let import_from_type = ast_module.get(py, "ImportFrom").unwrap(); |
260 let if_type = ast_module.get(py, "If").unwrap(); | 261 let if_type = ast_module.get(py, "If").unwrap(); |
261 let while_type = ast_module.get(py, "While").unwrap(); | 262 let while_type = ast_module.get(py, "While").unwrap(); |
262 let for_type = ast_module.get(py, "For").unwrap(); | 263 let for_type = ast_module.get(py, "For").unwrap(); |
416 } | 417 } |
417 | 418 |
418 let value = parse_expr(py, value); | 419 let value = parse_expr(py, value); |
419 | 420 |
420 Statement::Assign(arguments, value) | 421 Statement::Assign(arguments, value) |
422 } else if is_instance(&ast, &aug_assign_type) { | |
423 let target = ast.getattr(py, "target").unwrap(); | |
424 let op = ast.getattr(py, "op").unwrap(); | |
425 let value = ast.getattr(py, "value").unwrap(); | |
426 | |
427 let target = parse_expr(py, target); | |
428 let op = parse_binop(py, op); | |
429 let value = parse_expr(py, value); | |
430 | |
431 Statement::AugAssign(target, op, value) | |
421 } else if is_instance(&ast, &import_from_type) { | 432 } else if is_instance(&ast, &import_from_type) { |
422 let module = ast.getattr(py, "module").unwrap(); | 433 let module = ast.getattr(py, "module").unwrap(); |
423 let names = ast.getattr(py, "names").unwrap(); | 434 let names = ast.getattr(py, "names").unwrap(); |
424 //let level = ast.getattr(py, "level").unwrap(); | 435 //let level = ast.getattr(py, "level").unwrap(); |
425 | 436 |