diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-04-02 16:18:43 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-04-02 16:18:43 +0200 |
commit | 0e486cd3642da8a442629ffce9a3daf16745c35e (patch) | |
tree | 37dd2b40366598a68685168759543bc8abb4de80 /build2/parser | |
parent | 4bf42322fdd5dd7e01a3f61272bccc4a66a5585f (diff) |
Implement variable typing (via attributes)
Now we can do:
[string] str = foo
Diffstat (limited to 'build2/parser')
-rw-r--r-- | build2/parser | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/build2/parser b/build2/parser index a4b5dc5..23f90cc 100644 --- a/build2/parser +++ b/build2/parser @@ -22,8 +22,9 @@ namespace build2 class parser { public: - typedef build2::names names_type; - typedef build2::variable variable_type; + using names_type = build2::names; + using variable_type = build2::variable; + using attributes_type = vector<pair<string, string>>; // If boot is true, then we are parsing bootstrap.build and modules // should only be bootstrapped. @@ -90,17 +91,23 @@ namespace build2 names_type variable_value (token&, token_type&); + void + variable_attribute (const variable_type&, + attributes_type&, + const location&); + names_type eval (token&, token_type&); void eval_trailer (token&, token_type&, names_type&); - // If the next token is [, parse the attribute sequence until ] storing - // it in attrs_, get the next token, verify it is not a newline or eos, - // and return true. Otherwise return false. + // If the next token is '[' parse the attribute sequence until ']', get + // the next token, verify it is not newline/eos, and return the pointer to + // the extracted attributes (which is only valid until the next call). + // Otherwise return NULL. // - bool + attributes_type* attributes (token&, token_type&); // If chunk is true, then parse the smallest but complete, name-wise, @@ -298,7 +305,7 @@ namespace build2 scope* scope_; // Current base scope (out_base). scope* root_; // Current root scope (out_root). - vector<pair<string, string>> attrs_; // Current attributes, if any. + attributes_type attrs_; // Current attributes, if any. target* default_target_; names_type export_value_; |