diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-05-25 11:19:04 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-05-28 10:10:44 +0200 |
commit | 6b3e75edf034ebcbd048a24c283c7bcf7b1da019 (patch) | |
tree | 4dff34692fd09c6f201a486c0d92549adc864947 /libbuild2/lexer.cxx | |
parent | bb02e152dc036879ab0b2d1d8aa2cb19084b8e16 (diff) |
Add support for regex-based target type/pattern specific variables
This is in addition to the already supported path-based target type/pattern
specific variables. For example:
hxx{*}: x = y # path-based
hxx{~/.*/}: x = y # regex-based
Diffstat (limited to 'libbuild2/lexer.cxx')
-rw-r--r-- | libbuild2/lexer.cxx | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/libbuild2/lexer.cxx b/libbuild2/lexer.cxx index 0b6f96d..f445d4b 100644 --- a/libbuild2/lexer.cxx +++ b/libbuild2/lexer.cxx @@ -674,18 +674,15 @@ namespace build2 bool qcomp (false); bool qfirst (false); - auto append = [&lexeme, &m, &qcomp, &qfirst] (char c) + auto append = [&lexeme, &m, &qcomp, &qfirst] (char c, bool escaped = false) { - if (m == lexer_mode::double_quoted) - { - if (lexeme.empty ()) // First character. + if (lexeme.empty () && (escaped || m == lexer_mode::double_quoted)) qfirst = true; - } - else - { - if (qcomp) // An unquoted character after a quoted fragment. - qcomp = false; - } + + // An unquoted character after a quoted fragment. + // + if (m != lexer_mode::double_quoted && qcomp) + qcomp = false; lexeme += c; }; @@ -716,7 +713,7 @@ namespace build2 fail (p) << "unterminated escape sequence"; if (p != '\n') // Ignore if line continuation. - append (p); + append (p, true); continue; } |