bug fixes

This commit is contained in:
Leo
2024-04-10 18:46:48 +02:00
parent a689c04122
commit 84397b05d0
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -78,7 +78,7 @@ const SYNTAX: [Node; 13] = [
}, },
Node { Node {
token_type: TokenType::Operator, token_type: TokenType::Operator,
token_regex: Lazy::new(|| Regex::new(r"^[\-|\+|\*|\=]").unwrap()) token_regex: Lazy::new(|| Regex::new(r"^[\-|\+|\*|\=|\!]").unwrap())
}, },
Node { Node {
token_type: TokenType::Round, token_type: TokenType::Round,
+2 -1
View File
@@ -60,8 +60,9 @@ impl Parser {
let token = &self.tokens[index]; let token = &self.tokens[index];
match token.token_type { match token.token_type {
TokenType::Identifier => { TokenType::Identifier => {
if self.tokens.len()-index > 3 && self.tokens[index+1].token_type==TokenType::Identifier && self.tokens[index+2].token_type==TokenType::Round && self.tokens[index+3].token_type==TokenType::Curly {
ast_res.tokens.push(self.tokens[index].clone()); ast_res.tokens.push(self.tokens[index].clone());
self.index += 1;
if self.tokens.len()-index > 3 && self.tokens[index+1].token_type==TokenType::Identifier && self.tokens[index+2].token_type==TokenType::Round && self.tokens[index+3].token_type==TokenType::Curly {
ast_res.tokens.push(self.tokens[index+1].clone()); ast_res.tokens.push(self.tokens[index+1].clone());
ast_res.tokens.push(self.tokens[index+2].clone()); ast_res.tokens.push(self.tokens[index+2].clone());
ast_res.tokens.push(self.tokens[index+3].clone()); ast_res.tokens.push(self.tokens[index+3].clone());