From 7967542a0bc1331e809d13e04c06f1ec124fcf0b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 16 Dec 2016 17:18:35 +0200 Subject: Minor code cleanup --- build2/parser.cxx | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'build2') diff --git a/build2/parser.cxx b/build2/parser.cxx index 6b5708e..688df86 100644 --- a/build2/parser.cxx +++ b/build2/parser.cxx @@ -2407,14 +2407,25 @@ namespace build2 tt != type::pair_separator)); }; + // Return true if the next token which should be peeked at won't be part + // of this concatenation. + // + auto last_concat = [this] () + { + const token& t (peeked ()); + type tt (t.type); + + return (t.separated || + (tt != type::word && + tt != type::dollar && + tt != type::lparen)); + }; + // If we have accumulated some concatenations, then we have two options: // continue accumulating or inject. We inject if the next token is not a // word, var expansion, or eval context or if it is separated. // - if (concat && - ((tt != type::word && - tt != type::dollar && - tt != type::lparen) || peeked ().separated)) + if (concat && last_concat ()) { // Concatenation does not affect the tokens we get, only what we do // with them. As a result, we never set the concat flag during pre- @@ -2510,9 +2521,8 @@ namespace build2 // the next token is a var expansion or eval context and it // is not separated, then we need to start accumulating. // - if (concat || // Continue. - ((tt == type::dollar || - tt == type::lparen) && !peeked ().separated)) // Start. + if (concat || // Continue. + !last_concat ()) // Start. { // If LHS is typed then do typed concatenation. // @@ -2822,10 +2832,8 @@ namespace build2 // the next token is a word or var expansion and it is not // separated, then we need to start accumulating. // - if (concat || // Continue. - ((tt == type::word || // Start. - tt == type::dollar || - tt == type::lparen) && !peeked ().separated)) + if (concat || // Continue. + !last_concat ()) // Start. { // This can be a typed or untyped concatenation. The rules that // determine which one it is are as follows: -- cgit v1.1