aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-09-30 13:57:10 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-09-30 15:30:55 +0200
commite42da2a469404e1d421ccee7ccbccb36f363a98b (patch)
tree62e5f89e99bd6b70dffdfc2f25f5d99d5aae5cd3 /libbuild2/parser.cxx
parent4a295f6ff98e7ff7ec9a33f38748a6537780a1bf (diff)
Handle attributes in switch value and pattern expressions
Diffstat (limited to 'libbuild2/parser.cxx')
-rw-r--r--libbuild2/parser.cxx30
1 files changed, 28 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)
{