diff options
author | Aleksey Kladov <[email protected]> | 2018-01-21 23:12:26 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-01-21 23:12:26 +0000 |
commit | 05ad469ac33965f76ccc0f5b8a9959695b8979a0 (patch) | |
tree | 1212adb51b8970a458c322cf687f625c5ef612e7 /src/bin | |
parent | c8cf1d8cdac48f48caf9505bd5dc20dd2b962317 (diff) |
Command-line utilty to print the parse tree
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/parse-rust.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/bin/parse-rust.rs b/src/bin/parse-rust.rs new file mode 100644 index 000000000..3c13e732e --- /dev/null +++ b/src/bin/parse-rust.rs | |||
@@ -0,0 +1,20 @@ | |||
1 | extern crate libsyntax2; | ||
2 | |||
3 | use std::io::Read; | ||
4 | |||
5 | use libsyntax2::{tokenize, parse}; | ||
6 | use libsyntax2::utils::dump_tree; | ||
7 | |||
8 | fn main() { | ||
9 | let text = read_input(); | ||
10 | let tokens = tokenize(&text); | ||
11 | let file = parse(text, &tokens); | ||
12 | let tree = dump_tree(&file); | ||
13 | println!("{}", tree); | ||
14 | } | ||
15 | |||
16 | fn read_input() -> String { | ||
17 | let mut buff = String::new(); | ||
18 | ::std::io::stdin().read_to_string(&mut buff).unwrap(); | ||
19 | buff | ||
20 | } | ||