aboutsummaryrefslogtreecommitdiff
path: root/src/bin/parse-rust.rs
blob: 3c13e732ed881fdd733e88eab9a98409d1f058cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
}