ImHex/include/lang/preprocessor.hpp

31 lines
728 B
C++
Raw Normal View History

#pragma once
#include <hex.hpp>
#include "token.hpp"
2020-11-21 13:39:01 +00:00
#include <functional>
#include <set>
#include <string>
2020-11-21 13:39:01 +00:00
#include <unordered_map>
#include <utility>
namespace hex::lang {
class Preprocessor {
public:
Preprocessor();
2020-11-21 13:39:01 +00:00
std::pair<Result, std::string> preprocess(const std::string& code, bool initialRun = true);
void addPragmaHandler(std::string pragmaType, std::function<bool(std::string)> function);
void addDefaultPragramHandlers();
private:
2020-11-21 13:39:01 +00:00
std::unordered_map<std::string, std::function<bool(std::string)>> m_pragmaHandlers;
std::set<std::pair<std::string, std::string>> m_defines;
2020-11-21 13:39:01 +00:00
std::set<std::pair<std::string, std::string>> m_pragmas;
};
}