feat: regex for pattern matching for signed and unsigned integers
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
main() {
|
||||
uint32 y = 1;
|
||||
uint8 x = 0;
|
||||
if x > 0 {
|
||||
print("Hello World, x is zero");
|
||||
|
||||
+12
-5
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user