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/parser | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'build/parser') diff --git a/build/parser b/build/parser index 66c0357..7515908 100644 --- a/build/parser +++ b/build/parser @@ -9,10 +9,9 @@ #include #include #include // std::move -#include - #include +#include namespace build { @@ -22,15 +21,11 @@ namespace build enum class token_type; class lexer; - // The handler must assume the diagnostics has already been issued. - // - struct parser_error: std::exception {}; - class parser { public: - parser (std::ostream& diag): diag_ (diag) {} - + // Issues diagnostics and throws failed in case of an error. + // void parse (std::istream&, const path&, scope&); @@ -70,14 +65,22 @@ namespace build token_type next (token&, token_type&); - std::ostream& - error (const token&); + // Diagnostics. + // + private: + struct fail_mark_base: build::fail_mark_base + { + location_prologue + operator() (const token&) const; + + const path* path_; + }; + typedef diag_mark fail_mark; private: - std::ostream& diag_; + fail_mark fail; lexer* lexer_; - const path* path_; scope* scope_; }; } -- cgit v1.1