From 08ae9246421cf2b7269dc09dab2dbd5dc5d0817a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 28 Oct 2016 13:01:04 +0200 Subject: Add tests and fixes for trailing description support --- build2/test/script/lexer.cxx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'build2/test/script/lexer.cxx') diff --git a/build2/test/script/lexer.cxx b/build2/test/script/lexer.cxx index 8b647dc..a9b7d56 100644 --- a/build2/test/script/lexer.cxx +++ b/build2/test/script/lexer.cxx @@ -407,20 +407,30 @@ namespace build2 token lexer:: next_description () { - xchar c (get ()); + xchar c (peek ()); + + if (eos (c)) + fail (c) << "expected newline at the end of description line"; uint64_t ln (c.line), cn (c.column); + + if (c == '\n') + { + get (); + state_.pop (); // Expire the description mode. + return token (type::newline, false, ln, cn, token_printer); + } + string lexeme; // For now no line continutions though we could support them. // - for (; !eos (c) && c != '\n'; c = get ()) + for (; !eos (c) && c != '\n'; c = peek ()) + { + get (); lexeme += c; + } - if (eos (c)) - fail (c) << "expected newline at the end of description line"; - - state_.pop (); // Expire the description mode. return token (move (lexeme), false, false, ln, cn); } -- cgit v1.1