aboutsummaryrefslogtreecommitdiff
path: root/build2/token
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-11-26 16:19:28 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-26 16:19:28 +0200
commit73c7f8615ebfaf76063207fbd071b2ff7b6b5a3f (patch)
treea4b9bfdd5e50dcbe1ec05aa135c171270414f1b7 /build2/token
parent757f42e7dea94f8b79b3d55074dedeafd853ddc5 (diff)
Spec testscript regex, add support in token/lexer
Diffstat (limited to 'build2/token')
-rw-r--r--build2/token20
1 files changed, 14 insertions, 6 deletions
diff --git a/build2/token b/build2/token
index df25d4c..0dc914f 100644
--- a/build2/token
+++ b/build2/token
@@ -81,7 +81,10 @@ namespace build2
quote_type qtype;
bool qcomp;
- string value; // Only valid for word.
+ // Normally only used for word, but can also be used to store "modifiers"
+ // or some such for other tokens.
+ //
+ string value;
uint64_t line;
uint64_t column;
@@ -93,18 +96,23 @@ namespace build2
: token (token_type::eos, false, 0, 0, token_printer) {}
token (token_type t, bool s, uint64_t l, uint64_t c, printer_type* p)
- : type (t), separated (s), qtype (quote_type::unquoted),
- line (l), column (c),
- printer (p) {}
+ : token (t, string (), s, quote_type::unquoted, false, l, c, p) {}
token (string v, bool s,
quote_type qt, bool qc,
uint64_t l, uint64_t c)
- : type (token_type::word), separated (s),
+ : token (token_type::word, move (v), s, qt, qc, l, c, &token_printer){}
+
+ token (token_type t,
+ string v, bool s,
+ quote_type qt, bool qc,
+ uint64_t l, uint64_t c,
+ printer_type* p)
+ : type (t), separated (s),
qtype (qt), qcomp (qc),
value (move (v)),
line (l), column (c),
- printer (&token_printer) {}
+ printer (p) {}
};
// Output the token value in a format suitable for diagnostics.