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