add lexer
This commit is contained in:
parent
05ad6afe72
commit
ad7a8ad879
3 changed files with 120 additions and 2 deletions
25
src/main.rs
25
src/main.rs
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue