use std::fs; use crate::{ cli::{fatal, parse_args}, parser::Parser, }; mod ast; mod cli; mod diagnostic; mod lexer; mod parser; mod token; fn main() { let opts = parse_args(); for file in &opts.files { let content = match fs::read_to_string(file) { Ok(content) => content, Err(error) => { fatal(format!( "failed to read {}: {:?}", file.display(), error.kind() )); } }; println!("-- {} --", file.display()); let mut parser = Parser::new(&content); match parser.parse_expression(0) { Ok(ast) => println!("{ast:#?}"), Err(diag) => diag.report(file, &content), } } }