#pragma once #include #include "token.hpp" #include "ast_node.hpp" #include namespace hex::lang { class Parser { public: Parser(); using TokenIter = std::vector::const_iterator; std::pair> parse(const std::vector &tokens); const std::pair& getError() { return this->m_error; } private: std::pair m_error; ASTNode* parseBuiltinVariableDecl(TokenIter &curr); ASTNode* parseCustomTypeVariableDecl(TokenIter &curr); ASTNode* parseBuiltinPointerVariableDecl(TokenIter &curr); ASTNode* parseCustomTypePointerVariableDecl(TokenIter &curr); ASTNode* parseBuiltinArrayDecl(TokenIter &curr); ASTNode* parseCustomTypeArrayDecl(TokenIter &curr); ASTNode* parseBuiltinVariableArrayDecl(TokenIter &curr); ASTNode* parseCustomTypeVariableArrayDecl(TokenIter &curr); ASTNode* parsePaddingDecl(TokenIter &curr); ASTNode* parseFreeBuiltinVariableDecl(TokenIter &curr); ASTNode* parseFreeCustomTypeVariableDecl(TokenIter &curr); ASTNode* parseStruct(TokenIter &curr); ASTNode* parseUnion(TokenIter &curr); ASTNode* parseEnum(TokenIter &curr); ASTNode *parseBitField(TokenIter &curr); ASTNode *parseScope(TokenIter &curr); std::optional parseUsingDeclaration(TokenIter &curr); std::optional> parseStatement(TokenIter &curr); std::vector parseTillToken(TokenIter &curr, Token::Type endTokenType); bool tryConsume(TokenIter &curr, std::initializer_list tokenTypes); }; }