aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-03-10 15:24:11 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-03-10 15:24:11 +0200
commitd4baa98d4e4c290a5afbda4228e12b2bc7b3866e (patch)
treed725ba902cba340943b05b94323ff49b93e9d9f0
parentcc2c21d5225fead188b8c2f1a077f20913faa0d1 (diff)
Allow escaping in double-quote strings, use ['"\] as var name delimiters
-rw-r--r--build2/lexer.cxx25
1 files changed, 17 insertions, 8 deletions
diff --git a/build2/lexer.cxx b/build2/lexer.cxx
index c73017e..1b24a61 100644
--- a/build2/lexer.cxx
+++ b/build2/lexer.cxx
@@ -234,10 +234,16 @@ namespace build2
//
if (m == lexer_mode::variable)
{
+ //@@ Maybe we should rather test for allowed characeters (e.g.,
+ // alnum plus '_' and '.')?
+ //
switch (c)
{
case '/':
case '-':
+ case '"':
+ case '\'':
+ case '\\':
{
done = true;
break;
@@ -268,6 +274,17 @@ namespace build2
break;
}
+ // Handle escape sequences.
+ //
+ if (c == '\\')
+ {
+ get ();
+ c = escape ();
+ if (c != '\n') // Ignore.
+ lexeme += c;
+ continue;
+ }
+
// If we are quoted, these are ordinary characters.
//
if (m != lexer_mode::quoted)
@@ -285,14 +302,6 @@ namespace build2
done = true;
break;
}
- case '\\':
- {
- get ();
- c = escape ();
- if (c != '\n') // Ignore.
- lexeme += c;
- continue;
- }
case '\'':
{
// If we are in the variable mode, then treat quote as just