-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
factored out tracking and untracking of lists of pddl objects
- Loading branch information
Showing
11 changed files
with
232 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (C) 2023 Dominik Drexler | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "reference_utils.hpp" | ||
|
||
#include "../../../../include/loki/domain/pddl/exceptions.hpp" | ||
|
||
|
||
namespace loki { | ||
|
||
void track_variable_references(const pddl::ParameterList& parameter_list, Context& context) { | ||
for (const auto& parameter : parameter_list) { | ||
context.references.track(parameter->get_variable()); | ||
} | ||
} | ||
|
||
void test_variable_references(const pddl::ParameterList& parameter_list, const Context& context) { | ||
for (const auto& parameter : parameter_list) { | ||
if (context.references.exists(parameter->get_variable())) { | ||
const auto& [variable, position, error_handler] = context.scopes.get<pddl::VariableImpl>(parameter->get_variable()->get_name()).value(); | ||
throw UnusedVariableError(variable->get_name(), error_handler(position.value(), "")); | ||
} | ||
} | ||
} | ||
|
||
|
||
void track_predicate_references(const pddl::PredicateList& predicate_list, Context& context) { | ||
for (const auto& predicate : predicate_list) { | ||
context.references.track(predicate); | ||
} | ||
} | ||
|
||
void test_predicate_references(const pddl::PredicateList& predicate_list, const Context& context) { | ||
for (const auto& predicate : predicate_list) { | ||
if (context.references.exists(predicate)) { | ||
const auto& [_predicate, position, error_handler] = context.scopes.get<pddl::PredicateImpl>(predicate->get_name()).value(); | ||
throw UnusedPredicateError(predicate->get_name(), error_handler(position.value(), "")); | ||
} | ||
} | ||
} | ||
|
||
|
||
void track_function_skeleton_references(const pddl::FunctionSkeletonList& function_skeleton_list, Context& context) { | ||
for (const auto& function_skeleton : function_skeleton_list) { | ||
context.references.track(function_skeleton); | ||
} | ||
} | ||
|
||
void test_function_skeleton_references(const pddl::FunctionSkeletonList& function_skeleton_list, const Context& context) { | ||
for (const auto& function_skeleton : function_skeleton_list) { | ||
if (context.references.exists(function_skeleton)) { | ||
const auto& [_function_skeleton, position, error_handler] = context.scopes.get<pddl::FunctionSkeletonImpl>(function_skeleton->get_name()).value(); | ||
throw UnusedFunctionSkeletonError(function_skeleton->get_name(), error_handler(position.value(), "")); | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (C) 2023 Dominik Drexler | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef LOKI_SRC_PROBLEM_PDDL_PARSER_REFERENCE_UTILS_HPP_ | ||
#define LOKI_SRC_PROBLEM_PDDL_PARSER_REFERENCE_UTILS_HPP_ | ||
|
||
#include "../../../../include/loki/common/pddl/context.hpp" | ||
#include "../../../../include/loki/domain/pddl/declarations.hpp" | ||
#include "../../../../include/loki/domain/pddl/parameter.hpp" | ||
|
||
|
||
namespace loki { | ||
|
||
// For tracking an untracking of lists of pddl objects | ||
|
||
extern void track_variable_references(const pddl::ParameterList& parameter_list, Context& context); | ||
|
||
extern void test_variable_references(const pddl::ParameterList& parameter_list, const Context& context); | ||
|
||
|
||
extern void track_predicate_references(const pddl::PredicateList& predicate_list, Context& context); | ||
|
||
extern void test_predicate_references(const pddl::PredicateList& predicate_list, const Context& context); | ||
|
||
|
||
extern void track_function_skeleton_references(const pddl::FunctionSkeletonList& function_skeleton_list, Context& context); | ||
|
||
extern void test_function_skeleton_references(const pddl::FunctionSkeletonList& function_skeleton_list, const Context& context); | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.