-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmain.rs
26 lines (23 loc) · 777 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
extern crate python_parser;
use std::env::args_os;
use std::fs::File;
use std::io::Read;
use python_parser::visitors::printer::format_module;
use python_parser::{file_input, make_strspan};
fn main() {
let mut iter = args_os();
iter.next();
for filename in iter {
let mut file = File::open(filename).expect("Could not open file");
let mut content = String::new();
file.read_to_string(&mut content)
.expect("Could not read file");
let (rest, ast) = file_input(make_strspan(&content)).unwrap();
//println!("{:?}", ast);
let output = format_module(&ast);
if rest.fragment.0.len() > 0 {
println!("\nUnparsed: {:?}\n\n", rest.fragment.0)
}
println!("{}", output);
}
}