From d4baa98d4e4c290a5afbda4228e12b2bc7b3866e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 10 Mar 2016 15:24:11 +0200 Subject: Allow escaping in double-quote strings, use ['"\] as var name delimiters --- build2/lexer.cxx | 25 +++++++++++++++++-------- 1 file 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 -- cgit v1.1