feat(tokenizer): add exceptions

This commit is contained in:
3lswear
2022-02-12 18:54:45 +03:00
parent 7df10265e0
commit 3a5879eb4d
3 changed files with 47 additions and 8 deletions

View File

@@ -59,6 +59,37 @@ namespace config
void rollBackToken();
void set_last(e_token type);
class NoMoreTokens: public std::exception
{
public:
virtual const char *what() const throw()
{
return ("No more tokens!");
}
};
class InvalidToken: public std::exception
{
protected:
std::string *msg;
public:
InvalidToken(const std::string &token)
{
msg = new std::string("Invalid token: '" + token + "'");
}
virtual const char *what() const throw()
{
return (msg->c_str());
}
virtual ~InvalidToken() throw()
{
delete msg;
}
};
};
/* struct s_token Tokenizer::getKey(void) */