aboutsummaryrefslogtreecommitdiff
path: root/build2/lexer
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-11-22 12:10:03 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-22 12:10:03 +0200
commit557269660c1d9796a7cf9e911efb9262f645e359 (patch)
tree0323bcb5a90c339fe87fcd193cf71bdcb3431c91 /build2/lexer
parentfae6cd2235c907e077dad7b5d8dc9b6d90a78a37 (diff)
Use diagnostics facility from libbutl
Diffstat (limited to 'build2/lexer')
-rw-r--r--build2/lexer31
1 files changed, 18 insertions, 13 deletions
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<failed>
- {
- fail_mark_base (const path& n): name_ (n) {}
-
- location_prologue
- operator() (const xchar&) const;
-
- path name_;
- };
- typedef diag_mark<fail_mark_base> 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<const path*> (data), c.line, c.column);
+ }
+}
+
#endif // BUILD2_LEXER