aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2022-06-03 10:38:23 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2022-06-03 10:38:23 +0200
commit776f59bc572ad1d6e00b9e72bbed595c74757abe (patch)
treee21b6341ecdf4ea22255f33491469c17ae4963de
parent66438e8e5f6fcf77ef6d4c32fda000168b37cd7a (diff)
Expose type name to value_type mapping function in parser
-rw-r--r--libbuild2/parser.cxx8
-rw-r--r--libbuild2/parser.hxx9
2 files changed, 13 insertions, 4 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 99e67a7..19c1751 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -4633,8 +4633,8 @@ namespace build2
: value (names ());
}
- static const value_type*
- map_type (const string& n)
+ const value_type* parser::
+ find_value_type (const scope*, const string& n)
{
auto ptr = [] (const value_type& vt) {return &vt;};
@@ -4680,7 +4680,7 @@ namespace build2
string& n (a.name);
value& v (a.value);
- if (const value_type* t = map_type (n))
+ if (const value_type* t = find_value_type (root_, n))
{
if (type != nullptr && t != type)
fail (l) << "multiple variable types: " << n << ", " << type->name;
@@ -4742,7 +4742,7 @@ namespace build2
null = true;
// Fall through.
}
- else if (const value_type* t = map_type (n))
+ else if (const value_type* t = find_value_type (root_, n))
{
if (type != nullptr && t != type)
fail (l) << "multiple value types: " << n << ", " << type->name;
diff --git a/libbuild2/parser.hxx b/libbuild2/parser.hxx
index a6060d5..185216b 100644
--- a/libbuild2/parser.hxx
+++ b/libbuild2/parser.hxx
@@ -120,6 +120,15 @@ namespace build2
vector<pair<lookup, string>> config_report; // Config value and format.
bool config_report_new = false; // One of values is new.
+ // Misc utilities.
+ //
+ public:
+ // Return the value type corresponding to the type name or NULL if the
+ // type name is unknown. Pass project's root scope if known.
+ //
+ static const value_type*
+ find_value_type (const scope* rs, const string& name);
+
// Recursive descent parser.
//
protected: