aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-12-16 17:18:35 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-12-16 17:18:35 +0200
commit7967542a0bc1331e809d13e04c06f1ec124fcf0b (patch)
treeeee52509d1071b61617c5e81fee4bfa1fb1dde23
parent25352f11efd89c5b17cf401cf3c33d944c0adc52 (diff)
Minor code cleanup
-rw-r--r--build2/parser.cxx30
1 files changed, 19 insertions, 11 deletions
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: