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);