pattern: Fixed many code inconsistencies and bugs

This commit is contained in:
WerWolv
2022-01-31 14:37:12 +01:00
parent 8f8f3c5415
commit 61fc479c79
22 changed files with 303 additions and 246 deletions

View File

@@ -2,28 +2,29 @@
#include <hex.hpp>
#include <optional>
#include <string>
#include <vector>
#include <hex/pattern_language/error.hpp>
namespace hex::pl {
class ASTNode;
class Validator {
public:
Validator();
Validator() = default;
bool validate(const std::vector<ASTNode *> &ast);
const std::pair<u32, std::string> &getError() { return this->m_error; }
const std::optional<PatternLanguageError> &getError() { return this->m_error; }
private:
std::pair<u32, std::string> m_error;
std::optional<PatternLanguageError> m_error;
using ValidatorError = std::pair<u32, std::string>;
[[noreturn]] void throwValidateError(std::string_view error, u32 lineNumber) const {
throw ValidatorError(lineNumber, error);
[[noreturn]] static void throwValidatorError(const std::string &error, u32 lineNumber) {
throw PatternLanguageError(lineNumber, "Validator: " + error);
}
};