Mercurial > python-compiler.rs
diff src/main.rs @ 90:4e62a8927dcc
Add a symtable module, to obtain information about symbols.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 23 Jun 2016 03:16:59 +0100 |
parents | 5923cd4bfc36 |
children | c06d12a81637 |
line wrap: on
line diff
--- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ mod tests; mod python_tb; mod python_parse; mod python_ast; +mod python_symtable; mod ast_convert; mod ast_dump; //mod ast_scope; @@ -39,7 +40,7 @@ fn main() { code }; - let module = match python_parse::parse_ast(code) { + let module = match python_parse::parse_ast(code.clone()) { Ok(module) => module, Err(err) => { // TODO: use stderr instead. @@ -49,6 +50,17 @@ fn main() { } }; + let symtable = match python_symtable::generate_symtable(code, &filename) { + Ok(symtable) => symtable, + Err(err) => { + // TODO: use stderr instead. + println!("Error while parsing file “{}”:", filename); + python_tb::traceback(err); + std::process::exit(4); + } + }; + println!("{:#?}", symtable); + let module_ast = ast_convert::convert_ast("__main__".to_string(), &module); println!("{}", ast_dump::dump_ast(&module_ast)); //let scoped_ast = ast_scope::scope_ast(vec!(module_ast));