Files
bucky/src/main.rs
Jooris Hadeler 93f08d1944 feat: Add parsing for expressions.
This commit adds support for parsing expression using the pratt parsing
approach.
2026-03-12 12:14:00 +01:00

39 lines
789 B
Rust

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),
}
}
}