aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/parser.cxx24
-rw-r--r--libbuild2/parser.hxx3
2 files changed, 25 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};
}
diff --git a/libbuild2/parser.hxx b/libbuild2/parser.hxx
index 658f266..79cbead 100644
--- a/libbuild2/parser.hxx
+++ b/libbuild2/parser.hxx
@@ -333,6 +333,9 @@ namespace build2
// it is the result of a sole, unquoted variable expansion, function call,
// or context evaluation.
//
+ // In the pre-parse mode no names are appended and the result is always
+ // {true, nullptr, nullopt}.
+ //
struct parse_names_result
{
bool not_null;