mod object; mod syn; use std::io::Read; use std::path::PathBuf; use structopt::StructOpt; use syn::lexer::Lexer; #[derive(Debug, StructOpt)] struct Opt { #[structopt(name = "PATH", parse(from_os_str))] path: Option, } type Result> = std::result::Result; fn main() -> Result { let opt = Opt::from_args(); let text = if let Some(path) = opt.path.as_ref() { std::fs::read_to_string(path)? } else { let mut input = String::new(); std::io::stdin().read_to_string(&mut input)?; input }; let mut lexer = Lexer::new(&text); while let Some(token) = lexer.next()? { println!("{:?}", token); } Ok(()) }