initial rust scanner
This commit is contained in:
parent
818816d16d
commit
3cf8ef02d1
16 changed files with 610 additions and 4 deletions
|
@ -1,6 +1,45 @@
|
|||
use std::path::Path;
|
||||
use std::{
|
||||
fs::{self},
|
||||
io::{self, Write},
|
||||
path::Path,
|
||||
};
|
||||
|
||||
use tracing::error;
|
||||
|
||||
pub mod cli;
|
||||
pub mod keywords;
|
||||
pub mod scanner;
|
||||
pub mod token;
|
||||
pub mod tokenizer {
|
||||
pub mod comment;
|
||||
pub mod identifier;
|
||||
pub mod interface;
|
||||
pub mod lookahead;
|
||||
pub mod newline;
|
||||
pub mod number;
|
||||
pub mod single_char;
|
||||
pub mod string;
|
||||
pub mod whitespace;
|
||||
}
|
||||
|
||||
pub fn compile(source: &Path) {}
|
||||
pub fn repl() {}
|
||||
pub fn compile(source: &Path) -> Result<(), io::Error> {
|
||||
let input = fs::read_to_string(source)?;
|
||||
let _tokens = scanner::tokenize(&input);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn repl() {
|
||||
loop {
|
||||
print!("> ");
|
||||
let _ = io::stdout().flush();
|
||||
|
||||
let mut input = String::new();
|
||||
match io::stdin().read_line(&mut input) {
|
||||
Ok(_) => {}
|
||||
Err(e) => error!("{}", e),
|
||||
}
|
||||
let input = input.trim().to_string();
|
||||
let _tokens = scanner::tokenize(&input);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue