Mercurial > python-compiler.rs
comparison src/ast_convert.rs @ 47:38f59b0efc2c
Handle Import and add a test for it.
author | Bastien Orivel <eijebong@bananium.fr> |
---|---|
date | Tue, 07 Jun 2016 12:51:36 +0200 |
parents | 5f1d285471af |
children | 039f85b187f2 |
comparison
equal
deleted
inserted
replaced
46:b3f47c8150c0 | 47:38f59b0efc2c |
---|---|
432 let global_type = ast_module.get(py, "Global").unwrap(); | 432 let global_type = ast_module.get(py, "Global").unwrap(); |
433 let assign_type = ast_module.get(py, "Assign").unwrap(); | 433 let assign_type = ast_module.get(py, "Assign").unwrap(); |
434 let aug_assign_type = ast_module.get(py, "AugAssign").unwrap(); | 434 let aug_assign_type = ast_module.get(py, "AugAssign").unwrap(); |
435 let return_type = ast_module.get(py, "Return").unwrap(); | 435 let return_type = ast_module.get(py, "Return").unwrap(); |
436 let import_from_type = ast_module.get(py, "ImportFrom").unwrap(); | 436 let import_from_type = ast_module.get(py, "ImportFrom").unwrap(); |
437 let import_type = ast_module.get(py, "Import").unwrap(); | |
437 let if_type = ast_module.get(py, "If").unwrap(); | 438 let if_type = ast_module.get(py, "If").unwrap(); |
438 let while_type = ast_module.get(py, "While").unwrap(); | 439 let while_type = ast_module.get(py, "While").unwrap(); |
439 let for_type = ast_module.get(py, "For").unwrap(); | 440 let for_type = ast_module.get(py, "For").unwrap(); |
440 let expr_type = ast_module.get(py, "Expr").unwrap(); | 441 let expr_type = ast_module.get(py, "Expr").unwrap(); |
441 let break_type = ast_module.get(py, "Break").unwrap(); | 442 let break_type = ast_module.get(py, "Break").unwrap(); |
543 | 544 |
544 let module = get_str(py, module); | 545 let module = get_str(py, module); |
545 let names = parse_list(py, names, parse_alias); | 546 let names = parse_list(py, names, parse_alias); |
546 | 547 |
547 stmt::ImportFrom(module, names, None) | 548 stmt::ImportFrom(module, names, None) |
549 } else if is_instance(&ast, &import_type) { | |
550 let names = ast.getattr(py, "names").unwrap(); | |
551 let names = parse_list(py, names, parse_alias); | |
552 | |
553 stmt::Import(names) | |
548 } else if is_instance(&ast, &return_type) { | 554 } else if is_instance(&ast, &return_type) { |
549 let value = ast.getattr(py, "value").unwrap(); | 555 let value = ast.getattr(py, "value").unwrap(); |
550 if value == py.None() { | 556 if value == py.None() { |
551 stmt::Return(None) | 557 stmt::Return(None) |
552 } else { | 558 } else { |