diff --git a/examples/print.sr b/examples/print.sr index b9e8210..2c7cb4b 100644 --- a/examples/print.sr +++ b/examples/print.sr @@ -1,4 +1,5 @@ main() { + uint32 y = 1; uint8 x = 0; if x > 0 { print("Hello World, x is zero"); diff --git a/src/main.rs b/src/main.rs index 2d379db..f0d022f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,8 +15,18 @@ struct SymbolRow { scope: String, is_const: bool, } +fn build_sym_table(stream: &Vec::<&str>) -> Vec { + let sym_table: Vec = vec![]; -static SYM_TABLE: Vec = 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(()) }