feat: Add parsing for expressions.

This commit adds support for parsing expression using the pratt parsing
approach.
This commit is contained in:
2026-03-12 12:14:00 +01:00
parent 9ac8a79151
commit 93f08d1944
5 changed files with 632 additions and 3 deletions

View File

@@ -2,11 +2,14 @@ use std::fs;
use crate::{
cli::{fatal, parse_args},
lexer::Lexer,
parser::Parser,
};
mod ast;
mod cli;
mod diagnostic;
mod lexer;
mod parser;
mod token;
fn main() {
@@ -25,8 +28,11 @@ fn main() {
};
println!("-- {} --", file.display());
for token in Lexer::new(&content) {
println!("{}", token);
let mut parser = Parser::new(&content);
match parser.parse_expression(0) {
Ok(ast) => println!("{ast:#?}"),
Err(diag) => diag.report(file, &content),
}
}
}