added float and as

This commit is contained in:
2024-05-18 17:43:39 +02:00
parent a5e23db625
commit ae281d70d1
3 changed files with 35 additions and 25 deletions
+1 -9
View File
@@ -114,21 +114,13 @@ impl Parser {
ast_res.tokens.push(self.tokens[index+1].clone());
ast_res.ast_type = AstType::VariableDeceleration;
self.index += 1;
} else if self.tokens[index+2].token_type==TokenType::Identifier && self.tokens[index+1].token_type==TokenType::Angle {
} else if self.tokens.len()-index > 2 && self.tokens[index+2].token_type==TokenType::Identifier && self.tokens[index+1].token_type==TokenType::Angle {
ast_res.tokens.push(self.tokens[index+2].clone());
ast_res.tokens[0].value += "<";
ast_res.tokens[0].value += self.tokens[index+1].value.as_str();
ast_res.tokens[0].value += ">";
ast_res.ast_type = AstType::VariableDeceleration;
self.index += 2;
} else if self.tokens[index+1].value=="mut" && self.tokens[index+2].token_type==TokenType::Identifier {
ast_res.tokens.push(self.tokens[index+2].clone());
ast_res.ast_type = AstType::MutVariableDeceleration;
self.index += 2;
} else if self.tokens[index+1].value=="*" && self.tokens[index+2].token_type==TokenType::Identifier {
ast_res.tokens.push(self.tokens[index+2].clone());
ast_res.ast_type = AstType::PointerDeceleration;
self.index += 2;
}
}
}