aboutsummaryrefslogtreecommitdiff
path: root/build2/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-03-28 09:14:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-03-28 16:03:35 +0200
commit3ce44330cca9dbc4314feebb27403ebc3175b6c2 (patch)
tree8c1f27442f3b2dafaec3ba50baaca3d5fd63dca7 /build2/parser.cxx
parent9d0d078ff297138622cd2f3f1076f5984395e42b (diff)
New variable architecture
Diffstat (limited to 'build2/parser.cxx')
-rw-r--r--build2/parser.cxx36
1 files changed, 21 insertions, 15 deletions
diff --git a/build2/parser.cxx b/build2/parser.cxx
index ab9012c..b19fcb3 100644
--- a/build2/parser.cxx
+++ b/build2/parser.cxx
@@ -1062,14 +1062,21 @@ namespace build2
const location nsl (get_location (t, &path_));
names_type ns (names (t, tt));
- // Should evaluate to true or false.
+ // Should evaluate to 'true' or 'false'.
//
- if (ns.size () != 1 || !assign<bool> (ns[0]))
+ try
+ {
+ if (ns.size () != 1)
+ throw invalid_argument (string ());
+
+ bool e (convert<bool> (move (ns[0])));
+ take = (k.back () == '!' ? !e : e);
+ }
+ catch (const invalid_argument&)
+ {
fail (nsl) << "expected " << k << "-expression to evaluate to "
<< "'true' or 'false' instead of '" << ns << "'";
-
- bool e (ns[0].value == "true");
- take = (k.back () == '!' ? !e : e);
+ }
}
}
else
@@ -1574,8 +1581,8 @@ namespace build2
// pretty quickly end up with a list of names that we need
// to splice into the result.
//
- names_type lv_data;
- const names_type* plv;
+ names_type lv_storage;
+ names_view lv;
location loc;
const char* what; // Variable or evaluation context.
@@ -1630,10 +1637,10 @@ namespace build2
tt = peek ();
- if (lv_data.empty ())
+ if (lv_storage.empty ())
continue;
- plv = &lv_data;
+ lv = lv_storage;
what = "function call";
}
else
@@ -1660,27 +1667,26 @@ namespace build2
if (!l || l->empty ())
continue;
- plv = &l->data_;
+ lv = reverse (*l, lv_storage);
what = "variable expansion";
}
}
else
{
loc = get_location (t, &path_);
- lv_data = eval (t, tt);
+ lv_storage = eval (t, tt);
tt = peek ();
- if (lv_data.empty ())
+ if (lv_storage.empty ())
continue;
- plv = &lv_data;
+ lv = lv_storage;
what = "context evaluation";
}
- // @@ Could move if (lv == &lv_data).
+ // @@ Could move if lv is lv_storage.
//
- const names_type& lv (*plv);
// Should we accumulate? If the buffer is not empty, then
// we continue accumulating (the case where we are separated