aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/script
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-05-20 14:51:58 +0300
committerBoris Kolpackov <boris@codesynthesis.com>2020-05-27 08:35:29 +0200
commit7c8e544b520cc46c174a952e63ccd2d71002516d (patch)
tree09212fddbe15dc3e092cfefad2e17c86e13bad9b /libbuild2/script
parent51ae6dcf64ce1de3f0f28228050c7db1776e5b1b (diff)
Partially implement dump(ostream,script::lines)
Diffstat (limited to 'libbuild2/script')
-rw-r--r--libbuild2/script/script.cxx29
1 files changed, 22 insertions, 7 deletions
diff --git a/libbuild2/script/script.cxx b/libbuild2/script/script.cxx
index 349b05e..04727a5 100644
--- a/libbuild2/script/script.cxx
+++ b/libbuild2/script/script.cxx
@@ -46,7 +46,7 @@ namespace build2
// information is lost and we won't be able to restore the token
// original representation.
//
-// char qseq ('\0'); // Can be used as bool.
+ char qseq ('\0'); // Can be used as bool.
for (const replay_token& rt: l.tokens)
{
@@ -57,18 +57,18 @@ namespace build2
char lq ('\0');
char rq ('\0');
- /*
if (t.qtype != quote_type::unquoted)
{
auto quote = [&t] ()
{
return t.qtype == quote_type::single ? '\'' : '"';
- }
+ };
if (t.qcomp) // Complete quoting.
{
// If we are inside quoted token sequence then we do noting.
- // Otherwise we just quote the token not starting a sequence.
+ // Otherwise we just quote the current token not starting a
+ // sequence.
//
if (!qseq)
{
@@ -78,12 +78,27 @@ namespace build2
}
else // Partial quoting.
{
+ // Note that we can not always reproduce the original tokens
+ // representation for partial quoting. For example, the
+ // following two tokens are lexed into the identical token
+ // objects:
+ //
+ // "foo
+ // f"oo"
+ //
if (!qseq)
- lq =
-
+ {
+ lq = quote ();
+ qseq = lq;
+ }
+ else
+ {
+ rq = quote ();
+ qseq = '\0';
+ }
}
}
- */
+
// @@ Add 2 spaces indentation for if block contents.
if (t.separated &&