aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-05-22 11:26:24 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-05-27 08:35:29 +0200
commit3552356a87402727e663131994fa87f48b3cd4fb (patch)
treeb2bd2f8a2f6fbac9af1eb39d2d1a0ac9bc549c7b /libbuild2/parser.cxx
parentaae1d0fd9c98f6b562b28b4c802803bad7c6dce6 (diff)
Improve ternary diagnostics with info for wildcard pattern escape
Diffstat (limited to 'libbuild2/parser.cxx')
-rw-r--r--libbuild2/parser.cxx15
1 files changed, 13 insertions, 2 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index f0eac97..e87ca95 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -3568,6 +3568,8 @@ namespace build2
if (tt != type::question)
return lhs;
+ location ql (get_location (t));
+
// Use the pre-parse mechanism to implement short-circuit.
//
bool pp (pre_parse_);
@@ -3577,7 +3579,12 @@ namespace build2
{
q = pp ? true : convert<bool> (move (lhs));
}
- catch (const invalid_argument& e) { fail (l) << e << endf; }
+ catch (const invalid_argument& e)
+ {
+ fail (l) << e <<
+ info (ql) << "use the '\\?' escape sequence if this is a wildcard "
+ << "pattern" << endf;
+ }
if (!pp)
pre_parse_ = !q; // Short-circuit middle?
@@ -3587,7 +3594,11 @@ namespace build2
value mhs (parse_eval_ternary (t, tt, pmode));
if (tt != type::colon)
- fail (t) << "expected ':' instead of " << t;
+ {
+ fail (t) << "expected ':' instead of " << t <<
+ info (ql) << "use the '\\?' escape sequence if this is a wildcard "
+ << "pattern" << endf;
+ }
if (!pp)
pre_parse_ = q; // Short-circuit right?