From 5c369faa461ec4416d2d4b231a5b36963a7315ce Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 4 Apr 2016 13:06:50 +0200 Subject: Implement value typing, null support via value attributes For example: v = [null] v = [string] abc v += ABC # abcABC --- build2/context.cxx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'build2/context.cxx') 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 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. -- cgit v1.1