From 5ec57d68a5205173a02c34a24d7129347d43196c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 14 Nov 2019 12:55:54 +0200 Subject: Tighten up attribute recognition during parsing Now it should be possible to use `[]` for wildcard patterns, for example: foo = foo.[hit]xx Note that a leading bracket expression will still be recognized as attributes and escaping or quoting it will inhibit pattern matching. To resolve this case we need to specify an empty attribute list: foo = [] [abc]-foo.cxx --- libbuild2/test/script/parser.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libbuild2/test/script/parser.cxx') diff --git a/libbuild2/test/script/parser.cxx b/libbuild2/test/script/parser.cxx index f3f6ffa..aa78437 100644 --- a/libbuild2/test/script/parser.cxx +++ b/libbuild2/test/script/parser.cxx @@ -1288,10 +1288,11 @@ namespace build2 // enter: assignment // leave: newline or semi - // We cannot reuse the value mode since it will recognize { which we + // We cannot reuse the value mode since it will recognize `{` which we // want to treat as a literal. // mode (lexer_mode::variable_line); + enable_attributes (); // @@ VAL next (t, tt); // Parse value attributes if any. Note that it's ok not to have @@ -3446,11 +3447,13 @@ namespace build2 path_ = &name; istringstream is (attributes); - lexer l (is, name, lexer_mode::attribute); + lexer l (is, name, lexer_mode::attributes); set_lexer (&l); token t; type tt; + + enable_attributes (); // Enable `[` recognition. next (t, tt); if (tt != type::lsbrace && tt != type::eos) -- cgit v1.1