From 05ad469ac33965f76ccc0f5b8a9959695b8979a0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 22 Jan 2018 02:12:26 +0300 Subject: Command-line utilty to print the parse tree --- src/bin/parse-rust.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/bin/parse-rust.rs (limited to 'src/bin') 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 @@ +extern crate libsyntax2; + +use std::io::Read; + +use libsyntax2::{tokenize, parse}; +use libsyntax2::utils::dump_tree; + +fn main() { + let text = read_input(); + let tokens = tokenize(&text); + let file = parse(text, &tokens); + let tree = dump_tree(&file); + println!("{}", tree); +} + +fn read_input() -> String { + let mut buff = String::new(); + ::std::io::stdin().read_to_string(&mut buff).unwrap(); + buff +} -- cgit v1.2.3