Initial commit WIP

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2021-12-21 11:29:59 -08:00
commit 946a927b09
12 changed files with 960 additions and 0 deletions

34
src/main.rs Normal file
View File

@@ -0,0 +1,34 @@
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<PathBuf>,
}
type Result<T = (), E = Box<dyn std::error::Error>> = std::result::Result<T, E>;
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(())
}