Mercurial > python-compiler.rs
comparison src/ast_convert.rs @ 52:d9838e8b3ec5
Add ast.Ellipsis.
author | Bastien Orivel <eijebong@bananium.fr> |
---|---|
date | Wed, 08 Jun 2016 19:01:46 +0200 |
parents | ded1907b7a69 |
children | 1a815946c2e5 |
comparison
equal
deleted
inserted
replaced
51:ded1907b7a69 | 52:d9838e8b3ec5 |
---|---|
249 let compare_type = ast_module.get(py, "Compare").unwrap(); | 249 let compare_type = ast_module.get(py, "Compare").unwrap(); |
250 let call_type = ast_module.get(py, "Call").unwrap(); | 250 let call_type = ast_module.get(py, "Call").unwrap(); |
251 let listcomp_type = ast_module.get(py, "ListComp").unwrap(); | 251 let listcomp_type = ast_module.get(py, "ListComp").unwrap(); |
252 let dictcomp_type = ast_module.get(py, "DictComp").unwrap(); | 252 let dictcomp_type = ast_module.get(py, "DictComp").unwrap(); |
253 let tuple_type = ast_module.get(py, "Tuple").unwrap(); | 253 let tuple_type = ast_module.get(py, "Tuple").unwrap(); |
254 let ellipsis_type = ast_module.get(py, "Ellipsis").unwrap(); | |
254 | 255 |
255 assert!(is_instance(&ast, &ast_type)); | 256 assert!(is_instance(&ast, &ast_type)); |
256 | 257 |
257 if is_instance(&ast, &arg_type) { | 258 if is_instance(&ast, &arg_type) { |
258 let arg = ast.getattr(py, "arg").unwrap(); | 259 let arg = ast.getattr(py, "arg").unwrap(); |
359 expr::DictComp(Box::new(key), Box::new(value), generators) | 360 expr::DictComp(Box::new(key), Box::new(value), generators) |
360 } else if is_instance(&ast, &tuple_type) { | 361 } else if is_instance(&ast, &tuple_type) { |
361 let elts = ast.getattr(py, "elts").unwrap(); | 362 let elts = ast.getattr(py, "elts").unwrap(); |
362 let elts = parse_list(py, elts, parse_expr); | 363 let elts = parse_list(py, elts, parse_expr); |
363 expr::Tuple(elts, get_ctx(py, ast)) | 364 expr::Tuple(elts, get_ctx(py, ast)) |
365 } else if is_instance(&ast, &ellipsis_type) { | |
366 expr::Ellipsis | |
364 } else { | 367 } else { |
365 println!("expr {}", ast); | 368 println!("expr {}", ast); |
366 unreachable!() | 369 unreachable!() |
367 } | 370 } |
368 } | 371 } |