aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/build
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-05-25 12:12:13 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-05-27 15:44:40 +0200
commitba628f6f90e7412245dcebdecd9cfa7e4bbf989c (patch)
tree8f7f109c70d615bc93daa2a8f4b25ceb3842e062 /libbuild2/build
parent2a9204cab666d47770bf3809d95a689088019121 (diff)
Add support for value subscript after expansionsadhoc-recipe-history
Value subscript is only recognized in evaluation contexts (due to ambiguity with wildcard patterns; consider: $x[123].txt) and should be unseparated from the previous token. For example: x = ($y[1]) x = (($f ? $y : $z)[1]) x = ($identity($x)[$z])
Diffstat (limited to 'libbuild2/build')
-rw-r--r--libbuild2/build/script/lexer.cxx15
1 files changed, 7 insertions, 8 deletions
diff --git a/libbuild2/build/script/lexer.cxx b/libbuild2/build/script/lexer.cxx
index 7b8bdd4..a58f794 100644
--- a/libbuild2/build/script/lexer.cxx
+++ b/libbuild2/build/script/lexer.cxx
@@ -27,8 +27,6 @@ namespace build2
optional<const char*> esc,
uintptr_t data)
{
- bool a (false); // attributes
-
const char* s1 (nullptr);
const char* s2 (nullptr);
@@ -88,7 +86,8 @@ namespace build2
}
assert (ps == '\0');
- state_.push (state {m, data, nullopt, a, ps, s, n, q, *esc, s1, s2});
+ state_.push (
+ state {m, data, nullopt, false, false, ps, s, n, q, *esc, s1, s2});
}
token lexer::
@@ -129,16 +128,16 @@ namespace build2
return token (t, sep, ln, cn, token_printer);
};
- // Handle attributes (do it first to make sure the flag is cleared
- // regardless of what we return).
+ // Handle `[` (do it first to make sure the flag is cleared regardless
+ // of what we return).
//
- if (st.attributes)
+ if (st.lsbrace)
{
assert (m == lexer_mode::variable_line);
- state_.top ().attributes = false;
+ state_.top ().lsbrace = false; // Note: st is a copy.
- if (c == '[')
+ if (c == '[' && (!st.lsbrace_unsep || !sep))
return make_token (type::lsbrace);
}