blaze lisp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
999 B

/*
* Copyright (C) 2023 Riyyi
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include <vector>
#include "ruc/singleton.h"
#include "lexer.h"
namespace blaze {
class Error final : public ruc::Singleton<Error> {
public:
Error(s) {}
virtual ~Error() = default;
void clearErrors()
{
m_token_errors.clear();
m_other_errors.clear();
}
void add(Token error) { m_token_errors.push_back(error); }
void add(const std::string& error) { m_other_errors.push_back(error); }
bool hasTokenError() { return m_token_errors.size() > 0; }
bool hasOtherError() { return m_other_errors.size() > 0; }
bool hasAnyError() { return hasTokenError() || hasOtherError(); }
void setInput(std::string_view input) { m_input = input; }
Token tokenError() const { return m_token_errors[0]; }
const std::string& otherError() const { return m_other_errors[0]; }
private:
std::string_view m_input;
std::vector<Token> m_token_errors;
std::vector<std::string> m_other_errors;
};
} // namespace blaze