#pragma once #include #include "token.hpp" #include #include #include #include #include namespace hex::lang { class Preprocessor { public: Preprocessor(); std::optional preprocess(const std::string& code, bool initialRun = true); void addPragmaHandler(const std::string &pragmaType, const std::function &function); void addDefaultPragmaHandlers(); const std::pair& getError() { return this->m_error; } private: using PreprocessorError = std::pair; [[noreturn]] void throwPreprocessorError(std::string_view error, u32 lineNumber) const { throw PreprocessorError(lineNumber, "Preprocessor: " + std::string(error)); } std::unordered_map> m_pragmaHandlers; std::set> m_defines; std::set> m_pragmas; std::pair m_error; }; }