From 630b498533f5a9a1e9d40893f4806ef855f1e03b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 1 May 2020 17:09:59 +0200 Subject: Fix outstanding issue with directive vs assignment differentiation Specifically, now the following does the right thing: print +foo --- libbuild2/lexer.cxx | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'libbuild2/lexer.cxx') 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 lexer:: - peek_char () + pair, 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 ()); -- cgit v1.1