]> git.localhorst.tv Git - l2e.git/blobdiff - src/loader/Tokenizer.h
made parsing exceptions a little more informative
[l2e.git] / src / loader / Tokenizer.h
index b7ca72f664c148c1f92029a27cc132fbdb7682ce..6dda20fad0b9744fe6578fdb203b5b50be2000b7 100644 (file)
@@ -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;
 
 };