From 97ca7117735044673da6c89ee9dff544a3526f70 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 6 Aug 2017 15:16:04 +0200 Subject: Resolve if-else block ambiguity --- build2/parser.cxx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'build2/parser.cxx') diff --git a/build2/parser.cxx b/build2/parser.cxx index 0c45e17..66af0a5 100644 --- a/build2/parser.cxx +++ b/build2/parser.cxx @@ -1396,13 +1396,17 @@ namespace build2 fail (t) << "expected newline instead of " << t << " after " << k << (k != "else" ? "-expression" : ""); - // This can be a block or a single line. + // This can be a block or a single line. The block part is a bit + // tricky, consider: // - if (next (t, tt) == type::lcbrace) + // else + // {hxx cxx}{options}: install = false + // + // So we treat it as a block if it's followed immediately by newline. + // + if (next (t, tt) == type::lcbrace && peek () == type::newline) { - if (next (t, tt) != type::newline) - fail (t) << "expected newline after {"; - + next (t, tt); // Get newline. next (t, tt); if (take) -- cgit v1.1