diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-12-02 11:37:15 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-12-02 11:37:15 +0200 |
commit | 9891b20350021ce41a950645dd76df20a45c92cc (patch) | |
tree | 0cd27041b0c3413e17b9319ae99e87c5e745b1ff /build/parser.cxx | |
parent | 74212589a797ca75e55f92a522e198915c0dbaf6 (diff) |
Implement optional module loading
The syntax is:
using? cli
Now each module use results in two bool variables: <module>.loaded and
<module>.configured.
Also implement variable visibility (the above two variables are limited
to project).
Diffstat (limited to 'build/parser.cxx')
-rw-r--r-- | build/parser.cxx | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/build/parser.cxx b/build/parser.cxx index 05c79db..c896c71 100644 --- a/build/parser.cxx +++ b/build/parser.cxx @@ -128,7 +128,8 @@ namespace build export_ (t, tt); continue; } - else if (n == "using") + else if (n == "using" || + n == "using?") { using_ (t, tt); continue; @@ -360,7 +361,7 @@ namespace build fail (t) << "append to target type/pattern-specific " << "variable " << v; - const auto& var (variable_pool.find (move (v))); + const auto& var (var_pool.find (move (v))); // Note: expand variables in the value in the context of // the scope. @@ -711,7 +712,7 @@ namespace build if (at == token_type::equal || at == token_type::plus_equal) { - var = &variable_pool.find (t.value); + var = &var_pool.find (t.value); val = at == token_type::equal ? &scope_->assign (*var) : &scope_->append (*var); @@ -782,6 +783,8 @@ namespace build { tracer trace ("parser::using", &path_); + bool optional (t.value.back () == '?'); + // The rest should be a list of module names. Parse them as names // to get variable expansion, etc. // @@ -798,7 +801,7 @@ namespace build if (!n.simple ()) fail (l) << "module name expected instead of " << n; - load_module (n.value, *root_, *scope_, l); + load_module (optional, n.value, *root_, *scope_, l); } if (tt == type::newline) @@ -912,7 +915,7 @@ namespace build void parser:: variable (token& t, token_type& tt, string name, token_type kind) { - const auto& var (variable_pool.find (move (name))); + const auto& var (var_pool.find (move (name))); names_type vns (variable_value (t, tt, var)); if (kind == type::equal) @@ -1366,7 +1369,7 @@ namespace build // Lookup. // - const auto& var (variable_pool.find (move (n))); + const auto& var (var_pool.find (move (n))); auto l (target_ != nullptr ? (*target_)[var] : (*scope_)[var]); // Undefined/NULL namespace variables are not allowed. |