diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-04-04 13:06:50 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-04-04 13:06:50 +0200 |
commit | 5c369faa461ec4416d2d4b231a5b36963a7315ce (patch) | |
tree | fc1b550870a29f0a03e258a76f16496ac69ec35c /build2/context.cxx | |
parent | 0e486cd3642da8a442629ffce9a3daf16745c35e (diff) |
Implement value typing, null support via value attributes
For example:
v = [null]
v = [string] abc
v += ABC # abcABC
Diffstat (limited to 'build2/context.cxx')
-rw-r--r-- | build2/context.cxx | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/build2/context.cxx b/build2/context.cxx index 26fc41a..941f98a 100644 --- a/build2/context.cxx +++ b/build2/context.cxx @@ -136,14 +136,19 @@ namespace build2 o = o->override.get (); // Currently we expand project overrides in the global scope to keep - // things simple. + // things simple. Pass original variable for diagnostics. // parser p; - names val; - t = p.parse_variable_value (l, gs, val); + pair<value, token> r (p.parse_variable_value (l, gs, var)); - if (t.type != token_type::eos) - fail << "unexpected " << t << " in variable assignment '" << s << "'"; + if (r.second.type != token_type::eos) + fail << "unexpected " << r.second << " in variable assignment " + << "'" << s << "'"; + + // Make sure the value is not typed. + // + if (r.first.type != nullptr) + fail << "typed override of variable " << var.name; if (c == '!') { @@ -153,10 +158,10 @@ namespace build2 fail << "multiple global overrides of variable " << var.name; value& v (p.first); - v.assign (move (val), var); // Original var for diagnostics. + v = move (r.first); } else - vos.emplace_back (variable_override {var, *o, move (val)}); + vos.emplace_back (variable_override {var, *o, move (r.first)}); } // Enter builtin variables. |