From 776f59bc572ad1d6e00b9e72bbed595c74757abe Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 3 Jun 2022 10:38:23 +0200 Subject: Expose type name to value_type mapping function in parser --- libbuild2/parser.cxx | 8 ++++---- libbuild2/parser.hxx | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'libbuild2') 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> 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: -- cgit v1.1