Everywhere: Add Error class for generic error reporting

The Lexer can now also report errors.
This commit is contained in:
Riyyi
2023-03-19 15:06:27 +01:00
parent a8f990ed98
commit 9816bb3de2
9 changed files with 90 additions and 72 deletions
-19
View File
@@ -23,7 +23,6 @@ public:
template<typename T>
bool fastIs() const = delete;
virtual bool isError() const { return false; }
virtual bool isVector() const { return false; }
virtual bool isHashMap() const { return false; }
virtual bool isList() const { return false; }
@@ -35,21 +34,6 @@ public:
// -----------------------------------------
class Error final : public ASTNode {
public:
Error(const std::string& error);
virtual ~Error() = default;
virtual bool isError() const override { return true; }
const std::string& error() const { return m_error; }
private:
std::string m_error;
};
// -----------------------------------------
// []
class Vector final : public ASTNode {
public:
@@ -159,9 +143,6 @@ private:
// -----------------------------------------
// clang-format off
template<>
inline bool ASTNode::fastIs<Error>() const { return isError(); }
template<>
inline bool ASTNode::fastIs<Vector>() const { return isVector(); }