aboutsummaryrefslogtreecommitdiff
path: root/build2/parser
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-11-04 08:30:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:14 +0200
commit685dcfe6329479f1e19313a30409ba9f6e113f7d (patch)
tree6ec0d66938f3bbf33df526f1e778aafb4885a3c8 /build2/parser
parent20d3418dc97b08ac1d3eb2d276dac09943839045 (diff)
Allow customizing names parsing diagnostics
Diffstat (limited to 'build2/parser')
-rw-r--r--build2/parser24
1 files changed, 17 insertions, 7 deletions
diff --git a/build2/parser b/build2/parser
index eeaec7b..bb6bc17 100644
--- a/build2/parser
+++ b/build2/parser
@@ -154,13 +154,18 @@ namespace build2
// If chunk is true, then parse the smallest but complete, name-wise,
// chunk of input. Note that in this case you may still end up with
- // multiple names, for example, {foo bar}.
+ // multiple names, for example, {foo bar} or $foo.
+ //
+ // The what argument is used in diagnostics (e.g., "expected <what>
+ // instead of ...".
//
names_type
- names (token& t, token_type& tt, bool chunk = false)
+ names (token& t, token_type& tt,
+ bool chunk = false,
+ const char* what = "name")
{
names_type ns;
- names (t, tt, ns, chunk, 0, nullptr, nullptr, nullptr);
+ names (t, tt, ns, chunk, what, 0, nullptr, nullptr, nullptr);
return ns;
}
@@ -170,10 +175,10 @@ namespace build2
// context evaluation.
//
value
- names_value (token& t, token_type& tt)
+ names_value (token& t, token_type& tt, const char* what = "name")
{
names_type ns;
- return names (t, tt, ns, false, 0, nullptr, nullptr, nullptr)
+ return names (t, tt, ns, false, what, 0, nullptr, nullptr, nullptr)
? value (move (ns))
: value (nullptr);
}
@@ -181,15 +186,19 @@ namespace build2
// Append names and return true if the parsed value is NOT NULL.
//
bool
- names (token& t, token_type& tt, names_type& ns, bool chunk = false)
+ names (token& t, token_type& tt,
+ names_type& ns,
+ bool chunk = false,
+ const char* what = "name")
{
- return names (t, tt, ns, chunk, 0, nullptr, nullptr, nullptr);
+ return names (t, tt, ns, chunk, what, 0, nullptr, nullptr, nullptr);
}
bool
names (token&, token_type&,
names_type&,
bool chunk,
+ const char* what,
size_t pair,
const string* prj,
const dir_path* dir,
@@ -198,6 +207,7 @@ namespace build2
size_t
names_trailer (token&, token_type&,
names_type&,
+ const char* what,
size_t pair,
const string* prj,
const dir_path* dir,