add lexer

This commit is contained in:
Raptorox 2026-05-20 21:04:14 +02:00
parent 05ad6afe72
commit ad7a8ad879
No known key found for this signature in database
GPG key ID: 8B3556FC3ED1F6D8
3 changed files with 120 additions and 2 deletions

View file

@ -1,3 +1,24 @@
fn main() {
println!("Hello, world!");
use std::{fs::File, io::Read};
mod lexer;
use lexer::Lexer;
fn main() -> std::io::Result<()> {
let args = std::env::args().collect::<Vec<String>>();
let mut source = String::new();
File::open(&args[1])?.read_to_string(&mut source)?;
println!("{:?}", source);
let mut lexer = Lexer::new(&source);
loop {
match lexer.next() {
Some(tok) => print!("{tok:?}, "),
None => break
}
}
Ok(())
}