comparison src/ast_convert.rs @ 74:97537c90d92d

Add ast.Yield.
author Bastien Orivel <eijebong@bananium.fr>
date Mon, 13 Jun 2016 18:25:02 +0200
parents 2a6629ea82b5
children 1abc8ca9f30b
comparison
equal deleted inserted replaced
73:2a6629ea82b5 74:97537c90d92d
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 let await_type = ast_module.get(py, "Await").unwrap();
305 let yield_type = ast_module.get(py, "Yield").unwrap();
305 306
306 assert!(is_instance(&ast, &ast_type)); 307 assert!(is_instance(&ast, &ast_type));
307 308
308 if is_instance(&ast, &attribute_type) { 309 if is_instance(&ast, &attribute_type) {
309 let value = ast.getattr(py, "value").unwrap(); 310 let value = ast.getattr(py, "value").unwrap();
406 } else if is_instance(&ast, &await_type) { 407 } else if is_instance(&ast, &await_type) {
407 let value = ast.getattr(py, "value").unwrap(); 408 let value = ast.getattr(py, "value").unwrap();
408 let value = parse_expr(py, value); 409 let value = parse_expr(py, value);
409 410
410 expr::Await(Box::new(value)) 411 expr::Await(Box::new(value))
412 } else if is_instance(&ast, &yield_type) {
413 let value = ast.getattr(py, "value").unwrap();
414 let value = parse_optional_expr(py, value);
415
416 expr::Yield(Box::new(value))
411 } else { 417 } else {
412 println!("expr {}", ast); 418 println!("expr {}", ast);
413 unreachable!() 419 unreachable!()
414 } 420 }
415 } 421 }