diff options
Diffstat (limited to 'libbuild2')
-rw-r--r-- | libbuild2/parser.cxx | 30 | ||||
-rw-r--r-- | libbuild2/parser.hxx | 8 |
2 files changed, 36 insertions, 2 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx index a6a5a83..6a5698d 100644 --- a/libbuild2/parser.cxx +++ b/libbuild2/parser.cxx @@ -2105,7 +2105,10 @@ namespace build2 expr e; e.value = - parse_value (t, tt, pattern_mode::expand, "expression", nullptr); + parse_value_with_attributes (t, tt, + pattern_mode::expand, + "expression", + nullptr); if (tt == type::colon) { @@ -2203,7 +2206,7 @@ namespace build2 auto parse_pattern = [this] (token& t, type& tt) { - return parse_value ( + return parse_value_with_attributes ( t, tt, pattern_mode::ignore, "pattern", nullptr); }; @@ -3048,6 +3051,29 @@ namespace build2 } } + value parser:: + parse_value_with_attributes (token& t, token_type& tt, + pattern_mode pmode, + const char* what, + const string* separators) + { + // Parse value attributes if any. Note that it's ok not to have anything + // after the attributes (think [null]). + // + attributes_push (t, tt, true); + + value rhs (tt != type::newline && tt != type::eos + ? parse_value (t, tt, pmode, what, separators) + : value (names ())); + + if (pre_parse_) + return rhs; // Empty. + + value lhs; + apply_value_attributes (nullptr, lhs, move (rhs), type::assign); + return lhs; + } + values parser:: parse_eval (token& t, type& tt, pattern_mode pmode) { diff --git a/libbuild2/parser.hxx b/libbuild2/parser.hxx index 581ad1b..7174b3e 100644 --- a/libbuild2/parser.hxx +++ b/libbuild2/parser.hxx @@ -336,6 +336,14 @@ namespace build2 return v; } + // As above but also handle value attributes. + // + value + parse_value_with_attributes (token& t, token_type& tt, + pattern_mode pmode, + const char* what = "name", + const string* separators = &name_separators); + // Append names and return the indication if the parsed value is not NULL // and whether it is typed (and whether it is a pattern if pattern_mode is // detect). |