aboutsummaryrefslogtreecommitdiff
path: root/build/name.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-03-06 09:15:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-03-06 09:15:40 +0200
commit897a0e4fdf9ca90ee8d236a38e138a8ae6bc3627 (patch)
treed4c00de32d028823906d342fcd984faee8d977ff /build/name.cxx
parent9ef25ab2f9da89ab48ecce3fe1b8cbb0bc5f1e09 (diff)
Add support for lexing and parsing name pairs
We will need it for the buildspec and also if/when we support map variable types.
Diffstat (limited to 'build/name.cxx')
-rw-r--r--build/name.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/build/name.cxx b/build/name.cxx
index 6280676..46e2440 100644
--- a/build/name.cxx
+++ b/build/name.cxx
@@ -17,6 +17,7 @@ namespace build
{
bool ht (!n.type.empty ());
bool hv (!n.value.empty ());
+ bool hd (false);
if (ht)
os << n.type << '{';
@@ -37,6 +38,8 @@ namespace build
//
if (s.back () != path::traits::directory_separator && (hv || !ht))
os << path::traits::directory_separator;
+
+ hd = true;
}
}
@@ -45,14 +48,21 @@ namespace build
if (ht)
os << '}';
+ if (!ht && !hv && !hd)
+ os << "{}"; // Nothing got printed.
+
return os;
}
ostream&
operator<< (ostream& os, const names& ns)
{
- for (auto b (ns.begin ()), i (b), e (ns.end ()); i != e; ++i)
- os << (i != b ? " " : "") << *i;
+ for (auto i (ns.begin ()), e (ns.end ()); i != e; )
+ {
+ const name& n (*i);
+ ++i;
+ os << n << (n.pair ? "=" : (i != e ? " " : ""));
+ }
return os;
}