diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-01-20 17:18:09 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-01-20 17:18:09 +0200 |
commit | b0524a0b18eec9d5e5c3f6ce30b6cecdd02a6306 (patch) | |
tree | 4b1efc586782507e0647e884d6a13c6605298508 /build/lexer | |
parent | 47751abc43dab40e0ac4a1523994fd533e6a3b22 (diff) |
Diagnostic infrastructure revamp
Diffstat (limited to 'build/lexer')
-rw-r--r-- | build/lexer | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/build/lexer b/build/lexer index cf67eec..1944727 100644 --- a/build/lexer +++ b/build/lexer @@ -11,18 +11,14 @@ #include <exception> #include <build/token> +#include <build/diagnostics> namespace build { - // The handler must assume the diagnostics has already been issued. - // - struct lexer_error: std::exception {}; - class lexer { public: - lexer (std::istream& is, const std::string& name, std::ostream& diag) - : is_ (is), name_ (name), diag_ (diag) {} + lexer (std::istream& is, const std::string& name): is_ (is), fail (name) {} token next (); @@ -83,16 +79,23 @@ namespace build token name (xchar); - // Utilities. + // Diagnostics. // private: - std::ostream& - error (const xchar&); + struct fail_mark_base: build::fail_mark_base<failed> + { + fail_mark_base (const std::string& n): name_ (n) {} + + location_prologue + operator() (const xchar&) const; + + std::string name_; + }; + typedef diag_mark<fail_mark_base> fail_mark; private: std::istream& is_; - std::string name_; - std::ostream& diag_; + fail_mark fail; std::uint64_t l_ {1}; std::uint64_t c_ {1}; |