diff --git a/src/parser.rs b/src/parser.rs index b68fb92..c39b790 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -44,7 +44,7 @@ pub fn tokenize(code: String, root: &mut Transpiler) -> Vec { match c { ')' => { if stoken.0 == 1 { - stoken.1 -= 1; + stoken.1 += 1; if stoken.1 == 0 { stoken.0 = 0; tokens.push(get_token( @@ -61,7 +61,30 @@ pub fn tokenize(code: String, root: &mut Transpiler) -> Vec { } '(' => { if stoken.0 == 1 { + stoken.1 -= 1; + token_value += c.to_string().as_str(); + } + } + '{' => { + if stoken.0 == 2 { stoken.1 += 1; + if stoken.1 == 0 { + stoken.0 = 0; + tokens.push(get_token( + token_value.clone(), + token_type, + token_state.clone(), + )); + token_type = 0; + token_value = String::new(); + } else { + token_value += c.to_string().as_str(); + } + } + } + '}' => { + if stoken.0 == 2 { + stoken.1 -= 1; token_value += c.to_string().as_str(); } } @@ -131,8 +154,6 @@ pub fn tokenize(code: String, root: &mut Transpiler) -> Vec { pub fn parse(code: String, vars: &mut Variables, root: &mut Transpiler) -> Vec { let mut ast: Vec = Vec::new(); let mut tokens = tokenize(code, root); - println!("{:?}", tokens); - panic!("xd"); let mut pcon: Vec<(u32, u32)> = Vec::new(); while tokens.len() > 0 { let mut drain: usize = 1;