aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/file.cxx3
-rw-r--r--build2/name3
-rw-r--r--build2/name.cxx2
-rw-r--r--build2/name.ixx2
-rw-r--r--build2/parser.cxx14
-rw-r--r--build2/variable.txx21
6 files changed, 38 insertions, 7 deletions
diff --git a/build2/file.cxx b/build2/file.cxx
index b735cab..e494f5a 100644
--- a/build2/file.cxx
+++ b/build2/file.cxx
@@ -594,6 +594,9 @@ namespace build2
string n;
if (i->pair)
{
+ if (i->pair != '@')
+ fail << "unexpected pair style in variable subprojects";
+
try
{
n = convert<string> (move (*i));
diff --git a/build2/name b/build2/name
index d0a115f..68fe9c7 100644
--- a/build2/name
+++ b/build2/name
@@ -33,7 +33,8 @@ namespace build2
dir_path dir;
string type;
string value;
- bool pair = false; // True if first half of a pair.
+ char pair = '\0'; // Pair character if first half of a pair. Can be used
+ // as bool.
name () = default;
diff --git a/build2/name.cxx b/build2/name.cxx
index 296b4ec..f3e4c0f 100644
--- a/build2/name.cxx
+++ b/build2/name.cxx
@@ -49,7 +49,7 @@ namespace build2
os << n;
if (n.pair)
- os << '@';
+ os << n.pair;
else if (i != e)
os << ' ';
}
diff --git a/build2/name.ixx b/build2/name.ixx
index 21bd125..73dbb4a 100644
--- a/build2/name.ixx
+++ b/build2/name.ixx
@@ -37,6 +37,6 @@ namespace build2
dir.clear ();
type.clear ();
value.clear ();
- pair = false;
+ pair = '\0';
}
}
diff --git a/build2/parser.cxx b/build2/parser.cxx
index ce5b968..f7b17b2 100644
--- a/build2/parser.cxx
+++ b/build2/parser.cxx
@@ -991,6 +991,9 @@ namespace build2
if (i->pair)
{
+ if (i->pair != '@')
+ fail << "unexpected pair style in using directive";
+
++i;
if (!i->simple ())
fail (l) << "module version expected instead of " << *i;
@@ -1547,6 +1550,9 @@ namespace build2
if (i->pair)
{
+ if (i->pair != '=')
+ fail << "unexpected pair style in attributes";
+
try
{
v = convert<string> (move (*++i));
@@ -2178,7 +2184,8 @@ namespace build2
if (pair != 0)
fail (t) << "nested pair on the right hand side of a pair";
- // Catch '@@'. Maybe we can use for something later (e.g., escaping).
+ // Catch double pair separator ('@@'). Maybe we can use for something
+ // later (e.g., escaping).
//
if (!ns.empty () && ns.back ().pair)
fail (t) << "double pair separator";
@@ -2197,7 +2204,7 @@ namespace build2
else if (count > 1)
fail (t) << "multiple names on the left hand side of a pair";
- ns.back ().pair = true;
+ ns.back ().pair = lexer_->pair_separator ();
tt = peek ();
// If the next token is separated, then we have an empty RHS. Note
@@ -2527,6 +2534,9 @@ namespace build2
dir_path src_base;
if (i->pair)
{
+ if (i->pair != '@')
+ fail << "unexpected pair style in buildspec";
+
if (i->typed ())
fail (l) << "expected target src_base instead of " << *i;
diff --git a/build2/variable.txx b/build2/variable.txx
index 721e3c0..bd7a18b 100644
--- a/build2/variable.txx
+++ b/build2/variable.txx
@@ -138,7 +138,18 @@ namespace build2
for (auto i (ns.begin ()); i != ns.end (); ++i)
{
name& n (*i);
- name* r (n.pair ? &*++i : nullptr);
+ name* r (nullptr);
+
+ if (n.pair)
+ {
+ r = &*++i;
+
+ if (n.pair != '@')
+ fail << "unexpected pair style for "
+ << value_traits<T>::value_type.name << " value "
+ << "'" << n << "'" << n.pair << "'" << *r << "' "
+ << "in variable " << var.name;
+ }
try
{
@@ -279,6 +290,12 @@ namespace build2
name& r (*++i); // Got to have the second half of the pair.
+ if (l.pair != '@')
+ fail << "unexpected pair style for "
+ << value_traits<map<K, V>>::value_type.name << " key-value "
+ << "'" << l << "'" << l.pair << "'" << r << "' "
+ << "in variable " << var.name;
+
try
{
K k (value_traits<K>::convert (move (l), nullptr));
@@ -329,7 +346,7 @@ namespace build2
for (const auto& p: vm)
{
s.push_back (value_traits<K>::reverse (p.first));
- s.back ().pair = true;
+ s.back ().pair = '@';
s.push_back (value_traits<V>::reverse (p.second));
}