feat: regex for pattern matching for signed and unsigned integers

This commit is contained in:
2026-08-24 00:12:10 +05:30
parent 3bc9e06673
commit 79a92f1d2d
2 changed files with 13 additions and 5 deletions
+12 -5
View File
@@ -15,8 +15,18 @@ struct SymbolRow {
scope: String,
is_const: bool,
}
fn build_sym_table(stream: &Vec::<&str>) -> Vec<SymbolRow> {
let sym_table: Vec<SymbolRow> = vec![];
static SYM_TABLE: Vec<SymbolRow> = Vec::new();
let rx_func = Regex::new(r"int[0-9]+|uint[0-9]+|string|char").unwrap();
for token in stream {
if rx_func.is_match(token){
print!("{token} ");
}
}
return sym_table;
}
fn main() -> std::io::Result<()>{
PlumeBuilder::new()
@@ -37,9 +47,6 @@ fn main() -> std::io::Result<()>{
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} ",);
}
build_sym_table(&tokens);
Ok(())
}