X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2FTokenizer.h;h=6dda20fad0b9744fe6578fdb203b5b50be2000b7;hb=32b5ea1b0f05283eb588b2b069d667f7c36e84da;hp=b7ca72f664c148c1f92029a27cc132fbdb7682ce;hpb=00dafa489224450ccc0321e238c176b9e8aa34bc;p=l2e.git diff --git a/src/loader/Tokenizer.h b/src/loader/Tokenizer.h index b7ca72f..6dda20f 100644 --- a/src/loader/Tokenizer.h +++ b/src/loader/Tokenizer.h @@ -18,7 +18,7 @@ namespace loader { class Tokenizer { public: - explicit Tokenizer(std::istream &in) : in(in), isPutback(false) { } + explicit Tokenizer(std::istream &in) : in(in), line(1), isPutback(false) { } ~Tokenizer() { } private: Tokenizer(const Tokenizer &); @@ -60,15 +60,21 @@ public: class LexerError: public std::runtime_error { public: - explicit LexerError(const std::string &msg) : std::runtime_error(msg) { } + LexerError(int line, const std::string &msg) + : std::runtime_error(msg), line(line) { } + int Line() const { return line; } + private: + int line; }; bool HasMore(); Token GetNext(); const Token &Peek(); void Putback(const Token &); + int Line() const { return line; } private: + void ScanSpace(); Token ReadToken(); Token ReadNumber(); @@ -80,6 +86,7 @@ private: private: std::istream ∈ Token putback; + int line; bool isPutback; };