Mercurial > python-compiler.rs
comparison src/ast_convert.rs @ 76:efd42fc280e8
Add ast.Set.
author | Bastien Orivel <eijebong@bananium.fr> |
---|---|
date | Mon, 13 Jun 2016 19:19:49 +0200 |
parents | 1abc8ca9f30b |
children | 7d1406181aae |
comparison
equal
deleted
inserted
replaced
75:1abc8ca9f30b | 76:efd42fc280e8 |
---|---|
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 let await_type = ast_module.get(py, "Await").unwrap(); |
305 let yield_type = ast_module.get(py, "Yield").unwrap(); | 305 let yield_type = ast_module.get(py, "Yield").unwrap(); |
306 let yield_from_type = ast_module.get(py, "YieldFrom").unwrap(); | 306 let yield_from_type = ast_module.get(py, "YieldFrom").unwrap(); |
307 let set_type = ast_module.get(py, "Set").unwrap(); | |
307 | 308 |
308 assert!(is_instance(&ast, &ast_type)); | 309 assert!(is_instance(&ast, &ast_type)); |
309 | 310 |
310 if is_instance(&ast, &attribute_type) { | 311 if is_instance(&ast, &attribute_type) { |
311 let value = ast.getattr(py, "value").unwrap(); | 312 let value = ast.getattr(py, "value").unwrap(); |
418 } else if is_instance(&ast, &yield_from_type) { | 419 } else if is_instance(&ast, &yield_from_type) { |
419 let value = ast.getattr(py, "value").unwrap(); | 420 let value = ast.getattr(py, "value").unwrap(); |
420 let value = parse_expr(py, value); | 421 let value = parse_expr(py, value); |
421 | 422 |
422 expr::YieldFrom(Box::new(value)) | 423 expr::YieldFrom(Box::new(value)) |
424 } else if is_instance(&ast, &set_type) { | |
425 let elts = ast.getattr(py, "elts").unwrap(); | |
426 let elements = parse_list(py, elts, parse_expr); | |
427 | |
428 expr::Set(elements) | |
423 } else { | 429 } else { |
424 println!("expr {}", ast); | 430 println!("expr {}", ast); |
425 unreachable!() | 431 unreachable!() |
426 } | 432 } |
427 } | 433 } |