#pragma once #include #include #include #include #include #include #include namespace hex::pl { 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(const std::string &error, u32 lineNumber) const { throw PreprocessorError(lineNumber, "Preprocessor: " + error); } std::unordered_map> m_pragmaHandlers; std::set> m_defines; std::set> m_pragmas; std::pair m_error; }; }