#include "Tokenizer.h"
#include <istream>
-#include <stdexcept>
namespace loader {
void Tokenizer::Putback(const Token &t) {
if (isPutback) {
- throw std::runtime_error("Tokenizer: double putback not supported");
+ throw LexerError("Tokenizer: double putback not supported");
} else {
putback = t;
isPutback = true;
} else if (std::islower(c)) {
CheckKeyword(t);
} else {
- throw std::runtime_error(std::string("Tokenizer: cannot parse token: ") + c);
+ throw LexerError(std::string("Tokenizer: cannot parse token: ") + c);
}
return t;
}
std::istream::char_type c;
in.get(c);
if (c != '"') {
- throw std::runtime_error("Tokenizer: strings must begin with '\"'");
+ throw LexerError("Tokenizer: strings must begin with '\"'");
}
while (in.get(c)) {
#include <iosfwd>
#include <ostream>
+#include <stdexcept>
#include <string>
namespace loader {
};
+ class LexerError: public std::runtime_error {
+ public:
+ explicit LexerError(const std::string &msg) : std::runtime_error(msg) { }
+ };
+
bool HasMore();
Token GetNext();
void Putback(const Token &);