Impl's and pointers

This commit is contained in:
2024-05-25 11:14:58 +02:00
parent b3db964a8e
commit 4cbf46da53
3 changed files with 34 additions and 3 deletions
+17
View File
@@ -20,6 +20,7 @@ pub enum AstType {
IncludeLocal,
CodeBlock,
Json,
Impl,
Other,
}
@@ -110,6 +111,15 @@ impl Parser {
ast_res.tokens.push(self.tokens[index + 2].clone());
ast_res.ast_type = AstType::Namespace;
self.index += 2;
} else if self.tokens.len() - index > 2
&& self.tokens[index].value == "impl"
&& 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::Impl;
self.index += 2;
} else if self.tokens.len() - index > 2
&& self.tokens[index].token_type == TokenType::Keyword1
&& self.tokens[index + 1].token_type == TokenType::Round
@@ -175,6 +185,13 @@ impl Parser {
ast_res.tokens[0].value += ">";
ast_res.ast_type = AstType::VariableDeceleration;
self.index += 2;
} else if self.tokens.len() - index > 2
&& self.tokens[index + 1].value == "*"
&& self.tokens[index + 2].token_type == TokenType::Identifier {
ast_res.tokens.push(self.tokens[index].clone());
ast_res.tokens.push(self.tokens[index + 1].clone());
ast_res.ast_type = AstType::PointerDeceleration;
self.index += 2;
}
}
}