Mercurial > python-compiler.rs
comparison src/ast_convert.rs @ 72:7ac23f4336b1
Add ast.AsyncWith.
author | Bastien Orivel <eijebong@bananium.fr> |
---|---|
date | Mon, 13 Jun 2016 18:09:15 +0200 |
parents | 2c1e2ce41263 |
children | 2a6629ea82b5 |
comparison
equal
deleted
inserted
replaced
71:2c1e2ce41263 | 72:7ac23f4336b1 |
---|---|
542 let delete_type = ast_module.get(py, "Delete").unwrap(); | 542 let delete_type = ast_module.get(py, "Delete").unwrap(); |
543 let pass_type = ast_module.get(py, "Pass").unwrap(); | 543 let pass_type = ast_module.get(py, "Pass").unwrap(); |
544 let continue_type = ast_module.get(py, "Continue").unwrap(); | 544 let continue_type = ast_module.get(py, "Continue").unwrap(); |
545 let assert_type = ast_module.get(py, "Assert").unwrap(); | 545 let assert_type = ast_module.get(py, "Assert").unwrap(); |
546 let with_type = ast_module.get(py, "With").unwrap(); | 546 let with_type = ast_module.get(py, "With").unwrap(); |
547 let async_with_type = ast_module.get(py, "AsyncWith").unwrap(); | |
547 let raise_type = ast_module.get(py, "Raise").unwrap(); | 548 let raise_type = ast_module.get(py, "Raise").unwrap(); |
548 let try_type = ast_module.get(py, "Try").unwrap(); | 549 let try_type = ast_module.get(py, "Try").unwrap(); |
549 | 550 |
550 assert!(is_instance(&ast, &ast_type)); | 551 assert!(is_instance(&ast, &ast_type)); |
551 | 552 |
693 | 694 |
694 let test = parse_expr(py, test); | 695 let test = parse_expr(py, test); |
695 let msg = parse_optional_expr(py, msg); | 696 let msg = parse_optional_expr(py, msg); |
696 | 697 |
697 stmt::Assert(test, msg) | 698 stmt::Assert(test, msg) |
698 } else if is_instance(&ast, &with_type) { | 699 } else if is_instance(&ast, &with_type) || is_instance(&ast, &async_with_type) { |
699 let items = ast.getattr(py, "items").unwrap(); | 700 let items = ast.getattr(py, "items").unwrap(); |
700 let body = ast.getattr(py, "body").unwrap(); | 701 let body = ast.getattr(py, "body").unwrap(); |
701 | 702 |
702 let items = parse_list(py, items, parse_withitem); | 703 let items = parse_list(py, items, parse_withitem); |
703 let body = parse_list(py, body, parse_statement); | 704 let body = parse_list(py, body, parse_statement); |
704 stmt::With(items, body) | 705 stmt::With(items, body, is_instance(&ast, &async_with_type)) |
705 } else if is_instance(&ast, &raise_type) { | 706 } else if is_instance(&ast, &raise_type) { |
706 let exc = ast.getattr(py, "exc").unwrap(); | 707 let exc = ast.getattr(py, "exc").unwrap(); |
707 let cause = ast.getattr(py, "cause").unwrap(); | 708 let cause = ast.getattr(py, "cause").unwrap(); |
708 | 709 |
709 let exc = parse_optional_expr(py, exc); | 710 let exc = parse_optional_expr(py, exc); |