aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/token.hxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-05-18 12:06:16 +0300
committerBoris Kolpackov <boris@codesynthesis.com>2020-05-27 08:35:29 +0200
commitef5969da26c9c89533a7b480f365739aa37472ff (patch)
tree455beb2e612c895407ac7d3ee540785a7f640a52 /libbuild2/token.hxx
parente1c923e1c5cc07d21669cc2452b780a321df1bec (diff)
Add dump(ostream,script::lines) (partial implementation)
Diffstat (limited to 'libbuild2/token.hxx')
-rw-r--r--libbuild2/token.hxx27
1 files changed, 24 insertions, 3 deletions
diff --git a/libbuild2/token.hxx b/libbuild2/token.hxx
index 18096c1..156e428 100644
--- a/libbuild2/token.hxx
+++ b/libbuild2/token.hxx
@@ -88,13 +88,30 @@ namespace build2
class token;
+ enum class print_mode
+ {
+ // Print eos, newline, and pair separator in the <name> form and other
+ // tokens as literals, single-quoting the word token.
+ //
+ normal,
+
+ // Same as normal but all literals are quoted.
+ //
+ diagnostics,
+
+ // Print all tokens as literals with newline represented as '\n' and eos
+ // as an empty string.
+ //
+ raw
+ };
+
LIBBUILD2_SYMEXPORT void
- token_printer (ostream&, const token&, bool);
+ token_printer (ostream&, const token&, print_mode);
class token
{
public:
- using printer_type = void (ostream&, const token&, bool diag);
+ using printer_type = void (ostream&, const token&, print_mode);
token_type type;
bool separated; // Whitespace-separated from the previous token.
@@ -149,7 +166,11 @@ namespace build2
// 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;}
+ operator<< (ostream& o, const token& t)
+ {
+ t.printer (o, t, print_mode::diagnostics);
+ return o;
+ }
// Note: these are currently only used for sanity checks.
//