From 3552356a87402727e663131994fa87f48b3cd4fb Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 22 May 2020 11:26:24 +0200 Subject: Improve ternary diagnostics with info for wildcard pattern escape --- libbuild2/parser.cxx | 15 +++++++++++++-- 1 file 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 (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? -- cgit v1.1