struct var defs

This commit is contained in:
2024-05-16 18:07:48 +02:00
parent 9dc8712364
commit a5e23db625
2 changed files with 38 additions and 5 deletions
+11
View File
@@ -7,6 +7,8 @@ use once_cell::sync::Lazy;
pub enum AstType {
FunctionDeceleration,
StructDeceleration,
StructCall,
StructVar,
VoidFunctionDeceleration,
VariableDeceleration,
PointerDeceleration,
@@ -98,6 +100,15 @@ impl Parser {
ast_res.ast_type = AstType::FunctionDeceleration;
}
self.index += 3;
} else if self.tokens.len()-index > 1 && self.tokens[index+1].token_type==TokenType::Curly {
ast_res.tokens.push(self.tokens[index+1].clone());
ast_res.ast_type = AstType::StructCall;
self.index += 1;
} else if self.tokens.len()-index > 2 && self.tokens[index+1].token_type==TokenType::Identifier && self.tokens[index+2].token_type==TokenType::Curly {
ast_res.tokens.push(self.tokens[index+1].clone());
ast_res.tokens.push(self.tokens[index+2].clone());
ast_res.ast_type = AstType::StructVar;
self.index += 2;
} else if self.tokens.len()-index > 1 {
if self.tokens[index+1].token_type==TokenType::Identifier {
ast_res.tokens.push(self.tokens[index+1].clone());