add: tokenizer for content

This commit is contained in:
2026-08-23 22:55:16 +05:30
parent 4b2ecb367d
commit 3bc9e06673
4 changed files with 90 additions and 6 deletions
+10 -6
View File
@@ -1,11 +1,13 @@
#![allow(unused_imports)]
#![allow(unused)]
#![allow(dead_code)]
use std::env;
use std::fs::File;
use std::fs;
use std::io::{BufRead, BufReader};
use log::{debug, error, info, trace, warn};
use plume_log::{PlumeBuilder, success};
use regex::Regex;
struct SymbolRow {
sym: String,
@@ -30,12 +32,14 @@ fn main() -> std::io::Result<()>{
std::process::exit(-1);
}
info!("File: {}", file_path);
let file = File::open(&args[1])?;
let reader = BufReader::new(file);
let content = fs::read_to_string(file_path)
.expect("Should've read the file");
for line in reader.lines() {
println!("+ {}", line?);
let re = Regex::new(r"[ \n\t]+").unwrap();
let tokens: Vec<&str> = re.split(&content).filter(|s| !s.is_empty()).collect();
for token in tokens {
print!("{token} ",);
}
Ok(())
}