aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/parser.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-07-12 12:07:57 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-07-25 15:30:09 +0300
commitbd43c80c29a02eeebc8667cd14ccb2784e6f5534 (patch)
treeb794de2e919cc78787975dc484b58b543503166f /libbuild2/parser.cxx
parent2161f4a66606ae380c67e67343f5f07bb2649f54 (diff)
Implement pre-parse mode for parse_names_trailer()
Diffstat (limited to 'libbuild2/parser.cxx')
-rw-r--r--libbuild2/parser.cxx24
1 files changed, 22 insertions, 2 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 2f1cf56..4df2ce3 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -3704,8 +3704,6 @@ namespace build2
const string* tp,
bool cross)
{
- assert (!pre_parse_);
-
if (pp)
pmode = pattern_mode::ignore;
@@ -3761,6 +3759,11 @@ namespace build2
//
if (pat_tt)
{
+ // In the pre-parse mode the parse_names() result can never be a
+ // pattern.
+ //
+ assert (!pre_parse_);
+
// Move the pattern names our of the result.
//
names ps;
@@ -3802,6 +3805,11 @@ namespace build2
continue;
}
+ // In the pre-parse mode we fall back to the above "cross with empty
+ // LHS" case.
+ //
+ assert (!pre_parse_);
+
//@@ This can be a nested replay (which we don't support), for example,
// via target-specific var assignment. Add support for nested (2-level
// replay)? Why not use replay_guard for storage? Alternatively, don't
@@ -3834,6 +3842,12 @@ namespace build2
}
}
+ // We don't modify the resulting names during pre-parsing and so can bail
+ // out now.
+ //
+ if (pre_parse_)
+ return 0;
+
// Splice the names into the result. Note that we have already handled
// project/dir/type qualification but may still have a pair. Fast-path
// common cases.
@@ -4224,6 +4238,9 @@ namespace build2
{
tt = peek ();
+ // Skip it in the pre-parse mode (any {...} that may follow will be
+ // handled as an untyped group below).
+ //
if (pre_parse_)
continue;
@@ -4918,6 +4935,9 @@ namespace build2
string ());
}
+ if (pre_parse_)
+ assert (!vnull && vtype == nullptr && !rpat);
+
return parse_names_result {!vnull, vtype, rpat};
}