Mercurial > python-compiler.rs
comparison src/ast_convert.rs @ 73:2a6629ea82b5
Add ast.Await.
author | Bastien Orivel <eijebong@bananium.fr> |
---|---|
date | Mon, 13 Jun 2016 18:21:06 +0200 |
parents | 7ac23f4336b1 |
children | 97537c90d92d |
comparison
equal
deleted
inserted
replaced
72:7ac23f4336b1 | 73:2a6629ea82b5 |
---|---|
299 let call_type = ast_module.get(py, "Call").unwrap(); | 299 let call_type = ast_module.get(py, "Call").unwrap(); |
300 let listcomp_type = ast_module.get(py, "ListComp").unwrap(); | 300 let listcomp_type = ast_module.get(py, "ListComp").unwrap(); |
301 let dictcomp_type = ast_module.get(py, "DictComp").unwrap(); | 301 let dictcomp_type = ast_module.get(py, "DictComp").unwrap(); |
302 let tuple_type = ast_module.get(py, "Tuple").unwrap(); | 302 let tuple_type = ast_module.get(py, "Tuple").unwrap(); |
303 let ellipsis_type = ast_module.get(py, "Ellipsis").unwrap(); | 303 let ellipsis_type = ast_module.get(py, "Ellipsis").unwrap(); |
304 let await_type = ast_module.get(py, "Await").unwrap(); | |
304 | 305 |
305 assert!(is_instance(&ast, &ast_type)); | 306 assert!(is_instance(&ast, &ast_type)); |
306 | 307 |
307 if is_instance(&ast, &attribute_type) { | 308 if is_instance(&ast, &attribute_type) { |
308 let value = ast.getattr(py, "value").unwrap(); | 309 let value = ast.getattr(py, "value").unwrap(); |
400 let elts = ast.getattr(py, "elts").unwrap(); | 401 let elts = ast.getattr(py, "elts").unwrap(); |
401 let elts = parse_list(py, elts, parse_expr); | 402 let elts = parse_list(py, elts, parse_expr); |
402 expr::Tuple(elts, get_ctx(py, ast)) | 403 expr::Tuple(elts, get_ctx(py, ast)) |
403 } else if is_instance(&ast, &ellipsis_type) { | 404 } else if is_instance(&ast, &ellipsis_type) { |
404 expr::Ellipsis | 405 expr::Ellipsis |
406 } else if is_instance(&ast, &await_type) { | |
407 let value = ast.getattr(py, "value").unwrap(); | |
408 let value = parse_expr(py, value); | |
409 | |
410 expr::Await(Box::new(value)) | |
405 } else { | 411 } else { |
406 println!("expr {}", ast); | 412 println!("expr {}", ast); |
407 unreachable!() | 413 unreachable!() |
408 } | 414 } |
409 } | 415 } |