forked from natto1784/tricc
does not support many expressions Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
35 lines
917 B
Rust
35 lines
917 B
Rust
use std::{
|
|
fs,
|
|
panic,
|
|
};
|
|
|
|
use tricc::args::Args;
|
|
use tricc::parser::Parser;
|
|
|
|
fn main() {
|
|
panic::set_hook(Box::new(|panic_info| {
|
|
if let Some(msg) = panic_info.payload().downcast_ref::<&str>() {
|
|
eprintln!("{}", msg);
|
|
} else if let Some(msg) = panic_info.payload().downcast_ref::<String>() {
|
|
eprintln!("{}", msg);
|
|
} else if let Some(location) = panic_info.location() {
|
|
eprintln!(
|
|
"panic occurred in file '{}' at line {}",
|
|
location.file(),
|
|
location.line(),
|
|
);
|
|
} else {
|
|
eprintln!("panic occurred");
|
|
}
|
|
}));
|
|
|
|
let mut args = Args::default();
|
|
args.handle();
|
|
|
|
let file = args.get_file();
|
|
let content = fs::read_to_string(file).expect("Couldn't read the file");
|
|
let mut parser = Parser::new(&content);
|
|
|
|
println!("{:?}", parser.parse());
|
|
}
|