#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, bool hasEndianDef); ASTNode* parseCustomTypeVariableDecl(TokenIter &curr, bool hasEndianDef); ASTNode* parseBuiltinPointerVariableDecl(TokenIter &curr, bool hasEndianDef); ASTNode* parseCustomTypePointerVariableDecl(TokenIter &curr, bool hasEndianDef); ASTNode* parseBuiltinArrayDecl(TokenIter &curr, bool hasEndianDef); ASTNode* parseCustomTypeArrayDecl(TokenIter &curr, bool hasEndianDef); ASTNode* parseBuiltinVariableArrayDecl(TokenIter &curr, bool hasEndianDef); ASTNode* parseCustomTypeVariableArrayDecl(TokenIter &curr, bool hasEndianDef); ASTNode* parsePaddingDecl(TokenIter &curr); ASTNode* parseFreeBuiltinVariableDecl(TokenIter &curr, bool hasEndianDef); ASTNode* parseFreeCustomTypeVariableDecl(TokenIter &curr, bool hasEndianDef); 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); }; }