Mercurial > python-compiler.rs
comparison src/ast_dump.rs @ 22:25b202005d1d
Return a String from ast_dump instead of printing it directly.
author | Bastien Orivel <eijebong@bananium.fr> |
---|---|
date | Fri, 03 Jun 2016 19:00:09 +0200 |
parents | 7af637f444d1 |
children | bc3437ecb12b |
comparison
equal
deleted
inserted
replaced
21:7af637f444d1 | 22:25b202005d1d |
---|---|
207 } | 207 } |
208 } | 208 } |
209 } | 209 } |
210 | 210 |
211 #[allow(dead_code)] | 211 #[allow(dead_code)] |
212 pub fn dump_ast(ast: &Module) { | 212 pub fn dump_ast(ast: &Module) -> String { |
213 let mut dumped_statements = vec!(); | |
213 for statement in &ast.statements { | 214 for statement in &ast.statements { |
214 println!("{}", statement.to_string(0)); | 215 let dumped_statement = statement.to_string(0); |
215 } | 216 dumped_statements.push(dumped_statement); |
216 } | 217 } |
218 dumped_statements.join("\n") | |
219 } | |
220 |