From b0524a0b18eec9d5e5c3f6ce30b6cecdd02a6306 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 20 Jan 2015 17:18:09 +0200 Subject: Diagnostic infrastructure revamp --- build/lexer | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'build/lexer') diff --git a/build/lexer b/build/lexer index cf67eec..1944727 100644 --- a/build/lexer +++ b/build/lexer @@ -11,18 +11,14 @@ #include #include +#include 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 + { + fail_mark_base (const std::string& n): name_ (n) {} + + location_prologue + operator() (const xchar&) const; + + std::string name_; + }; + typedef diag_mark 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}; -- cgit v1.1