From 82a01d4ffa203c7bfc4f6d306178a444ab618f62 Mon Sep 17 00:00:00 2001 From: olaghattas Date: Sat, 9 Aug 2025 20:47:22 -0700 Subject: [PATCH] bug fix where param_to_type_map was never populated causing type to be an empty string and init of the problem doesnt get populated --- pddl_parser/src/pddl_parser.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pddl_parser/src/pddl_parser.cpp b/pddl_parser/src/pddl_parser.cpp index 299d43c..a2077dc 100644 --- a/pddl_parser/src/pddl_parser.cpp +++ b/pddl_parser/src/pddl_parser.cpp @@ -107,6 +107,8 @@ namespace pddl_lib { std::string_view section; std::string matched_token; std::vector all_comments; + + std::unordered_map param_to_type_map; std::tie(section, remaining) = getNextParen(content); const auto strings = parseVector(section, {'\t', '\n', ' '}, all_comments); @@ -144,6 +146,13 @@ namespace pddl_lib { // return fmt::format("ERROR line {}: missing ':objects' keyword", get_line_num(content, substrings[0])); problem.objects = parse_instantiated_params( std::vector(substrings.begin() + 1, substrings.end())); + + // <-- Populate param_to_type_map here + + for (auto &obj : problem.objects) { + param_to_type_map[obj.name] = obj.type; + } + ind++; std::tie(section, remaining) = getNextParen(strings[ind]); substrings = parseVector(section, {'\t', '\n', ' '}, all_comments); @@ -152,7 +161,7 @@ namespace pddl_lib { if (substrings[0] != ":init") { return fmt::format("ERROR line {}: missing ':init' keyword", get_line_num(content, substrings[0])); } - std::unordered_map param_to_type_map; + for (const auto &str: std::vector(substrings.begin() + 1, substrings.end())) { std::tie(section, remaining) = getNextParen(str); auto subsubstrings = parseVector(section, {'\t', '\n', ' '}, all_comments);