aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/lexer.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-05-01 17:09:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-05-01 17:12:04 +0200
commit630b498533f5a9a1e9d40893f4806ef855f1e03b (patch)
tree18657642a3d0deffc1ed14ad449bd6f3ac4b1e64 /libbuild2/lexer.cxx
parentc7e9f97fc7684c01c692916be1ac2cfc92024a0c (diff)
Fix outstanding issue with directive vs assignment differentiation
Specifically, now the following does the right thing: print +foo
Diffstat (limited to 'libbuild2/lexer.cxx')
-rw-r--r--libbuild2/lexer.cxx23
1 files changed, 18 insertions, 5 deletions
diff --git a/libbuild2/lexer.cxx b/libbuild2/lexer.cxx
index 5ffac54..c0cadd3 100644
--- a/libbuild2/lexer.cxx
+++ b/libbuild2/lexer.cxx
@@ -11,12 +11,26 @@ namespace build2
{
using type = token_type;
- pair<char, bool> lexer::
- peek_char ()
+ pair<pair<char, char>, bool> lexer::
+ peek_chars ()
{
sep_ = skip_spaces ();
- xchar c (peek ());
- return make_pair (eos (c) ? '\0' : char (c), sep_);
+ char r[2] = {'\0', '\0'};
+
+ xchar c0 (peek ());
+ if (!eos (c0))
+ {
+ get (c0);
+ r[0] = c0;
+
+ xchar c1 (peek ());
+ if (!eos (c1))
+ r[1] = c1;
+
+ unget (c0);
+ }
+
+ return make_pair (make_pair (r[0], r[1]), sep_);
}
void lexer::
@@ -31,7 +45,6 @@ namespace build2
bool n (true); // newline
bool q (true); // quotes
-
if (!esc)
{
assert (!state_.empty ());