aboutsummaryrefslogtreecommitdiff
path: root/build/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-12-14 10:12:23 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-12-14 10:12:23 +0200
commite649f2d988ce4e7a67aee1236850eb0b95a97d56 (patch)
treea1fe2ea19e24ba1d018fe08633f70be8489d607e /build/parser.cxx
parentde3f340fac96aca1e626068cbbb22ec92c1dc4b6 (diff)
Add support for variable prepend operator: =+
Diffstat (limited to 'build/parser.cxx')
-rw-r--r--build/parser.cxx30
1 files changed, 23 insertions, 7 deletions
diff --git a/build/parser.cxx b/build/parser.cxx
index 7f8b570..1c8f4f6 100644
--- a/build/parser.cxx
+++ b/build/parser.cxx
@@ -305,7 +305,9 @@ namespace build
// Scope/target-specific variable assignment.
//
- if (tt == type::equal || tt == type::plus_equal)
+ if (tt == type::equal ||
+ tt == type::equal_plus ||
+ tt == type::plus_equal)
{
string v (variable_name (move (pns), ploc));
@@ -376,6 +378,10 @@ namespace build
if (ti == nullptr)
fail (nloc) << "unknown target type " << n.type;
+ if (tt == type::equal_plus)
+ fail (t) << "prepend to target type/pattern-specific "
+ << "variable " << v;
+
if (tt == type::plus_equal)
fail (t) << "append to target type/pattern-specific "
<< "variable " << v;
@@ -460,7 +466,9 @@ namespace build
// Variable assignment.
//
- if (tt == type::equal || tt == type::plus_equal)
+ if (tt == type::equal ||
+ tt == type::equal_plus ||
+ tt == type::plus_equal)
{
variable (t, tt, variable_name (move (ns), nloc), tt);
@@ -729,13 +737,15 @@ namespace build
{
at = peek ();
- if (at == type::equal || at == type::plus_equal)
+ if (at == type::equal ||
+ at == type::equal_plus ||
+ at == type::plus_equal)
{
var = &var_pool.find (t.value);
val = at == type::equal
? &scope_->assign (*var)
: &scope_->append (*var);
- next (t, tt); // Consume =/+=.
+ next (t, tt); // Consume =/=+/+=.
lexer_->mode (lexer_mode::value);
next (t, tt);
}
@@ -759,6 +769,8 @@ namespace build
{
if (at == type::equal)
val->assign (move (r), *var);
+ else if (at == type::equal_plus)
+ val->prepend (move (r), *var);
else
val->append (move (r), *var);
}
@@ -1092,7 +1104,11 @@ namespace build
value& v (target_ != nullptr
? target_->append (var)
: scope_->append (var));
- v.append (move (vns), var);
+
+ if (kind == type::equal_plus)
+ v.prepend (move (vns), var);
+ else
+ v.append (move (vns), var);
}
}
@@ -1791,8 +1807,8 @@ namespace build
//
// - it is not quoted [so a keyword can always be escaped] and
// - next token is eos or '(' [so if(...) will work] or
- // - next token is separated and is not '=' or '+=' [which means a
- // "directive trailer" can never start with one of them].
+ // - next token is separated and is not '=', '=+', or '+=' [which
+ // means a "directive trailer" can never start with one of them].
//
// See tests/keyword.
//