1
1
Fork 0
mirror of https://github.com/azur1s/bobbylisp.git synced 2024-10-16 02:37:40 -05:00
bobbylisp/src/main.rs

33 lines
743 B
Rust
Raw Normal View History

2022-01-24 14:08:41 -06:00
use std::{fs::read_to_string, path::Path};
use structopt::StructOpt;
mod args;
use args::Args;
2022-01-21 17:43:50 -06:00
mod util;
2022-01-23 15:42:08 -06:00
use util::cover_paren;
2022-01-21 17:43:50 -06:00
mod parser;
2022-01-24 14:08:41 -06:00
use parser::{tokenize, Parser};
2022-01-21 17:43:50 -06:00
fn main() {
2022-01-24 14:08:41 -06:00
let args = Args::from_args();
2022-01-23 15:42:08 -06:00
2022-01-24 14:08:41 -06:00
let src = cover_paren(read_to_string(&args.file).unwrap());
let _file_name = Path::new(&args.file).file_stem().unwrap().to_str().unwrap();
2022-01-23 15:42:08 -06:00
2022-01-24 14:08:41 -06:00
let tokens = tokenize(&src);
let mut parser = Parser::new(tokens.clone());
2022-01-23 15:42:08 -06:00
let result = parser.parse();
2022-01-24 14:08:41 -06:00
match args.verbose {
0 => println!("We don't do anything yet."),
1 => println!("{:?}", result),
2 | _ => {
println!("Tokens: {:?}", tokens);
println!("Parsed: {:#?}", result);
}
}
2022-01-21 17:43:50 -06:00
}