Mercurial > python-compiler.rs
comparison src/ast_convert.rs @ 51:ded1907b7a69
Add ast.Nonlocal.
author | Bastien Orivel <eijebong@bananium.fr> |
---|---|
date | Wed, 08 Jun 2016 17:26:09 +0200 |
parents | 5edbc24b625f |
children | d9838e8b3ec5 |
comparison
equal
deleted
inserted
replaced
50:5edbc24b625f | 51:ded1907b7a69 |
---|---|
428 let ast_module = py.import("ast").unwrap(); | 428 let ast_module = py.import("ast").unwrap(); |
429 let ast_type = ast_module.get(py, "AST").unwrap(); | 429 let ast_type = ast_module.get(py, "AST").unwrap(); |
430 let class_def_type = ast_module.get(py, "ClassDef").unwrap(); | 430 let class_def_type = ast_module.get(py, "ClassDef").unwrap(); |
431 let function_def_type = ast_module.get(py, "FunctionDef").unwrap(); | 431 let function_def_type = ast_module.get(py, "FunctionDef").unwrap(); |
432 let global_type = ast_module.get(py, "Global").unwrap(); | 432 let global_type = ast_module.get(py, "Global").unwrap(); |
433 let nonlocal_type = ast_module.get(py, "Nonlocal").unwrap(); | |
433 let assign_type = ast_module.get(py, "Assign").unwrap(); | 434 let assign_type = ast_module.get(py, "Assign").unwrap(); |
434 let aug_assign_type = ast_module.get(py, "AugAssign").unwrap(); | 435 let aug_assign_type = ast_module.get(py, "AugAssign").unwrap(); |
435 let return_type = ast_module.get(py, "Return").unwrap(); | 436 let return_type = ast_module.get(py, "Return").unwrap(); |
436 let import_from_type = ast_module.get(py, "ImportFrom").unwrap(); | 437 let import_from_type = ast_module.get(py, "ImportFrom").unwrap(); |
437 let import_type = ast_module.get(py, "Import").unwrap(); | 438 let import_type = ast_module.get(py, "Import").unwrap(); |
487 stmt::FunctionDef(name, args, body, decorators, returns) | 488 stmt::FunctionDef(name, args, body, decorators, returns) |
488 } else if is_instance(&ast, &global_type) { | 489 } else if is_instance(&ast, &global_type) { |
489 let names = ast.getattr(py, "names").unwrap(); | 490 let names = ast.getattr(py, "names").unwrap(); |
490 let names = parse_list(py, names, get_str); | 491 let names = parse_list(py, names, get_str); |
491 stmt::Global(names) | 492 stmt::Global(names) |
493 } else if is_instance(&ast, &nonlocal_type) { | |
494 let names = ast.getattr(py, "names").unwrap(); | |
495 let names = parse_list(py, names, get_str); | |
496 stmt::Nonlocal(names) | |
492 } else if is_instance(&ast, &if_type) { | 497 } else if is_instance(&ast, &if_type) { |
493 let test = ast.getattr(py, "test").unwrap(); | 498 let test = ast.getattr(py, "test").unwrap(); |
494 let body = ast.getattr(py, "body").unwrap(); | 499 let body = ast.getattr(py, "body").unwrap(); |
495 let orelse = ast.getattr(py, "orelse").unwrap(); | 500 let orelse = ast.getattr(py, "orelse").unwrap(); |
496 | 501 |