From 557269660c1d9796a7cf9e911efb9262f645e359 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 22 Nov 2016 12:10:03 +0200 Subject: Use diagnostics facility from libbutl --- build2/lexer | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'build2/lexer') diff --git a/build2/lexer b/build2/lexer index a539c2d..59150a9 100644 --- a/build2/lexer +++ b/build2/lexer @@ -79,7 +79,7 @@ namespace build2 : lexer (is, name, escapes, processor, true) {} const path& - name () const {return fail.name_;} + name () const {return name_;} // Note: sets mode for the next token. The second argument can be used to // specifythe pair separator character (if the mode supports pairs). @@ -157,17 +157,6 @@ namespace build2 // Diagnostics. // protected: - struct fail_mark_base: build2::fail_mark_base - { - fail_mark_base (const path& n): name_ (n) {} - - location_prologue - operator() (const xchar&) const; - - path name_; - }; - typedef diag_mark fail_mark; - fail_mark fail; // Lexer state. @@ -179,7 +168,8 @@ namespace build2 void (*p) (token&, const lexer&), bool sm) : char_scanner (is), - fail (n), + fail ("error", &name_), + name_ (n), escapes_ (e), processor_ (p), sep_ (false) @@ -188,6 +178,7 @@ namespace build2 mode (lexer_mode::normal, '@'); } + const path name_; const char* escapes_; void (*processor_) (token&, const lexer&); @@ -197,4 +188,18 @@ namespace build2 }; } +// Diagnostics plumbing. +// +namespace butl // ADL +{ + inline build2::location + get_location (const butl::char_scanner::xchar& c, const void* data) + { + using namespace build2; + + assert (data != nullptr); // E.g., must be &lexer::name_. + return location (static_cast (data), c.line, c.column); + } +} + #endif // BUILD2_LEXER -- cgit v1.1