From 55211f91fa8120ff0cb545157ad8e4cf5669c2e8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 20 Oct 2016 12:10:25 +0200 Subject: Add support for lexing modes that treat quotes as literals --- build2/lexer | 1 + build2/lexer.cxx | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build2/lexer b/build2/lexer index e9de617..df8c852 100644 --- a/build2/lexer +++ b/build2/lexer @@ -114,6 +114,7 @@ namespace build2 char sep_pair; bool sep_space; // Are whitespaces separators (see skip_spaces())? + bool quotes; // Recognize quoted fragments. // Word separator characters. For two-character sequence put the first // one in sep_first and the second one in the corresponding position of diff --git a/build2/lexer.cxx b/build2/lexer.cxx index c84b102..8760c13 100644 --- a/build2/lexer.cxx +++ b/build2/lexer.cxx @@ -36,6 +36,7 @@ namespace build2 const char* s2 (nullptr); char p ('\0'); bool s (true); + bool q (true); switch (m) { @@ -72,7 +73,7 @@ namespace build2 default: assert (false); // Unhandled custom mode. } - state_.push (state {m, p, s, s1, s2}); + state_.push (state {m, p, s, q, s1, s2}); } token lexer:: @@ -396,10 +397,10 @@ namespace build2 } } - // Handle single and double quotes unless they were considered - // separators. + // Handle single and double quotes if enabled for this mode and unless + // they were considered separators. // - if (!done) + if (st.quotes && !done) { switch (c) { -- cgit v1.1