upd: add except

This commit is contained in:
2023-11-06 22:04:47 +08:00
parent 6a7a957299
commit 86ea1176bf
2 changed files with 51 additions and 1 deletions

View File

@ -4,6 +4,8 @@
#include "Python3ParserBaseVisitor.h"
#include "int2048/int2048.h"
#include <exception>
#include <stdexcept>
class EvalVisitor : public Python3ParserBaseVisitor
{
@ -44,5 +46,34 @@ class EvalVisitor : public Python3ParserBaseVisitor
std::any visitArglist(Python3Parser::ArglistContext *ctx) override;
std::any visitArgument(Python3Parser::ArgumentContext *ctx) override;
};
class InterpretException : public std::exception
{
public:
InterpretException() {}
InterpretException(const char *message) : m_message(message) {}
const char *what() const noexcept override
{
return m_message;
}
~InterpretException() noexcept override {}
private:
const char *m_message;
};
class FatalError : public std::exception
{
public:
FatalError(const char *message) : m_message(message) {}
const char *what() const noexcept override
{
return m_message;
}
private:
const char *m_message;
};
#endif // PYTHON_INTERPRETER_EVALVISITOR_H