Mercurial > python-compiler.rs
comparison src/ast_convert.rs @ 83:e59cd5754268
Add ast.Starred.
author | Bastien Orivel <eijebong@bananium.fr> |
---|---|
date | Mon, 13 Jun 2016 21:41:14 +0200 |
parents | 2d906d1cb940 |
children | a7b1db623f41 |
comparison
equal
deleted
inserted
replaced
82:2d906d1cb940 | 83:e59cd5754268 |
---|---|
349 let generatorexp_type = ast_module.get(py, "GeneratorExp").unwrap(); | 349 let generatorexp_type = ast_module.get(py, "GeneratorExp").unwrap(); |
350 let lambda_type = ast_module.get(py, "Lambda").unwrap(); | 350 let lambda_type = ast_module.get(py, "Lambda").unwrap(); |
351 let ifexp_type = ast_module.get(py, "IfExp").unwrap(); | 351 let ifexp_type = ast_module.get(py, "IfExp").unwrap(); |
352 let dict_type = ast_module.get(py, "Dict").unwrap(); | 352 let dict_type = ast_module.get(py, "Dict").unwrap(); |
353 let subscript_type = ast_module.get(py, "Subscript").unwrap(); | 353 let subscript_type = ast_module.get(py, "Subscript").unwrap(); |
354 let starred_type = ast_module.get(py, "Starred").unwrap(); | |
354 | 355 |
355 assert!(is_instance(&ast, &ast_type)); | 356 assert!(is_instance(&ast, &ast_type)); |
356 | 357 |
357 if is_instance(&ast, &attribute_type) { | 358 if is_instance(&ast, &attribute_type) { |
358 let value = ast.getattr(py, "value").unwrap(); | 359 let value = ast.getattr(py, "value").unwrap(); |
521 | 522 |
522 let value = parse_expr(py, value); | 523 let value = parse_expr(py, value); |
523 let slice = parse_slice(py, slice); | 524 let slice = parse_slice(py, slice); |
524 | 525 |
525 expr::Subscript(Box::new(value), Box::new(slice), ctx) | 526 expr::Subscript(Box::new(value), Box::new(slice), ctx) |
527 } else if is_instance(&ast, &starred_type) { | |
528 let value = ast.getattr(py, "value").unwrap(); | |
529 let ctx = get_ctx(py, ast); | |
530 | |
531 let value = parse_expr(py, value); | |
532 | |
533 expr::Starred(Box::new(value), ctx) | |
526 } else { | 534 } else { |
527 println!("expr {}", ast); | 535 println!("expr {}", ast); |
528 unreachable!() | 536 unreachable!() |
529 } | 537 } |
530 } | 538 } |