feat: Add token definitions and lexer logic.

This commit adds the `Token` and `TokenKind` definitions in `src/token.rs`,
in `src/lexer.rs` I've added the `Lexer` logic.
This commit is contained in:
2026-03-11 23:18:05 +01:00
parent 9e4d4085ba
commit 51bd07d313
8 changed files with 426 additions and 6 deletions

View File

@@ -1,9 +1,32 @@
use crate::cli::parse_args;
use std::fs;
use crate::{
cli::{fatal, parse_args},
lexer::Lexer,
};
mod cli;
mod lexer;
mod token;
fn main() {
let opts = parse_args();
println!("{opts:#?}");
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());
for token in Lexer::new(&content) {
println!("{}", token);
}
}
}