From 93f38c7b1e4bf3c7bf14af6785146c81614cbac5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 19 Oct 2016 11:54:25 +0200 Subject: Various minor buildfile lexer/parser changes --- build2/token | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'build2/token') diff --git a/build2/token b/build2/token index 517bf47..19e82dc 100644 --- a/build2/token +++ b/build2/token @@ -92,13 +92,33 @@ namespace build2 printer (&token_printer) {} }; - using tokens = vector; - // Output the token value in a format suitable for diagnostics. // inline ostream& operator<< (ostream& o, const token& t) {t.printer (o, t, true); return o;} + // Extendable/inheritable enum-like class. + // + struct lexer_mode_base + { + enum { value_next }; + + using value_type = uint16_t; + + lexer_mode_base (value_type v = value_next): v_ (v) {} + operator value_type () const {return v_;} + value_type v_; + }; + + struct replay_token + { + build2::token token; + lexer_mode_base mode; + char pair_separator; + }; + + using replay_tokens = vector; + // Diagnostics plumbing. We assume that any diag stream for which we can use // token as location has its aux data pointing to pointer to path. // -- cgit v1.1