This commit is contained in:
Leo
2024-04-07 21:10:42 +02:00
parent 6faedc7c0d
commit 8a3009ac16
3 changed files with 7 additions and 3 deletions
+5 -1
View File
@@ -46,7 +46,7 @@ impl Parser {
let token = &self.tokens[index];
match token.token_type {
TokenType::Identifier => {
if self.tokens[index+1].token_type==TokenType::Identifier && self.tokens[index+2].token_type==TokenType::Round && self.tokens[index+3].token_type==TokenType::Curly {
if self.tokens.len()-index > 2 && 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+1].clone());
ast_res.tokens.push(self.tokens[index+2].clone());
@@ -65,6 +65,10 @@ impl Parser {
ast_res.tokens.push(ntk.clone());
ast_res.ast_type = AstType::VariableDecleration;
self.index += 1;
} else if ntk.token_type==TokenType::Keyword {
ast_res.tokens.push(ntk.clone());
ast_res.ast_type = AstType::VariableDecleration;
self.index += 1;
} else if ntk.token_type==TokenType::Angle {
ast_res.tokens.push(ntk.clone());
self.index += 1;