aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/lexer3
-rw-r--r--build2/lexer.cxx22
2 files changed, 17 insertions, 8 deletions
diff --git a/build2/lexer b/build2/lexer
index 7e59ff1..827d141 100644
--- a/build2/lexer
+++ b/build2/lexer
@@ -24,7 +24,8 @@ namespace build2
// eval mode is used in the evaluation context. Quoted is an internal mode
// and should not be set explicitly.
//
- // Note that the value mode splits names separated by the pair character.
+ // Note that the normal, value, and eval modes split names separated by the
+ // pair character (to disable pairs one can pass '\0' as a pair character).
//
// The alternnative modes must be set manually. The value mode is
// automatically reset after the end of the line. The variable mode is reset
diff --git a/build2/lexer.cxx b/build2/lexer.cxx
index 6b599fd..8124765 100644
--- a/build2/lexer.cxx
+++ b/build2/lexer.cxx
@@ -35,7 +35,6 @@ namespace build2
next_impl ()
{
lexer_mode m (state_.top ().mode);
- char ps (state_.top ().pair_separator);
// For some modes we have dedicated imlementations of next().
//
@@ -54,6 +53,12 @@ namespace build2
if (eos (c))
return token (type::eos, sep, ln, cn);
+ // Handle pair separator.
+ //
+ if ((m == lexer_mode::normal || m == lexer_mode::value) &&
+ c == state_.top ().pair_separator)
+ return token (type::pair_separator, sep, ln, cn);
+
switch (c)
{
// NOTE: remember to update name(), next_eval() if adding new
@@ -77,11 +82,6 @@ namespace build2
case ')': return token (type::rparen, sep, ln, cn);
}
- // Handle pair separator.
- //
- if (m == lexer_mode::value && c == ps)
- return token (type::pair_separator, sep, ln, cn);
-
// The following characters are not treated as special in the value mode.
//
if (m != lexer_mode::value)
@@ -133,6 +133,12 @@ namespace build2
// This mode is quite a bit like the value mode when it comes to special
// characters, except that we have some of our own.
//
+
+ // Handle pair separator.
+ //
+ if (c == state_.top ().pair_separator)
+ return token (type::pair_separator, sep, ln, cn);
+
// Note: we don't treat [ and ] as special here. Maybe can use them for
// something later.
//
@@ -224,7 +230,9 @@ namespace build2
// Handle the pair separator.
//
- if (m == lexer_mode::value && c == ps)
+ if ((m == lexer_mode::normal ||
+ m == lexer_mode::value ||
+ m == lexer_mode::eval) && c == ps)
break;
// The following characters are only special in the normal and