comparison src/ast_convert.rs @ 75:1abc8ca9f30b

Add ast.YieldFrom.
author Bastien Orivel <eijebong@bananium.fr>
date Mon, 13 Jun 2016 18:26:46 +0200
parents 97537c90d92d
children efd42fc280e8
comparison
equal deleted inserted replaced
74:97537c90d92d 75:1abc8ca9f30b
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 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 307
307 assert!(is_instance(&ast, &ast_type)); 308 assert!(is_instance(&ast, &ast_type));
308 309
309 if is_instance(&ast, &attribute_type) { 310 if is_instance(&ast, &attribute_type) {
310 let value = ast.getattr(py, "value").unwrap(); 311 let value = ast.getattr(py, "value").unwrap();
412 } else if is_instance(&ast, &yield_type) { 413 } else if is_instance(&ast, &yield_type) {
413 let value = ast.getattr(py, "value").unwrap(); 414 let value = ast.getattr(py, "value").unwrap();
414 let value = parse_optional_expr(py, value); 415 let value = parse_optional_expr(py, value);
415 416
416 expr::Yield(Box::new(value)) 417 expr::Yield(Box::new(value))
418 } else if is_instance(&ast, &yield_from_type) {
419 let value = ast.getattr(py, "value").unwrap();
420 let value = parse_expr(py, value);
421
422 expr::YieldFrom(Box::new(value))
417 } else { 423 } else {
418 println!("expr {}", ast); 424 println!("expr {}", ast);
419 unreachable!() 425 unreachable!()
420 } 426 }
421 } 427 }