Moved color logging to separate library for reusing it in PDDL parser.
This commit is contained in:
parent
595891f040
commit
e93085d88a
|
@ -25,6 +25,7 @@ if (CMAKE_GENERATOR STREQUAL "Ninja" AND
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(lib/tokenize)
|
add_subdirectory(lib/tokenize)
|
||||||
|
add_subdirectory(lib/colorlog)
|
||||||
add_subdirectory(lib/pddlparse)
|
add_subdirectory(lib/pddlparse)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_subdirectory(app)
|
add_subdirectory(app)
|
||||||
|
|
|
@ -7,6 +7,7 @@ set(includes
|
||||||
${Boost_INCLUDE_DIRS}
|
${Boost_INCLUDE_DIRS}
|
||||||
${PROJECT_SOURCE_DIR}/include
|
${PROJECT_SOURCE_DIR}/include
|
||||||
${PROJECT_SOURCE_DIR}/lib/tokenize/include
|
${PROJECT_SOURCE_DIR}/lib/tokenize/include
|
||||||
|
${PROJECT_SOURCE_DIR}/lib/colorlog/include
|
||||||
${PROJECT_SOURCE_DIR}/lib/variant/include
|
${PROJECT_SOURCE_DIR}/lib/variant/include
|
||||||
${PROJECT_SOURCE_DIR}/lib/pddlparse/include
|
${PROJECT_SOURCE_DIR}/lib/pddlparse/include
|
||||||
)
|
)
|
||||||
|
|
48
app/main.cpp
48
app/main.cpp
|
@ -4,16 +4,18 @@
|
||||||
|
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
|
|
||||||
|
#include <colorlog/ColorStream.h>
|
||||||
|
#include <colorlog/Logger.h>
|
||||||
|
#include <colorlog/Priority.h>
|
||||||
|
|
||||||
#include <pddlparse/AST.h>
|
#include <pddlparse/AST.h>
|
||||||
#include <pddlparse/Exception.h>
|
#include <pddlparse/Exception.h>
|
||||||
#include <pddlparse/Mode.h>
|
#include <pddlparse/Mode.h>
|
||||||
#include <pddlparse/Parse.h>
|
#include <pddlparse/Parse.h>
|
||||||
|
|
||||||
#include <plasp/LanguageDetection.h>
|
#include <plasp/LanguageDetection.h>
|
||||||
#include <plasp/output/ColorStream.h>
|
#include <plasp/TranslatorException.h>
|
||||||
#include <plasp/output/Logger.h>
|
|
||||||
#include <plasp/output/Priority.h>
|
|
||||||
#include <plasp/output/TranslatorException.h>
|
|
||||||
#include <plasp/pddl/TranslatorASP.h>
|
#include <plasp/pddl/TranslatorASP.h>
|
||||||
#include <plasp/sas/Description.h>
|
#include <plasp/sas/Description.h>
|
||||||
#include <plasp/sas/TranslatorASP.h>
|
#include <plasp/sas/TranslatorASP.h>
|
||||||
|
@ -49,7 +51,7 @@ int main(int argc, char **argv)
|
||||||
std::cout << description;
|
std::cout << description;
|
||||||
};
|
};
|
||||||
|
|
||||||
plasp::output::Logger logger;
|
colorlog::Logger logger;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -62,7 +64,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
catch (const po::error &e)
|
catch (const po::error &e)
|
||||||
{
|
{
|
||||||
logger.log(plasp::output::Priority::Error, e.what());
|
logger.log(colorlog::Priority::Error, e.what());
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
printHelp();
|
printHelp();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -81,7 +83,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (warningsAsErrors)
|
if (warningsAsErrors)
|
||||||
logger.setAbortPriority(plasp::output::Priority::Warning);
|
logger.setAbortPriority(colorlog::Priority::Warning);
|
||||||
|
|
||||||
auto parsingMode = pddl::Mode::Strict;
|
auto parsingMode = pddl::Mode::Strict;
|
||||||
|
|
||||||
|
@ -91,7 +93,7 @@ int main(int argc, char **argv)
|
||||||
parsingMode = pddl::Mode::Compatibility;
|
parsingMode = pddl::Mode::Compatibility;
|
||||||
else if (parsingModeString != "strict")
|
else if (parsingModeString != "strict")
|
||||||
{
|
{
|
||||||
logger.log(plasp::output::Priority::Error, "unknown parsing mode “" + parsingModeString + "”");
|
logger.log(colorlog::Priority::Error, "unknown parsing mode “" + parsingModeString + "”");
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
printHelp();
|
printHelp();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -101,20 +103,20 @@ int main(int argc, char **argv)
|
||||||
[&]()
|
[&]()
|
||||||
{
|
{
|
||||||
if (parsingMode != pddl::Mode::Compatibility)
|
if (parsingMode != pddl::Mode::Compatibility)
|
||||||
logger.log(plasp::output::Priority::Info, "try using --parsing-mode=compatibility for extended legacy feature support");
|
logger.log(colorlog::Priority::Info, "try using --parsing-mode=compatibility for extended legacy feature support");
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto colorPolicy = variablesMap["color"].as<std::string>();
|
const auto colorPolicy = variablesMap["color"].as<std::string>();
|
||||||
|
|
||||||
if (colorPolicy == "auto")
|
if (colorPolicy == "auto")
|
||||||
logger.setColorPolicy(plasp::output::ColorStream::ColorPolicy::Auto);
|
logger.setColorPolicy(colorlog::ColorStream::ColorPolicy::Auto);
|
||||||
else if (colorPolicy == "never")
|
else if (colorPolicy == "never")
|
||||||
logger.setColorPolicy(plasp::output::ColorStream::ColorPolicy::Never);
|
logger.setColorPolicy(colorlog::ColorStream::ColorPolicy::Never);
|
||||||
else if (colorPolicy == "always")
|
else if (colorPolicy == "always")
|
||||||
logger.setColorPolicy(plasp::output::ColorStream::ColorPolicy::Always);
|
logger.setColorPolicy(colorlog::ColorStream::ColorPolicy::Always);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.log(plasp::output::Priority::Error, "unknown color policy “" + colorPolicy + "”");
|
logger.log(colorlog::Priority::Error, "unknown color policy “" + colorPolicy + "”");
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
printHelp();
|
printHelp();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -124,12 +126,12 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto logPriority = plasp::output::priorityFromName(logPriorityString.c_str());
|
const auto logPriority = colorlog::priorityFromName(logPriorityString.c_str());
|
||||||
logger.setLogPriority(logPriority);
|
logger.setLogPriority(logPriority);
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
logger.log(plasp::output::Priority::Error, ("unknown log priorty “" + logPriorityString + "”").c_str());
|
logger.log(colorlog::Priority::Error, ("unknown log priorty “" + logPriorityString + "”").c_str());
|
||||||
logger.errorStream() << std::endl;
|
logger.errorStream() << std::endl;
|
||||||
printHelp();
|
printHelp();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -168,7 +170,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
if (language == plasp::Language::Type::Unknown)
|
if (language == plasp::Language::Type::Unknown)
|
||||||
{
|
{
|
||||||
logger.log(plasp::output::Priority::Error, "unknown input language");
|
logger.log(colorlog::Priority::Error, "unknown input language");
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
printHelp();
|
printHelp();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -179,7 +181,7 @@ int main(int argc, char **argv)
|
||||||
const auto logWarning =
|
const auto logWarning =
|
||||||
[&](const auto &location, const auto &warning)
|
[&](const auto &location, const auto &warning)
|
||||||
{
|
{
|
||||||
logger.log(plasp::output::Priority::Warning, location, warning);
|
logger.log(colorlog::Priority::Warning, location, warning);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto context = pddl::Context(std::move(tokenizer), logWarning);
|
auto context = pddl::Context(std::move(tokenizer), logWarning);
|
||||||
|
@ -197,7 +199,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
catch (const tokenize::TokenizerException &e)
|
catch (const tokenize::TokenizerException &e)
|
||||||
{
|
{
|
||||||
logger.log(plasp::output::Priority::Error, e.location(), e.message().c_str());
|
logger.log(colorlog::Priority::Error, e.location(), e.message().c_str());
|
||||||
|
|
||||||
printCompatibilityInfo();
|
printCompatibilityInfo();
|
||||||
|
|
||||||
|
@ -206,22 +208,22 @@ int main(int argc, char **argv)
|
||||||
catch (const pddl::ParserException &e)
|
catch (const pddl::ParserException &e)
|
||||||
{
|
{
|
||||||
if (e.location())
|
if (e.location())
|
||||||
logger.log(plasp::output::Priority::Error, e.location().value(), e.message().c_str());
|
logger.log(colorlog::Priority::Error, e.location().value(), e.message().c_str());
|
||||||
else
|
else
|
||||||
logger.log(plasp::output::Priority::Error, e.message().c_str());
|
logger.log(colorlog::Priority::Error, e.message().c_str());
|
||||||
|
|
||||||
printCompatibilityInfo();
|
printCompatibilityInfo();
|
||||||
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
catch (const plasp::output::TranslatorException &e)
|
catch (const plasp::TranslatorException &e)
|
||||||
{
|
{
|
||||||
logger.log(plasp::output::Priority::Error, e.what());
|
logger.log(colorlog::Priority::Error, e.what());
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
logger.log(plasp::output::Priority::Error, e.what());
|
logger.log(colorlog::Priority::Error, e.what());
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef __PLASP__LANGUAGE_DETECTION_H
|
#ifndef __PLASP__LANGUAGE_DETECTION_H
|
||||||
#define __PLASP__LANGUAGE_DETECTION_H
|
#define __PLASP__LANGUAGE_DETECTION_H
|
||||||
|
|
||||||
#include <plasp/Language.h>
|
|
||||||
|
|
||||||
#include <tokenize/Tokenizer.h>
|
#include <tokenize/Tokenizer.h>
|
||||||
|
|
||||||
|
#include <plasp/Language.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
#ifndef __PLASP__OUTPUT__TRANSLATOR_EXCEPTION_H
|
#ifndef __PLASP__TRANSLATOR_EXCEPTION_H
|
||||||
#define __PLASP__OUTPUT__TRANSLATOR_EXCEPTION_H
|
#define __PLASP__TRANSLATOR_EXCEPTION_H
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace output
|
|
||||||
{
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -50,7 +48,6 @@ class TranslatorException: public std::exception
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __PLASP__PDDL__TRANSLATOR_ASP_H
|
#ifndef __PLASP__PDDL__TRANSLATOR_ASP_H
|
||||||
#define __PLASP__PDDL__TRANSLATOR_ASP_H
|
#define __PLASP__PDDL__TRANSLATOR_ASP_H
|
||||||
|
|
||||||
#include <plasp/output/ColorStream.h>
|
#include <colorlog/ColorStream.h>
|
||||||
|
|
||||||
#include <pddlparse/ASTForward.h>
|
#include <pddlparse/ASTForward.h>
|
||||||
#include <pddlparse/Parse.h>
|
#include <pddlparse/Parse.h>
|
||||||
|
@ -20,7 +20,7 @@ namespace pddl
|
||||||
class TranslatorASP
|
class TranslatorASP
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit TranslatorASP(const ::pddl::ast::Description &description, output::ColorStream &outputStream);
|
explicit TranslatorASP(const ::pddl::ast::Description &description, colorlog::ColorStream &outputStream);
|
||||||
|
|
||||||
void translate() const;
|
void translate() const;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class TranslatorASP
|
||||||
void translateConstants(const std::string &heading, const ::pddl::ast::ConstantDeclarations &constants) const;
|
void translateConstants(const std::string &heading, const ::pddl::ast::ConstantDeclarations &constants) const;
|
||||||
|
|
||||||
const ::pddl::ast::Description &m_description;
|
const ::pddl::ast::Description &m_description;
|
||||||
output::ColorStream &m_outputStream;
|
colorlog::ColorStream &m_outputStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
#ifndef __PLASP__PDDL__TRANSLATION__EFFECT_H
|
#ifndef __PLASP__PDDL__TRANSLATION__EFFECT_H
|
||||||
#define __PLASP__PDDL__TRANSLATION__EFFECT_H
|
#define __PLASP__PDDL__TRANSLATION__EFFECT_H
|
||||||
|
|
||||||
|
#include <colorlog/Formatting.h>
|
||||||
|
|
||||||
#include <pddlparse/AST.h>
|
#include <pddlparse/AST.h>
|
||||||
|
|
||||||
#include <plasp/output/Formatting.h>
|
#include <plasp/TranslatorException.h>
|
||||||
#include <plasp/output/TranslatorException.h>
|
|
||||||
|
|
||||||
#include <plasp/pddl/translation/Predicate.h>
|
#include <plasp/pddl/translation/Predicate.h>
|
||||||
#include <plasp/pddl/translation/Primitives.h>
|
#include <plasp/pddl/translation/Primitives.h>
|
||||||
|
@ -21,25 +22,25 @@ namespace pddl
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<typename PrintObjectName>
|
template<typename PrintObjectName>
|
||||||
inline void translateEffect(output::ColorStream &outputStream, const ::pddl::ast::Effect &effect, const std::string &objectType, PrintObjectName printObjectName)
|
inline void translateEffect(colorlog::ColorStream &outputStream, const ::pddl::ast::Effect &effect, const std::string &objectType, PrintObjectName printObjectName)
|
||||||
{
|
{
|
||||||
const auto handleUnsupported =
|
const auto handleUnsupported =
|
||||||
[](const auto &)
|
[](const auto &)
|
||||||
{
|
{
|
||||||
throw output::TranslatorException("only “and” expressions and (negated) predicates supported as action effects currently");
|
throw TranslatorException("only “and” expressions and (negated) predicates supported as action effects currently");
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto handlePredicate =
|
const auto handlePredicate =
|
||||||
[&](const ::pddl::ast::PredicatePointer &predicate, bool isPositive = true)
|
[&](const ::pddl::ast::PredicatePointer &predicate, bool isPositive = true)
|
||||||
{
|
{
|
||||||
outputStream << std::endl << output::Function("postcondition") << "(";
|
outputStream << std::endl << colorlog::Function("postcondition") << "(";
|
||||||
printObjectName();
|
printObjectName();
|
||||||
outputStream
|
outputStream
|
||||||
<< ", " << output::Keyword("effect") << "("
|
<< ", " << colorlog::Keyword("effect") << "("
|
||||||
<< output::Reserved("unconditional") << ")"
|
<< colorlog::Reserved("unconditional") << ")"
|
||||||
<< ", ";
|
<< ", ";
|
||||||
translatePredicateToVariable(outputStream, *predicate, isPositive);
|
translatePredicateToVariable(outputStream, *predicate, isPositive);
|
||||||
outputStream << ") :- " << output::Function(objectType.c_str()) << "(";
|
outputStream << ") :- " << colorlog::Function(objectType.c_str()) << "(";
|
||||||
printObjectName();
|
printObjectName();
|
||||||
outputStream << ").";
|
outputStream << ").";
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
#ifndef __PLASP__PDDL__TRANSLATION__GOAL_H
|
#ifndef __PLASP__PDDL__TRANSLATION__GOAL_H
|
||||||
#define __PLASP__PDDL__TRANSLATION__GOAL_H
|
#define __PLASP__PDDL__TRANSLATION__GOAL_H
|
||||||
|
|
||||||
|
#include <colorlog/Formatting.h>
|
||||||
|
|
||||||
#include <pddlparse/AST.h>
|
#include <pddlparse/AST.h>
|
||||||
|
|
||||||
#include <plasp/output/Formatting.h>
|
#include <plasp/TranslatorException.h>
|
||||||
#include <plasp/output/TranslatorException.h>
|
|
||||||
|
|
||||||
#include <plasp/pddl/translation/Predicate.h>
|
#include <plasp/pddl/translation/Predicate.h>
|
||||||
#include <plasp/pddl/translation/Primitives.h>
|
#include <plasp/pddl/translation/Primitives.h>
|
||||||
|
@ -20,18 +21,18 @@ namespace pddl
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
inline void translateGoal(output::ColorStream &outputStream, const ::pddl::ast::Goal &goal)
|
inline void translateGoal(colorlog::ColorStream &outputStream, const ::pddl::ast::Goal &goal)
|
||||||
{
|
{
|
||||||
const auto handleUnsupported =
|
const auto handleUnsupported =
|
||||||
[](const auto &)
|
[](const auto &)
|
||||||
{
|
{
|
||||||
throw output::TranslatorException("only “and” expressions and (negated) predicates supported as goals currently");
|
throw TranslatorException("only “and” expressions and (negated) predicates supported as goals currently");
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto handlePredicate =
|
const auto handlePredicate =
|
||||||
[&](const ::pddl::ast::PredicatePointer &predicate, bool isPositive = true)
|
[&](const ::pddl::ast::PredicatePointer &predicate, bool isPositive = true)
|
||||||
{
|
{
|
||||||
outputStream << std::endl << output::Function("goal") << "(";
|
outputStream << std::endl << colorlog::Function("goal") << "(";
|
||||||
// TODO: assert that goal is variable-free
|
// TODO: assert that goal is variable-free
|
||||||
translatePredicateToVariable(outputStream, *predicate, isPositive);
|
translatePredicateToVariable(outputStream, *predicate, isPositive);
|
||||||
outputStream << ").";
|
outputStream << ").";
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
#ifndef __PLASP__PDDL__TRANSLATION__PRECONDITION_H
|
#ifndef __PLASP__PDDL__TRANSLATION__PRECONDITION_H
|
||||||
#define __PLASP__PDDL__TRANSLATION__PRECONDITION_H
|
#define __PLASP__PDDL__TRANSLATION__PRECONDITION_H
|
||||||
|
|
||||||
|
#include <colorlog/Formatting.h>
|
||||||
|
|
||||||
#include <pddlparse/AST.h>
|
#include <pddlparse/AST.h>
|
||||||
|
|
||||||
#include <plasp/output/Formatting.h>
|
#include <plasp/TranslatorException.h>
|
||||||
#include <plasp/output/TranslatorException.h>
|
|
||||||
|
|
||||||
#include <plasp/pddl/translation/Predicate.h>
|
#include <plasp/pddl/translation/Predicate.h>
|
||||||
#include <plasp/pddl/translation/Primitives.h>
|
#include <plasp/pddl/translation/Primitives.h>
|
||||||
|
@ -21,22 +22,22 @@ namespace pddl
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<typename PrintObjectName>
|
template<typename PrintObjectName>
|
||||||
inline void translatePrecondition(output::ColorStream &outputStream, const ::pddl::ast::Precondition &precondition, const std::string &objectType, PrintObjectName printObjectName)
|
inline void translatePrecondition(colorlog::ColorStream &outputStream, const ::pddl::ast::Precondition &precondition, const std::string &objectType, PrintObjectName printObjectName)
|
||||||
{
|
{
|
||||||
const auto handleUnsupported =
|
const auto handleUnsupported =
|
||||||
[](const auto &)
|
[](const auto &)
|
||||||
{
|
{
|
||||||
throw output::TranslatorException("only “and” expressions and (negated) predicates supported as action preconditions currently");
|
throw TranslatorException("only “and” expressions and (negated) predicates supported as action preconditions currently");
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto handlePredicate =
|
const auto handlePredicate =
|
||||||
[&](const ::pddl::ast::PredicatePointer &predicate, bool isPositive = true)
|
[&](const ::pddl::ast::PredicatePointer &predicate, bool isPositive = true)
|
||||||
{
|
{
|
||||||
outputStream << std::endl << output::Function("precondition") << "(";
|
outputStream << std::endl << colorlog::Function("precondition") << "(";
|
||||||
printObjectName();
|
printObjectName();
|
||||||
outputStream << ", ";
|
outputStream << ", ";
|
||||||
translatePredicateToVariable(outputStream, *predicate, isPositive);
|
translatePredicateToVariable(outputStream, *predicate, isPositive);
|
||||||
outputStream << ") :- " << output::Function(objectType.c_str()) << "(";
|
outputStream << ") :- " << colorlog::Function(objectType.c_str()) << "(";
|
||||||
printObjectName();
|
printObjectName();
|
||||||
outputStream << ").";
|
outputStream << ").";
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#ifndef __PLASP__PDDL__TRANSLATION__PREDICATE_H
|
#ifndef __PLASP__PDDL__TRANSLATION__PREDICATE_H
|
||||||
#define __PLASP__PDDL__TRANSLATION__PREDICATE_H
|
#define __PLASP__PDDL__TRANSLATION__PREDICATE_H
|
||||||
|
|
||||||
|
#include <colorlog/Formatting.h>
|
||||||
|
|
||||||
#include <pddlparse/AST.h>
|
#include <pddlparse/AST.h>
|
||||||
#include <pddlparse/Parse.h>
|
#include <pddlparse/Parse.h>
|
||||||
|
|
||||||
#include <plasp/output/Formatting.h>
|
|
||||||
|
|
||||||
#include <plasp/pddl/translation/Primitives.h>
|
#include <plasp/pddl/translation/Primitives.h>
|
||||||
#include <plasp/pddl/translation/Variables.h>
|
#include <plasp/pddl/translation/Variables.h>
|
||||||
|
|
||||||
|
@ -20,12 +20,12 @@ namespace pddl
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void translatePredicate(output::ColorStream &outputStream, const ::pddl::ast::Predicate &predicate);
|
void translatePredicate(colorlog::ColorStream &outputStream, const ::pddl::ast::Predicate &predicate);
|
||||||
void translatePredicateDeclaration(output::ColorStream &outputStream, const ::pddl::ast::PredicateDeclaration &predicateDeclaration);
|
void translatePredicateDeclaration(colorlog::ColorStream &outputStream, const ::pddl::ast::PredicateDeclaration &predicateDeclaration);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
inline void translatePredicate(output::ColorStream &outputStream, const ::pddl::ast::Predicate &predicate)
|
inline void translatePredicate(colorlog::ColorStream &outputStream, const ::pddl::ast::Predicate &predicate)
|
||||||
{
|
{
|
||||||
const auto &arguments = predicate.arguments;
|
const auto &arguments = predicate.arguments;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ inline void translatePredicate(output::ColorStream &outputStream, const ::pddl::
|
||||||
const auto handleConstant =
|
const auto handleConstant =
|
||||||
[&](const ::pddl::ast::ConstantPointer &constant)
|
[&](const ::pddl::ast::ConstantPointer &constant)
|
||||||
{
|
{
|
||||||
outputStream << output::Keyword("constant") << "(" << *constant << ")";
|
outputStream << colorlog::Keyword("constant") << "(" << *constant << ")";
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto handleVariable =
|
const auto handleVariable =
|
||||||
|
@ -56,7 +56,7 @@ inline void translatePredicate(output::ColorStream &outputStream, const ::pddl::
|
||||||
const auto handleUnsupported =
|
const auto handleUnsupported =
|
||||||
[&](const auto &)
|
[&](const auto &)
|
||||||
{
|
{
|
||||||
throw output::TranslatorException("only variables and constants supported in predicates currently");
|
throw TranslatorException("only variables and constants supported in predicates currently");
|
||||||
};
|
};
|
||||||
|
|
||||||
argument.match(handleConstant, handleVariable, handleUnsupported);
|
argument.match(handleConstant, handleVariable, handleUnsupported);
|
||||||
|
@ -67,9 +67,9 @@ inline void translatePredicate(output::ColorStream &outputStream, const ::pddl::
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
inline void translatePredicateDeclaration(output::ColorStream &outputStream, const ::pddl::ast::PredicateDeclaration &predicateDeclaration)
|
inline void translatePredicateDeclaration(colorlog::ColorStream &outputStream, const ::pddl::ast::PredicateDeclaration &predicateDeclaration)
|
||||||
{
|
{
|
||||||
outputStream << output::Keyword("variable") << "(";
|
outputStream << colorlog::Keyword("variable") << "(";
|
||||||
|
|
||||||
if (predicateDeclaration.parameters.empty())
|
if (predicateDeclaration.parameters.empty())
|
||||||
{
|
{
|
||||||
|
@ -84,18 +84,18 @@ inline void translatePredicateDeclaration(output::ColorStream &outputStream, con
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void translatePredicateToVariable(output::ColorStream &outputStream, const ::pddl::ast::Predicate &predicate, bool isPositive = true)
|
void translatePredicateToVariable(colorlog::ColorStream &outputStream, const ::pddl::ast::Predicate &predicate, bool isPositive = true)
|
||||||
{
|
{
|
||||||
outputStream << output::Keyword("variable") << "(";
|
outputStream << colorlog::Keyword("variable") << "(";
|
||||||
translatePredicate(outputStream, predicate);
|
translatePredicate(outputStream, predicate);
|
||||||
outputStream << "), " << output::Keyword("value") << "(";
|
outputStream << "), " << colorlog::Keyword("value") << "(";
|
||||||
translatePredicate(outputStream, predicate);
|
translatePredicate(outputStream, predicate);
|
||||||
outputStream << ", ";
|
outputStream << ", ";
|
||||||
|
|
||||||
if (isPositive)
|
if (isPositive)
|
||||||
outputStream << output::Boolean("true");
|
outputStream << colorlog::Boolean("true");
|
||||||
else
|
else
|
||||||
outputStream << output::Boolean("false");
|
outputStream << colorlog::Boolean("false");
|
||||||
|
|
||||||
outputStream << ")";
|
outputStream << ")";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
#ifndef __PLASP__PDDL__TRANSLATION__PRIMITIVES_H
|
#ifndef __PLASP__PDDL__TRANSLATION__PRIMITIVES_H
|
||||||
#define __PLASP__PDDL__TRANSLATION__PRIMITIVES_H
|
#define __PLASP__PDDL__TRANSLATION__PRIMITIVES_H
|
||||||
|
|
||||||
|
#include <colorlog/Formatting.h>
|
||||||
|
|
||||||
#include <pddlparse/AST.h>
|
#include <pddlparse/AST.h>
|
||||||
|
|
||||||
#include <plasp/output/Formatting.h>
|
#include <plasp/TranslatorException.h>
|
||||||
#include <plasp/output/TranslatorException.h>
|
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
|
@ -17,16 +18,16 @@ namespace pddl
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
inline output::ColorStream &operator<<(output::ColorStream &stream, const ::pddl::ast::ConstantDeclaration &constantDeclaration)
|
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const ::pddl::ast::ConstantDeclaration &constantDeclaration)
|
||||||
{
|
{
|
||||||
assert(!constantDeclaration.name.empty());
|
assert(!constantDeclaration.name.empty());
|
||||||
|
|
||||||
return (stream << output::String(constantDeclaration.name.c_str()));
|
return (stream << colorlog::String(constantDeclaration.name.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
inline output::ColorStream &operator<<(output::ColorStream &stream, const ::pddl::ast::Constant &constant)
|
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const ::pddl::ast::Constant &constant)
|
||||||
{
|
{
|
||||||
assert(constant.declaration != nullptr);
|
assert(constant.declaration != nullptr);
|
||||||
|
|
||||||
|
@ -35,16 +36,16 @@ inline output::ColorStream &operator<<(output::ColorStream &stream, const ::pddl
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
inline output::ColorStream &operator<<(output::ColorStream &stream, const ::pddl::ast::PrimitiveTypeDeclaration &primitiveTypeDeclaration)
|
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const ::pddl::ast::PrimitiveTypeDeclaration &primitiveTypeDeclaration)
|
||||||
{
|
{
|
||||||
assert(!primitiveTypeDeclaration.name.empty());
|
assert(!primitiveTypeDeclaration.name.empty());
|
||||||
|
|
||||||
return (stream << output::String(primitiveTypeDeclaration.name.c_str()));
|
return (stream << colorlog::String(primitiveTypeDeclaration.name.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
inline output::ColorStream &operator<<(output::ColorStream &stream, const ::pddl::ast::PrimitiveType &primitiveType)
|
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const ::pddl::ast::PrimitiveType &primitiveType)
|
||||||
{
|
{
|
||||||
assert(primitiveType.declaration != nullptr);
|
assert(primitiveType.declaration != nullptr);
|
||||||
|
|
||||||
|
@ -53,7 +54,7 @@ inline output::ColorStream &operator<<(output::ColorStream &stream, const ::pddl
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
inline output::ColorStream &operator<<(output::ColorStream &stream, ::pddl::ast::VariableDeclaration &variableDeclaration)
|
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, ::pddl::ast::VariableDeclaration &variableDeclaration)
|
||||||
{
|
{
|
||||||
assert(!variableDeclaration.name.empty());
|
assert(!variableDeclaration.name.empty());
|
||||||
assert(std::isalpha(variableDeclaration.name[0]));
|
assert(std::isalpha(variableDeclaration.name[0]));
|
||||||
|
@ -62,14 +63,14 @@ inline output::ColorStream &operator<<(output::ColorStream &stream, ::pddl::ast:
|
||||||
variableDeclaration.name[0] = std::toupper(variableDeclaration.name[0]);
|
variableDeclaration.name[0] = std::toupper(variableDeclaration.name[0]);
|
||||||
|
|
||||||
return (stream
|
return (stream
|
||||||
<< output::Format({output::Color::Green, output::FontWeight::Bold})
|
<< colorlog::Format({colorlog::Color::Green, colorlog::FontWeight::Bold})
|
||||||
<< variableDeclaration.name
|
<< variableDeclaration.name
|
||||||
<< output::ResetFormat());
|
<< colorlog::ResetFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
inline output::ColorStream &operator<<(output::ColorStream &stream, ::pddl::ast::Variable &variable)
|
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, ::pddl::ast::Variable &variable)
|
||||||
{
|
{
|
||||||
assert(variable.declaration != nullptr);
|
assert(variable.declaration != nullptr);
|
||||||
|
|
||||||
|
@ -79,23 +80,23 @@ inline output::ColorStream &operator<<(output::ColorStream &stream, ::pddl::ast:
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// TODO: move to appropriate header
|
// TODO: move to appropriate header
|
||||||
inline output::ColorStream &operator<<(output::ColorStream &stream, const ::pddl::ast::Action &action)
|
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const ::pddl::ast::Action &action)
|
||||||
{
|
{
|
||||||
return (stream << output::String(action.name.c_str()));
|
return (stream << colorlog::String(action.name.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// TODO: move to appropriate header
|
// TODO: move to appropriate header
|
||||||
inline output::ColorStream &operator<<(output::ColorStream &stream, const ::pddl::ast::PredicateDeclaration &predicateDeclaration)
|
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const ::pddl::ast::PredicateDeclaration &predicateDeclaration)
|
||||||
{
|
{
|
||||||
return (stream << output::String(predicateDeclaration.name.c_str()));
|
return (stream << colorlog::String(predicateDeclaration.name.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// TODO: move to appropriate header
|
// TODO: move to appropriate header
|
||||||
inline output::ColorStream &operator<<(output::ColorStream &stream, const ::pddl::ast::Predicate &predicate)
|
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const ::pddl::ast::Predicate &predicate)
|
||||||
{
|
{
|
||||||
return (stream << *predicate.declaration);
|
return (stream << *predicate.declaration);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#ifndef __PLASP__PDDL__TRANSLATION__VARIABLES_H
|
#ifndef __PLASP__PDDL__TRANSLATION__VARIABLES_H
|
||||||
#define __PLASP__PDDL__TRANSLATION__VARIABLES_H
|
#define __PLASP__PDDL__TRANSLATION__VARIABLES_H
|
||||||
|
|
||||||
|
#include <colorlog/Formatting.h>
|
||||||
|
|
||||||
#include <pddlparse/AST.h>
|
#include <pddlparse/AST.h>
|
||||||
#include <pddlparse/Parse.h>
|
#include <pddlparse/Parse.h>
|
||||||
|
|
||||||
#include <plasp/output/Formatting.h>
|
#include <plasp/TranslatorException.h>
|
||||||
#include <plasp/output/TranslatorException.h>
|
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
|
@ -19,14 +20,14 @@ namespace pddl
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void translateVariablesForRuleHead(output::ColorStream &outputStream, const T &variables);
|
void translateVariablesForRuleHead(colorlog::ColorStream &outputStream, const T &variables);
|
||||||
template<class T>
|
template<class T>
|
||||||
void translateVariablesForRuleBody(output::ColorStream &outputStream, const T &variables);
|
void translateVariablesForRuleBody(colorlog::ColorStream &outputStream, const T &variables);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void translateVariablesForRuleHead(output::ColorStream &outputStream, const T &variables)
|
inline void translateVariablesForRuleHead(colorlog::ColorStream &outputStream, const T &variables)
|
||||||
{
|
{
|
||||||
if (variables.empty())
|
if (variables.empty())
|
||||||
return;
|
return;
|
||||||
|
@ -38,7 +39,7 @@ inline void translateVariablesForRuleHead(output::ColorStream &outputStream, con
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void translateVariablesForRuleBody(output::ColorStream &outputStream, const T &variables)
|
inline void translateVariablesForRuleBody(colorlog::ColorStream &outputStream, const T &variables)
|
||||||
{
|
{
|
||||||
if (variables.empty())
|
if (variables.empty())
|
||||||
return;
|
return;
|
||||||
|
@ -53,18 +54,18 @@ inline void translateVariablesForRuleBody(output::ColorStream &outputStream, con
|
||||||
if (variable->type)
|
if (variable->type)
|
||||||
{
|
{
|
||||||
if (!variable->type.value().template is<::pddl::ast::PrimitiveTypePointer>())
|
if (!variable->type.value().template is<::pddl::ast::PrimitiveTypePointer>())
|
||||||
throw output::TranslatorException("only primitive types supported currently");
|
throw TranslatorException("only primitive types supported currently");
|
||||||
|
|
||||||
const auto &type = variable->type.value().template get<::pddl::ast::PrimitiveTypePointer>();
|
const auto &type = variable->type.value().template get<::pddl::ast::PrimitiveTypePointer>();
|
||||||
|
|
||||||
outputStream << output::Function("has") << "("
|
outputStream << colorlog::Function("has") << "("
|
||||||
<< *variable << ", " << output::Keyword("type") << "(" << *type << "))";
|
<< *variable << ", " << colorlog::Keyword("type") << "(" << *type << "))";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
outputStream << output::Function("has") << "("
|
outputStream << colorlog::Function("has") << "("
|
||||||
<< *variable << ", "
|
<< *variable << ", "
|
||||||
<< output::Keyword("type") << "(" << output::String("object") << "))";
|
<< colorlog::Keyword("type") << "(" << colorlog::String("object") << "))";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <tokenize/Tokenizer.h>
|
||||||
|
|
||||||
#include <plasp/sas/Value.h>
|
#include <plasp/sas/Value.h>
|
||||||
#include <plasp/sas/Variable.h>
|
#include <plasp/sas/Variable.h>
|
||||||
|
|
||||||
#include <tokenize/Tokenizer.h>
|
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <tokenize/Tokenizer.h>
|
||||||
|
|
||||||
#include <plasp/sas/AssignedVariable.h>
|
#include <plasp/sas/AssignedVariable.h>
|
||||||
#include <plasp/sas/Variable.h>
|
#include <plasp/sas/Variable.h>
|
||||||
|
|
||||||
#include <tokenize/Tokenizer.h>
|
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
|
#include <colorlog/ColorStream.h>
|
||||||
|
|
||||||
#include <plasp/sas/Description.h>
|
#include <plasp/sas/Description.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
|
@ -16,7 +18,7 @@ namespace sas
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
output::ColorStream &operator<<(output::ColorStream &ostream, const Description &description);
|
colorlog::ColorStream &operator<<(colorlog::ColorStream &ostream, const Description &description);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <tokenize/Tokenizer.h>
|
||||||
|
|
||||||
#include <plasp/sas/AxiomRule.h>
|
#include <plasp/sas/AxiomRule.h>
|
||||||
#include <plasp/sas/Goal.h>
|
#include <plasp/sas/Goal.h>
|
||||||
#include <plasp/sas/InitialState.h>
|
#include <plasp/sas/InitialState.h>
|
||||||
|
@ -13,8 +15,6 @@
|
||||||
#include <plasp/sas/Operator.h>
|
#include <plasp/sas/Operator.h>
|
||||||
#include <plasp/sas/Variable.h>
|
#include <plasp/sas/Variable.h>
|
||||||
|
|
||||||
#include <tokenize/Tokenizer.h>
|
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <tokenize/Tokenizer.h>
|
||||||
|
|
||||||
#include <plasp/sas/AssignedVariable.h>
|
#include <plasp/sas/AssignedVariable.h>
|
||||||
#include <plasp/sas/Variable.h>
|
#include <plasp/sas/Variable.h>
|
||||||
|
|
||||||
#include <tokenize/Tokenizer.h>
|
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef __PLASP__SAS__GOAL_H
|
#ifndef __PLASP__SAS__GOAL_H
|
||||||
#define __PLASP__SAS__GOAL_H
|
#define __PLASP__SAS__GOAL_H
|
||||||
|
|
||||||
#include <plasp/sas/AssignedVariable.h>
|
|
||||||
|
|
||||||
#include <tokenize/Tokenizer.h>
|
#include <tokenize/Tokenizer.h>
|
||||||
|
|
||||||
|
#include <plasp/sas/AssignedVariable.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef __PLASP__SAS__INITIAL_STATE_H
|
#ifndef __PLASP__SAS__INITIAL_STATE_H
|
||||||
#define __PLASP__SAS__INITIAL_STATE_H
|
#define __PLASP__SAS__INITIAL_STATE_H
|
||||||
|
|
||||||
#include <plasp/sas/AssignedVariable.h>
|
|
||||||
|
|
||||||
#include <tokenize/Tokenizer.h>
|
#include <tokenize/Tokenizer.h>
|
||||||
|
|
||||||
|
#include <plasp/sas/AssignedVariable.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <plasp/sas/AssignedVariable.h>
|
|
||||||
|
|
||||||
#include <tokenize/Tokenizer.h>
|
#include <tokenize/Tokenizer.h>
|
||||||
|
|
||||||
|
#include <plasp/sas/AssignedVariable.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
|
|
|
@ -4,13 +4,15 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <plasp/output/ColorStream.h>
|
#include <tokenize/Tokenizer.h>
|
||||||
|
|
||||||
|
#include <colorlog/ColorStream.h>
|
||||||
|
|
||||||
#include <plasp/sas/AssignedVariable.h>
|
#include <plasp/sas/AssignedVariable.h>
|
||||||
#include <plasp/sas/Effect.h>
|
#include <plasp/sas/Effect.h>
|
||||||
#include <plasp/sas/Predicate.h>
|
#include <plasp/sas/Predicate.h>
|
||||||
#include <plasp/sas/Variable.h>
|
#include <plasp/sas/Variable.h>
|
||||||
|
|
||||||
#include <tokenize/Tokenizer.h>
|
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
|
@ -37,7 +39,7 @@ class Operator
|
||||||
static Operator fromSAS(tokenize::Tokenizer<> &tokenizer, const Variables &variables);
|
static Operator fromSAS(tokenize::Tokenizer<> &tokenizer, const Variables &variables);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void printPredicateAsASP(output::ColorStream &stream) const;
|
void printPredicateAsASP(colorlog::ColorStream &stream) const;
|
||||||
|
|
||||||
const Predicate &predicate() const;
|
const Predicate &predicate() const;
|
||||||
const Conditions &preconditions() const;
|
const Conditions &preconditions() const;
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <plasp/output/ColorStream.h>
|
|
||||||
|
|
||||||
#include <tokenize/Tokenizer.h>
|
#include <tokenize/Tokenizer.h>
|
||||||
|
|
||||||
|
#include <colorlog/ColorStream.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
|
@ -28,8 +28,8 @@ class Predicate
|
||||||
using Arguments = std::vector<std::string>;
|
using Arguments = std::vector<std::string>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void printAsSAS(output::ColorStream &stream) const;
|
void printAsSAS(colorlog::ColorStream &stream) const;
|
||||||
void printAsASP(output::ColorStream &stream) const;
|
void printAsASP(colorlog::ColorStream &stream) const;
|
||||||
|
|
||||||
const std::string &name() const;
|
const std::string &name() const;
|
||||||
const Arguments &arguments() const;
|
const Arguments &arguments() const;
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
#include <plasp/output/ColorStream.h>
|
#include <colorlog/ColorStream.h>
|
||||||
|
|
||||||
#include <plasp/sas/Description.h>
|
#include <plasp/sas/Description.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
|
@ -20,7 +21,7 @@ namespace sas
|
||||||
class TranslatorASP
|
class TranslatorASP
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit TranslatorASP(const Description &description, output::ColorStream &outputStream);
|
explicit TranslatorASP(const Description &description, colorlog::ColorStream &outputStream);
|
||||||
|
|
||||||
void translate() const;
|
void translate() const;
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ class TranslatorASP
|
||||||
void translateAxiomRules() const;
|
void translateAxiomRules() const;
|
||||||
|
|
||||||
const Description &m_description;
|
const Description &m_description;
|
||||||
output::ColorStream &m_outputStream;
|
colorlog::ColorStream &m_outputStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <plasp/output/ColorStream.h>
|
|
||||||
|
|
||||||
#include <tokenize/Tokenizer.h>
|
#include <tokenize/Tokenizer.h>
|
||||||
|
|
||||||
|
#include <colorlog/ColorStream.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
|
@ -46,8 +46,8 @@ struct Value
|
||||||
public:
|
public:
|
||||||
Value negated() const;
|
Value negated() const;
|
||||||
|
|
||||||
void printAsSAS(output::ColorStream &stream) const;
|
void printAsSAS(colorlog::ColorStream &stream) const;
|
||||||
void printAsASPPredicate(output::ColorStream &stream) const;
|
void printAsASPPredicate(colorlog::ColorStream &stream) const;
|
||||||
|
|
||||||
Sign sign() const;
|
Sign sign() const;
|
||||||
const std::string &name() const;
|
const std::string &name() const;
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <plasp/output/ColorStream.h>
|
|
||||||
#include <plasp/sas/Value.h>
|
|
||||||
|
|
||||||
#include <tokenize/Tokenizer.h>
|
#include <tokenize/Tokenizer.h>
|
||||||
|
|
||||||
|
#include <colorlog/ColorStream.h>
|
||||||
|
|
||||||
|
#include <plasp/sas/Value.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
|
@ -33,7 +34,7 @@ class Variable
|
||||||
static const Variable &referenceFromSAS(tokenize::Tokenizer<> &tokenizer, const Variables &variables);
|
static const Variable &referenceFromSAS(tokenize::Tokenizer<> &tokenizer, const Variables &variables);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void printNameAsASPPredicate(output::ColorStream &outputStream) const;
|
void printNameAsASPPredicate(colorlog::ColorStream &outputStream) const;
|
||||||
|
|
||||||
const std::string &name() const;
|
const std::string &name() const;
|
||||||
int axiomLayer() const;
|
int axiomLayer() const;
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
|
#include <tokenize/Tokenizer.h>
|
||||||
|
|
||||||
#include <plasp/sas/Value.h>
|
#include <plasp/sas/Value.h>
|
||||||
#include <plasp/sas/Variable.h>
|
#include <plasp/sas/Variable.h>
|
||||||
|
|
||||||
#include <tokenize/Tokenizer.h>
|
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
project(colorlog)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -Werror ${CMAKE_CXX_FLAGS}")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-g ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
|
||||||
|
if (CMAKE_GENERATOR STREQUAL "Ninja" AND
|
||||||
|
((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) OR
|
||||||
|
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)))
|
||||||
|
# Force colored warnings in Ninja's output, if the compiler has -fdiagnostics-color support.
|
||||||
|
# Rationale in https://github.com/ninja-build/ninja/issues/814
|
||||||
|
set(CMAKE_CXX_FLAGS "-fdiagnostics-color=always ${CMAKE_CXX_FLAGS}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
|
@ -1,12 +1,10 @@
|
||||||
#ifndef __PLASP__OUTPUT__COLOR_STREAM_H
|
#ifndef __COLOR_LOG__COLOR_STREAM_H
|
||||||
#define __PLASP__OUTPUT__COLOR_STREAM_H
|
#define __COLOR_LOG__COLOR_STREAM_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace colorlog
|
||||||
{
|
|
||||||
namespace output
|
|
||||||
{
|
{
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -288,7 +286,6 @@ ColorStream &ColorStream::operator<<(unsigned char value)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,13 +1,11 @@
|
||||||
#ifndef __PLASP__OUTPUT__FORMATTING_H
|
#ifndef __COLOR_LOG__FORMATTING_H
|
||||||
#define __PLASP__OUTPUT__FORMATTING_H
|
#define __COLOR_LOG__FORMATTING_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <plasp/output/ColorStream.h>
|
#include <colorlog/ColorStream.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace colorlog
|
||||||
{
|
|
||||||
namespace output
|
|
||||||
{
|
{
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -307,7 +305,6 @@ inline ColorStream &operator<<(ColorStream &stream, const Heading2 &heading2)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,16 +1,14 @@
|
||||||
#ifndef __PLASP__OUTPUT__LOGGER_H
|
#ifndef __COLOR_LOG__LOGGER_H
|
||||||
#define __PLASP__OUTPUT__LOGGER_H
|
#define __COLOR_LOG__LOGGER_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <plasp/output/ColorStream.h>
|
#include <colorlog/ColorStream.h>
|
||||||
#include <plasp/output/Priority.h>
|
#include <colorlog/Priority.h>
|
||||||
|
|
||||||
#include <tokenize/Location.h>
|
#include <tokenize/Location.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace colorlog
|
||||||
{
|
|
||||||
namespace output
|
|
||||||
{
|
{
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -50,7 +48,6 @@ class Logger
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,12 +1,10 @@
|
||||||
#ifndef __PLASP__OUTPUT__PRIORITY_H
|
#ifndef __COLOR_LOG__PRIORITY_H
|
||||||
#define __PLASP__OUTPUT__PRIORITY_H
|
#define __COLOR_LOG__PRIORITY_H
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
namespace plasp
|
namespace colorlog
|
||||||
{
|
|
||||||
namespace output
|
|
||||||
{
|
{
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -60,7 +58,6 @@ inline Priority priorityFromName(const char *priorityName)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -0,0 +1,21 @@
|
||||||
|
set(target colorlog)
|
||||||
|
|
||||||
|
file(GLOB core_sources "colorlog/*.cpp")
|
||||||
|
file(GLOB core_headers "../include/colorlog/*.h")
|
||||||
|
|
||||||
|
set(includes
|
||||||
|
${PROJECT_SOURCE_DIR}/include
|
||||||
|
${PROJECT_SOURCE_DIR}/../../lib/tokenize/include
|
||||||
|
)
|
||||||
|
|
||||||
|
set(sources
|
||||||
|
${core_sources}
|
||||||
|
${core_headers}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(libraries
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(${target} ${sources})
|
||||||
|
target_include_directories(${target} PRIVATE ${includes})
|
||||||
|
target_link_libraries(${target} ${libraries})
|
|
@ -1,10 +1,8 @@
|
||||||
#include <plasp/output/Logger.h>
|
#include <colorlog/Logger.h>
|
||||||
|
|
||||||
#include <plasp/output/Formatting.h>
|
#include <colorlog/Formatting.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace colorlog
|
||||||
{
|
|
||||||
namespace output
|
|
||||||
{
|
{
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -165,4 +163,3 @@ void Logger::log(Priority priority, const tokenize::Location &location, const st
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
|
@ -6,28 +6,17 @@ file(GLOB core_headers "../include/plasp/*.h")
|
||||||
file(GLOB pddl_sources "plasp/pddl/*.cpp")
|
file(GLOB pddl_sources "plasp/pddl/*.cpp")
|
||||||
file(GLOB pddl_headers "../include/plasp/pddl/*.h")
|
file(GLOB pddl_headers "../include/plasp/pddl/*.h")
|
||||||
|
|
||||||
file(GLOB pddl_expressions_sources "plasp/pddl/expressions/*.cpp")
|
|
||||||
file(GLOB pddl_expressions_headers "../include/plasp/pddl/expressions/*.h")
|
|
||||||
|
|
||||||
file(GLOB pddl_translation_sources "plasp/pddl/translation/*.cpp")
|
file(GLOB pddl_translation_sources "plasp/pddl/translation/*.cpp")
|
||||||
file(GLOB pddl_translation_headers "../include/plasp/pddl/translation/*.h")
|
file(GLOB pddl_translation_headers "../include/plasp/pddl/translation/*.h")
|
||||||
|
|
||||||
file(GLOB sas_sources "plasp/sas/*.cpp")
|
file(GLOB sas_sources "plasp/sas/*.cpp")
|
||||||
file(GLOB sas_headers "../include/plasp/sas/*.h")
|
file(GLOB sas_headers "../include/plasp/sas/*.h")
|
||||||
|
|
||||||
file(GLOB input_sources "plasp/input/*.cpp")
|
|
||||||
file(GLOB input_headers "../include/plasp/input/*.h")
|
|
||||||
|
|
||||||
file(GLOB output_sources "plasp/output/*.cpp")
|
|
||||||
file(GLOB output_headers "../include/plasp/output/*.h")
|
|
||||||
|
|
||||||
file(GLOB utils_sources "plasp/utils/*.cpp")
|
|
||||||
file(GLOB utils_headers "../include/plasp/utils/*.h")
|
|
||||||
|
|
||||||
set(includes
|
set(includes
|
||||||
${Boost_INCLUDE_DIRS}
|
${Boost_INCLUDE_DIRS}
|
||||||
${PROJECT_SOURCE_DIR}/include
|
${PROJECT_SOURCE_DIR}/include
|
||||||
${PROJECT_SOURCE_DIR}/lib/tokenize/include
|
${PROJECT_SOURCE_DIR}/lib/tokenize/include
|
||||||
|
${PROJECT_SOURCE_DIR}/lib/colorlog/include
|
||||||
${PROJECT_SOURCE_DIR}/lib/variant/include
|
${PROJECT_SOURCE_DIR}/lib/variant/include
|
||||||
${PROJECT_SOURCE_DIR}/lib/pddlparse/include
|
${PROJECT_SOURCE_DIR}/lib/pddlparse/include
|
||||||
)
|
)
|
||||||
|
@ -60,6 +49,7 @@ set(sources
|
||||||
|
|
||||||
set(libraries
|
set(libraries
|
||||||
${Boost_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
|
colorlog
|
||||||
pddlparse
|
pddlparse
|
||||||
pthread
|
pthread
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
|
#include <colorlog/Formatting.h>
|
||||||
|
|
||||||
#include <pddlparse/AST.h>
|
#include <pddlparse/AST.h>
|
||||||
|
|
||||||
#include <plasp/output/Formatting.h>
|
#include <plasp/TranslatorException.h>
|
||||||
#include <plasp/output/TranslatorException.h>
|
|
||||||
|
|
||||||
#include <plasp/pddl/translation/Effect.h>
|
#include <plasp/pddl/translation/Effect.h>
|
||||||
#include <plasp/pddl/translation/Goal.h>
|
#include <plasp/pddl/translation/Goal.h>
|
||||||
|
@ -25,7 +26,7 @@ namespace pddl
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TranslatorASP::TranslatorASP(const ::pddl::ast::Description &description, output::ColorStream &outputStream)
|
TranslatorASP::TranslatorASP(const ::pddl::ast::Description &description, colorlog::ColorStream &outputStream)
|
||||||
: m_description{description},
|
: m_description{description},
|
||||||
m_outputStream(outputStream)
|
m_outputStream(outputStream)
|
||||||
{
|
{
|
||||||
|
@ -48,7 +49,7 @@ void TranslatorASP::translate() const
|
||||||
|
|
||||||
void TranslatorASP::translateDomain() const
|
void TranslatorASP::translateDomain() const
|
||||||
{
|
{
|
||||||
m_outputStream << output::Heading1("domain");
|
m_outputStream << colorlog::Heading1("domain");
|
||||||
|
|
||||||
const auto &domain = m_description.domain;
|
const auto &domain = m_description.domain;
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ void TranslatorASP::translateDomain() const
|
||||||
|
|
||||||
void TranslatorASP::translateTypes() const
|
void TranslatorASP::translateTypes() const
|
||||||
{
|
{
|
||||||
m_outputStream << output::Heading2("types");
|
m_outputStream << colorlog::Heading2("types");
|
||||||
|
|
||||||
m_outputStream << std::endl;
|
m_outputStream << std::endl;
|
||||||
|
|
||||||
|
@ -91,8 +92,8 @@ void TranslatorASP::translateTypes() const
|
||||||
if (types.empty())
|
if (types.empty())
|
||||||
{
|
{
|
||||||
m_outputStream
|
m_outputStream
|
||||||
<< output::Function("type") << "("
|
<< colorlog::Function("type") << "("
|
||||||
<< output::Keyword("type") << "(" << output::String("object") << "))." << std::endl;
|
<< colorlog::Keyword("type") << "(" << colorlog::String("object") << "))." << std::endl;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -100,8 +101,8 @@ void TranslatorASP::translateTypes() const
|
||||||
for (const auto &type : types)
|
for (const auto &type : types)
|
||||||
{
|
{
|
||||||
m_outputStream
|
m_outputStream
|
||||||
<< output::Function("type") << "("
|
<< colorlog::Function("type") << "("
|
||||||
<< output::Keyword("type") << "("
|
<< colorlog::Keyword("type") << "("
|
||||||
<< *type
|
<< *type
|
||||||
<< "))." << std::endl;
|
<< "))." << std::endl;
|
||||||
|
|
||||||
|
@ -111,23 +112,23 @@ void TranslatorASP::translateTypes() const
|
||||||
[&](const auto &parentType)
|
[&](const auto &parentType)
|
||||||
{
|
{
|
||||||
m_outputStream
|
m_outputStream
|
||||||
<< output::Function("inherits") << "(" << output::Keyword("type")
|
<< colorlog::Function("inherits") << "(" << colorlog::Keyword("type")
|
||||||
<< "(" << *type << "), " << output::Keyword("type")
|
<< "(" << *type << "), " << colorlog::Keyword("type")
|
||||||
<< "(" << *parentType << "))." << std::endl;
|
<< "(" << *parentType << "))." << std::endl;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
m_outputStream
|
m_outputStream
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< output::Function("has") << "("
|
<< colorlog::Function("has") << "("
|
||||||
<< output::Variable("X") << ", "
|
<< colorlog::Variable("X") << ", "
|
||||||
<< output::Keyword("type") << "(" << output::Variable("T2") << ")) :- "
|
<< colorlog::Keyword("type") << "(" << colorlog::Variable("T2") << ")) :- "
|
||||||
<< output::Function("has") << "("
|
<< colorlog::Function("has") << "("
|
||||||
<< output::Variable("X") << ", "
|
<< colorlog::Variable("X") << ", "
|
||||||
<< output::Keyword("type") << "(" << output::Variable("T1") << ")), "
|
<< colorlog::Keyword("type") << "(" << colorlog::Variable("T1") << ")), "
|
||||||
<< output::Function("inherits") << "("
|
<< colorlog::Function("inherits") << "("
|
||||||
<< output::Keyword("type") << "(" << output::Variable("T1") << "), "
|
<< colorlog::Keyword("type") << "(" << colorlog::Variable("T1") << "), "
|
||||||
<< output::Keyword("type") << "(" << output::Variable("T2") << "))."
|
<< colorlog::Keyword("type") << "(" << colorlog::Variable("T2") << "))."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,13 +136,13 @@ void TranslatorASP::translateTypes() const
|
||||||
|
|
||||||
void TranslatorASP::translatePredicates() const
|
void TranslatorASP::translatePredicates() const
|
||||||
{
|
{
|
||||||
m_outputStream << output::Heading2("variables");
|
m_outputStream << colorlog::Heading2("variables");
|
||||||
|
|
||||||
const auto &predicates = m_description.domain->predicates;
|
const auto &predicates = m_description.domain->predicates;
|
||||||
|
|
||||||
for (const auto &predicate : predicates)
|
for (const auto &predicate : predicates)
|
||||||
{
|
{
|
||||||
m_outputStream << std::endl << output::Function("variable") << "(";
|
m_outputStream << std::endl << colorlog::Function("variable") << "(";
|
||||||
|
|
||||||
translatePredicateDeclaration(m_outputStream, *predicate);
|
translatePredicateDeclaration(m_outputStream, *predicate);
|
||||||
|
|
||||||
|
@ -154,14 +155,14 @@ void TranslatorASP::translatePredicates() const
|
||||||
|
|
||||||
m_outputStream
|
m_outputStream
|
||||||
<< std::endl << std::endl
|
<< std::endl << std::endl
|
||||||
<< output::Function("boolean") << "(" << output::Boolean("true") << ")." << std::endl
|
<< colorlog::Function("boolean") << "(" << colorlog::Boolean("true") << ")." << std::endl
|
||||||
<< output::Function("boolean") << "(" << output::Boolean("false") << ")." << std::endl
|
<< colorlog::Function("boolean") << "(" << colorlog::Boolean("false") << ")." << std::endl
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< output::Function("contains") << "("
|
<< colorlog::Function("contains") << "("
|
||||||
<< output::Keyword("variable") << "(" << output::Variable("X") << "), "
|
<< colorlog::Keyword("variable") << "(" << colorlog::Variable("X") << "), "
|
||||||
<< output::Keyword("value") << "(" << output::Variable("X") << ", " << output::Variable("B") << ")) :- "
|
<< colorlog::Keyword("value") << "(" << colorlog::Variable("X") << ", " << colorlog::Variable("B") << ")) :- "
|
||||||
<< output::Function("variable") << "(" << output::Keyword("variable") << "(" << output::Variable("X") << ")), "
|
<< colorlog::Function("variable") << "(" << colorlog::Keyword("variable") << "(" << colorlog::Variable("X") << ")), "
|
||||||
<< output::Function("boolean") << "(" << output::Variable("B") << ")."
|
<< colorlog::Function("boolean") << "(" << colorlog::Variable("B") << ")."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +170,7 @@ void TranslatorASP::translatePredicates() const
|
||||||
|
|
||||||
void TranslatorASP::translateActions() const
|
void TranslatorASP::translateActions() const
|
||||||
{
|
{
|
||||||
m_outputStream << output::Heading2("actions");
|
m_outputStream << colorlog::Heading2("actions");
|
||||||
|
|
||||||
const auto &actions = m_description.domain->actions;
|
const auto &actions = m_description.domain->actions;
|
||||||
|
|
||||||
|
@ -178,7 +179,7 @@ void TranslatorASP::translateActions() const
|
||||||
const auto printActionName =
|
const auto printActionName =
|
||||||
[&]()
|
[&]()
|
||||||
{
|
{
|
||||||
m_outputStream << output::Keyword("action") << "(";
|
m_outputStream << colorlog::Keyword("action") << "(";
|
||||||
|
|
||||||
if (action->parameters.empty())
|
if (action->parameters.empty())
|
||||||
{
|
{
|
||||||
|
@ -194,7 +195,7 @@ void TranslatorASP::translateActions() const
|
||||||
m_outputStream << std::endl;
|
m_outputStream << std::endl;
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
m_outputStream << output::Function("action") << "(";
|
m_outputStream << colorlog::Function("action") << "(";
|
||||||
printActionName();
|
printActionName();
|
||||||
m_outputStream << ")";
|
m_outputStream << ")";
|
||||||
|
|
||||||
|
@ -217,13 +218,13 @@ void TranslatorASP::translateActions() const
|
||||||
|
|
||||||
void TranslatorASP::translateConstants(const std::string &heading, const ::pddl::ast::ConstantDeclarations &constants) const
|
void TranslatorASP::translateConstants(const std::string &heading, const ::pddl::ast::ConstantDeclarations &constants) const
|
||||||
{
|
{
|
||||||
m_outputStream << output::Heading2(heading.c_str());
|
m_outputStream << colorlog::Heading2(heading.c_str());
|
||||||
|
|
||||||
for (const auto &constant : constants)
|
for (const auto &constant : constants)
|
||||||
{
|
{
|
||||||
m_outputStream << std::endl
|
m_outputStream << std::endl
|
||||||
<< output::Function("constant") << "("
|
<< colorlog::Function("constant") << "("
|
||||||
<< output::Keyword("constant") << "("
|
<< colorlog::Keyword("constant") << "("
|
||||||
<< *constant
|
<< *constant
|
||||||
<< "))." << std::endl;
|
<< "))." << std::endl;
|
||||||
|
|
||||||
|
@ -232,19 +233,19 @@ void TranslatorASP::translateConstants(const std::string &heading, const ::pddl:
|
||||||
if (type)
|
if (type)
|
||||||
{
|
{
|
||||||
if (!type.value().is<::pddl::ast::PrimitiveTypePointer>())
|
if (!type.value().is<::pddl::ast::PrimitiveTypePointer>())
|
||||||
throw output::TranslatorException("only primitive types supported currently");
|
throw TranslatorException("only primitive types supported currently");
|
||||||
|
|
||||||
const auto &primitveType = type.value().get<::pddl::ast::PrimitiveTypePointer>();
|
const auto &primitveType = type.value().get<::pddl::ast::PrimitiveTypePointer>();
|
||||||
|
|
||||||
m_outputStream << output::Function("has") << "("
|
m_outputStream << colorlog::Function("has") << "("
|
||||||
<< output::Keyword("constant") << "(" << *constant << "), "
|
<< colorlog::Keyword("constant") << "(" << *constant << "), "
|
||||||
<< output::Keyword("type") << "(" << *primitveType << "))." << std::endl;
|
<< colorlog::Keyword("type") << "(" << *primitveType << "))." << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_outputStream << output::Function("has") << "("
|
m_outputStream << colorlog::Function("has") << "("
|
||||||
<< output::Keyword("constant") << "(" << *constant << "), "
|
<< colorlog::Keyword("constant") << "(" << *constant << "), "
|
||||||
<< output::Keyword("type") << "(" << output::String("object") << "))." << std::endl;
|
<< colorlog::Keyword("type") << "(" << colorlog::String("object") << "))." << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,7 +256,7 @@ void TranslatorASP::translateProblem() const
|
||||||
{
|
{
|
||||||
assert(m_description.problem);
|
assert(m_description.problem);
|
||||||
|
|
||||||
m_outputStream << output::Heading1("problem");
|
m_outputStream << colorlog::Heading1("problem");
|
||||||
|
|
||||||
const auto &problem = m_description.problem.value();
|
const auto &problem = m_description.problem.value();
|
||||||
|
|
||||||
|
@ -284,13 +285,13 @@ void TranslatorASP::translateInitialState() const
|
||||||
{
|
{
|
||||||
assert(m_description.problem);
|
assert(m_description.problem);
|
||||||
|
|
||||||
m_outputStream << output::Heading2("initial state");
|
m_outputStream << colorlog::Heading2("initial state");
|
||||||
|
|
||||||
const auto &facts = m_description.problem.value()->initialState.facts;
|
const auto &facts = m_description.problem.value()->initialState.facts;
|
||||||
|
|
||||||
for (const auto &fact : facts)
|
for (const auto &fact : facts)
|
||||||
{
|
{
|
||||||
m_outputStream << std::endl << output::Function("initialState") << "(";
|
m_outputStream << std::endl << colorlog::Function("initialState") << "(";
|
||||||
|
|
||||||
// Translate single predicate
|
// Translate single predicate
|
||||||
if (fact.is<::pddl::ast::AtomicFormula>() && fact.get<::pddl::ast::AtomicFormula>().is<::pddl::ast::PredicatePointer>())
|
if (fact.is<::pddl::ast::AtomicFormula>() && fact.get<::pddl::ast::AtomicFormula>().is<::pddl::ast::PredicatePointer>())
|
||||||
|
@ -305,28 +306,28 @@ void TranslatorASP::translateInitialState() const
|
||||||
const auto ¬Expression = fact.get<::pddl::ast::NotPointer<::pddl::ast::Fact>>();
|
const auto ¬Expression = fact.get<::pddl::ast::NotPointer<::pddl::ast::Fact>>();
|
||||||
|
|
||||||
if (!notExpression->argument.is<::pddl::ast::AtomicFormula>() || !notExpression->argument.get<::pddl::ast::AtomicFormula>().is<::pddl::ast::PredicatePointer>())
|
if (!notExpression->argument.is<::pddl::ast::AtomicFormula>() || !notExpression->argument.get<::pddl::ast::AtomicFormula>().is<::pddl::ast::PredicatePointer>())
|
||||||
throw output::TranslatorException("only negations of simple predicates supported in initial state currently");
|
throw TranslatorException("only negations of simple predicates supported in initial state currently");
|
||||||
|
|
||||||
const auto &predicate = notExpression->argument.get<::pddl::ast::AtomicFormula>().get<::pddl::ast::PredicatePointer>();
|
const auto &predicate = notExpression->argument.get<::pddl::ast::AtomicFormula>().get<::pddl::ast::PredicatePointer>();
|
||||||
|
|
||||||
translatePredicateToVariable(m_outputStream, *predicate, false);
|
translatePredicateToVariable(m_outputStream, *predicate, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw output::TranslatorException("only predicates and their negations supported in initial state currently");
|
throw TranslatorException("only predicates and their negations supported in initial state currently");
|
||||||
|
|
||||||
m_outputStream << ").";
|
m_outputStream << ").";
|
||||||
}
|
}
|
||||||
|
|
||||||
m_outputStream
|
m_outputStream
|
||||||
<< std::endl << std::endl
|
<< std::endl << std::endl
|
||||||
<< output::Function("initialState") << "("
|
<< colorlog::Function("initialState") << "("
|
||||||
<< output::Keyword("variable") << "(" << output::Variable("X") << "), "
|
<< colorlog::Keyword("variable") << "(" << colorlog::Variable("X") << "), "
|
||||||
<< output::Keyword("value") << "(" << output::Variable("X") << ", " << output::Boolean("false") << ")) :- "
|
<< colorlog::Keyword("value") << "(" << colorlog::Variable("X") << ", " << colorlog::Boolean("false") << ")) :- "
|
||||||
<< output::Function("variable") << "(" << output::Keyword("variable") << "(" << output::Variable("X") << ")), "
|
<< colorlog::Function("variable") << "(" << colorlog::Keyword("variable") << "(" << colorlog::Variable("X") << ")), "
|
||||||
<< output::Keyword("not") << " "
|
<< colorlog::Keyword("not") << " "
|
||||||
<< output::Function("initialState") << "("
|
<< colorlog::Function("initialState") << "("
|
||||||
<< output::Keyword("variable") << "(" << output::Variable("X") << "), "
|
<< colorlog::Keyword("variable") << "(" << colorlog::Variable("X") << "), "
|
||||||
<< output::Keyword("value") << "(" << output::Variable("X") << ", " << output::Boolean("true") << "))."
|
<< colorlog::Keyword("value") << "(" << colorlog::Variable("X") << ", " << colorlog::Boolean("true") << "))."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +338,7 @@ void TranslatorASP::translateGoal() const
|
||||||
assert(m_description.problem);
|
assert(m_description.problem);
|
||||||
assert(m_description.problem.value()->goal);
|
assert(m_description.problem.value()->goal);
|
||||||
|
|
||||||
m_outputStream << output::Heading2("goal");
|
m_outputStream << colorlog::Heading2("goal");
|
||||||
|
|
||||||
const auto &goal = m_description.problem.value()->goal.value();
|
const auto &goal = m_description.problem.value()->goal.value();
|
||||||
// TODO: refactor
|
// TODO: refactor
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace sas
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
output::ColorStream &operator<<(output::ColorStream &stream, const Description &description)
|
colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const Description &description)
|
||||||
{
|
{
|
||||||
// Metric section
|
// Metric section
|
||||||
stream << "uses action costs: " << (description.usesActionCosts() ? "yes" : "no") << std::endl;
|
stream << "uses action costs: " << (description.usesActionCosts() ? "yes" : "no") << std::endl;
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include <plasp/sas/VariableTransition.h>
|
|
||||||
|
|
||||||
#include <tokenize/TokenizerException.h>
|
#include <tokenize/TokenizerException.h>
|
||||||
|
|
||||||
|
#include <plasp/sas/VariableTransition.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include <plasp/output/Formatting.h>
|
#include <colorlog/Formatting.h>
|
||||||
|
|
||||||
#include <plasp/sas/VariableTransition.h>
|
#include <plasp/sas/VariableTransition.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
|
@ -46,9 +47,9 @@ Operator Operator::fromSAS(tokenize::Tokenizer<> &tokenizer, const Variables &va
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void Operator::printPredicateAsASP(output::ColorStream &stream) const
|
void Operator::printPredicateAsASP(colorlog::ColorStream &stream) const
|
||||||
{
|
{
|
||||||
stream << output::Keyword("action") << "(";
|
stream << colorlog::Keyword("action") << "(";
|
||||||
m_predicate.printAsASP(stream);
|
m_predicate.printAsASP(stream);
|
||||||
stream << ")";
|
stream << ")";
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include <plasp/output/Formatting.h>
|
|
||||||
|
|
||||||
#include <tokenize/TokenizerException.h>
|
#include <tokenize/TokenizerException.h>
|
||||||
|
|
||||||
|
#include <colorlog/Formatting.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
|
@ -66,7 +66,7 @@ const Predicate::Arguments &Predicate::arguments() const
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void Predicate::printAsSAS(output::ColorStream &stream) const
|
void Predicate::printAsSAS(colorlog::ColorStream &stream) const
|
||||||
{
|
{
|
||||||
if (m_arguments.empty())
|
if (m_arguments.empty())
|
||||||
{
|
{
|
||||||
|
@ -84,18 +84,18 @@ void Predicate::printAsSAS(output::ColorStream &stream) const
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void Predicate::printAsASP(output::ColorStream &stream) const
|
void Predicate::printAsASP(colorlog::ColorStream &stream) const
|
||||||
{
|
{
|
||||||
if (m_arguments.empty())
|
if (m_arguments.empty())
|
||||||
{
|
{
|
||||||
stream << output::String(m_name.c_str());
|
stream << colorlog::String(m_name.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream << "(" << output::String(m_name.c_str());
|
stream << "(" << colorlog::String(m_name.c_str());
|
||||||
|
|
||||||
for (size_t i = 0; i < m_arguments.size(); i++)
|
for (size_t i = 0; i < m_arguments.size(); i++)
|
||||||
stream << ", " << output::String(m_arguments[i].c_str());
|
stream << ", " << colorlog::String(m_arguments[i].c_str());
|
||||||
|
|
||||||
stream << ")";
|
stream << ")";
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
#include <plasp/output/Formatting.h>
|
#include <colorlog/Formatting.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@ namespace sas
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TranslatorASP::TranslatorASP(const Description &description, output::ColorStream &outputStream)
|
TranslatorASP::TranslatorASP(const Description &description, colorlog::ColorStream &outputStream)
|
||||||
: m_description(description),
|
: m_description(description),
|
||||||
m_outputStream(outputStream)
|
m_outputStream(outputStream)
|
||||||
{
|
{
|
||||||
|
@ -58,30 +58,30 @@ void TranslatorASP::translate() const
|
||||||
|
|
||||||
void TranslatorASP::translateRequirements() const
|
void TranslatorASP::translateRequirements() const
|
||||||
{
|
{
|
||||||
m_outputStream << output::Heading2("feature requirements") << std::endl;
|
m_outputStream << colorlog::Heading2("feature requirements") << std::endl;
|
||||||
|
|
||||||
if (m_description.usesActionCosts())
|
if (m_description.usesActionCosts())
|
||||||
m_outputStream << output::Function("requires") << "(" << output::Keyword("feature") << "(" << output::Reserved("actionCosts") << "))." << std::endl;
|
m_outputStream << colorlog::Function("requires") << "(" << colorlog::Keyword("feature") << "(" << colorlog::Reserved("actionCosts") << "))." << std::endl;
|
||||||
|
|
||||||
if (m_description.usesAxiomRules())
|
if (m_description.usesAxiomRules())
|
||||||
m_outputStream << output::Function("requires") << "(" << output::Keyword("feature") << "(" << output::Reserved("axiomRules") << "))." << std::endl;
|
m_outputStream << colorlog::Function("requires") << "(" << colorlog::Keyword("feature") << "(" << colorlog::Reserved("axiomRules") << "))." << std::endl;
|
||||||
|
|
||||||
if (m_description.usesConditionalEffects())
|
if (m_description.usesConditionalEffects())
|
||||||
m_outputStream << output::Function("requires") << "(" << output::Keyword("feature") << "(" << output::Reserved("conditionalEffects") << "))." << std::endl;
|
m_outputStream << colorlog::Function("requires") << "(" << colorlog::Keyword("feature") << "(" << colorlog::Reserved("conditionalEffects") << "))." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void TranslatorASP::translateInitialState() const
|
void TranslatorASP::translateInitialState() const
|
||||||
{
|
{
|
||||||
m_outputStream << output::Heading2("initial state") << std::endl;
|
m_outputStream << colorlog::Heading2("initial state") << std::endl;
|
||||||
|
|
||||||
const auto &initialStateFacts = m_description.initialState().facts();
|
const auto &initialStateFacts = m_description.initialState().facts();
|
||||||
|
|
||||||
std::for_each(initialStateFacts.cbegin(), initialStateFacts.cend(),
|
std::for_each(initialStateFacts.cbegin(), initialStateFacts.cend(),
|
||||||
[&](const auto &fact)
|
[&](const auto &fact)
|
||||||
{
|
{
|
||||||
m_outputStream << output::Function("initialState") << "(";
|
m_outputStream << colorlog::Function("initialState") << "(";
|
||||||
fact.variable().printNameAsASPPredicate(m_outputStream);
|
fact.variable().printNameAsASPPredicate(m_outputStream);
|
||||||
m_outputStream << ", ";
|
m_outputStream << ", ";
|
||||||
fact.value().printAsASPPredicate(m_outputStream);
|
fact.value().printAsASPPredicate(m_outputStream);
|
||||||
|
@ -93,14 +93,14 @@ void TranslatorASP::translateInitialState() const
|
||||||
|
|
||||||
void TranslatorASP::translateGoal() const
|
void TranslatorASP::translateGoal() const
|
||||||
{
|
{
|
||||||
m_outputStream << output::Heading2("goal") << std::endl;
|
m_outputStream << colorlog::Heading2("goal") << std::endl;
|
||||||
|
|
||||||
const auto &goalFacts = m_description.goal().facts();
|
const auto &goalFacts = m_description.goal().facts();
|
||||||
|
|
||||||
std::for_each(goalFacts.cbegin(), goalFacts.cend(),
|
std::for_each(goalFacts.cbegin(), goalFacts.cend(),
|
||||||
[&](const auto &fact)
|
[&](const auto &fact)
|
||||||
{
|
{
|
||||||
m_outputStream << output::Function("goal") << "(";
|
m_outputStream << colorlog::Function("goal") << "(";
|
||||||
fact.variable().printNameAsASPPredicate(m_outputStream);
|
fact.variable().printNameAsASPPredicate(m_outputStream);
|
||||||
m_outputStream << ", ";
|
m_outputStream << ", ";
|
||||||
fact.value().printAsASPPredicate(m_outputStream);
|
fact.value().printAsASPPredicate(m_outputStream);
|
||||||
|
@ -112,7 +112,7 @@ void TranslatorASP::translateGoal() const
|
||||||
|
|
||||||
void TranslatorASP::translateVariables() const
|
void TranslatorASP::translateVariables() const
|
||||||
{
|
{
|
||||||
m_outputStream << output::Heading2("variables");
|
m_outputStream << colorlog::Heading2("variables");
|
||||||
|
|
||||||
const auto &variables = m_description.variables();
|
const auto &variables = m_description.variables();
|
||||||
|
|
||||||
|
@ -123,14 +123,14 @@ void TranslatorASP::translateVariables() const
|
||||||
|
|
||||||
BOOST_ASSERT(!values.empty());
|
BOOST_ASSERT(!values.empty());
|
||||||
|
|
||||||
m_outputStream << std::endl << output::Function("variable") << "(";
|
m_outputStream << std::endl << colorlog::Function("variable") << "(";
|
||||||
variable.printNameAsASPPredicate(m_outputStream);
|
variable.printNameAsASPPredicate(m_outputStream);
|
||||||
m_outputStream << ")." << std::endl;
|
m_outputStream << ")." << std::endl;
|
||||||
|
|
||||||
std::for_each(values.cbegin(), values.cend(),
|
std::for_each(values.cbegin(), values.cend(),
|
||||||
[&](const auto &value)
|
[&](const auto &value)
|
||||||
{
|
{
|
||||||
m_outputStream << output::Function("contains") << "(";
|
m_outputStream << colorlog::Function("contains") << "(";
|
||||||
variable.printNameAsASPPredicate(m_outputStream);
|
variable.printNameAsASPPredicate(m_outputStream);
|
||||||
m_outputStream << ", ";
|
m_outputStream << ", ";
|
||||||
value.printAsASPPredicate(m_outputStream);
|
value.printAsASPPredicate(m_outputStream);
|
||||||
|
@ -143,7 +143,7 @@ void TranslatorASP::translateVariables() const
|
||||||
|
|
||||||
void TranslatorASP::translateActions() const
|
void TranslatorASP::translateActions() const
|
||||||
{
|
{
|
||||||
m_outputStream << output::Heading2("actions");
|
m_outputStream << colorlog::Heading2("actions");
|
||||||
|
|
||||||
const auto &operators = m_description.operators();
|
const auto &operators = m_description.operators();
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ void TranslatorASP::translateActions() const
|
||||||
std::for_each(operators.cbegin(), operators.cend(),
|
std::for_each(operators.cbegin(), operators.cend(),
|
||||||
[&](const auto &operator_)
|
[&](const auto &operator_)
|
||||||
{
|
{
|
||||||
m_outputStream << std::endl << output::Function("action") << "(";
|
m_outputStream << std::endl << colorlog::Function("action") << "(";
|
||||||
operator_.printPredicateAsASP(m_outputStream);
|
operator_.printPredicateAsASP(m_outputStream);
|
||||||
m_outputStream << ")." << std::endl;
|
m_outputStream << ")." << std::endl;
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ void TranslatorASP::translateActions() const
|
||||||
std::for_each(preconditions.cbegin(), preconditions.cend(),
|
std::for_each(preconditions.cbegin(), preconditions.cend(),
|
||||||
[&](const auto &precondition)
|
[&](const auto &precondition)
|
||||||
{
|
{
|
||||||
m_outputStream << output::Function("precondition") << "(";
|
m_outputStream << colorlog::Function("precondition") << "(";
|
||||||
operator_.printPredicateAsASP(m_outputStream);
|
operator_.printPredicateAsASP(m_outputStream);
|
||||||
m_outputStream << ", ";
|
m_outputStream << ", ";
|
||||||
precondition.variable().printNameAsASPPredicate(m_outputStream);
|
precondition.variable().printNameAsASPPredicate(m_outputStream);
|
||||||
|
@ -177,13 +177,13 @@ void TranslatorASP::translateActions() const
|
||||||
{
|
{
|
||||||
const auto &conditions = effect.conditions();
|
const auto &conditions = effect.conditions();
|
||||||
|
|
||||||
m_outputStream << output::Function("postcondition") << "(";
|
m_outputStream << colorlog::Function("postcondition") << "(";
|
||||||
operator_.printPredicateAsASP(m_outputStream);
|
operator_.printPredicateAsASP(m_outputStream);
|
||||||
|
|
||||||
if (conditions.empty())
|
if (conditions.empty())
|
||||||
m_outputStream << ", " << output::Keyword("effect") << "(" << output::Reserved("unconditional") << "), ";
|
m_outputStream << ", " << colorlog::Keyword("effect") << "(" << colorlog::Reserved("unconditional") << "), ";
|
||||||
else
|
else
|
||||||
m_outputStream << ", " << output::Keyword("effect") << "(" << output::Number<decltype(currentEffectID)>(currentEffectID) << "), ";
|
m_outputStream << ", " << colorlog::Keyword("effect") << "(" << colorlog::Number<decltype(currentEffectID)>(currentEffectID) << "), ";
|
||||||
|
|
||||||
effect.postcondition().variable().printNameAsASPPredicate(m_outputStream);
|
effect.postcondition().variable().printNameAsASPPredicate(m_outputStream);
|
||||||
m_outputStream << ", ";
|
m_outputStream << ", ";
|
||||||
|
@ -195,8 +195,8 @@ void TranslatorASP::translateActions() const
|
||||||
{
|
{
|
||||||
// Conditions of conditional effects
|
// Conditions of conditional effects
|
||||||
m_outputStream
|
m_outputStream
|
||||||
<< output::Function("precondition") << "("
|
<< colorlog::Function("precondition") << "("
|
||||||
<< output::Keyword("effect") << "(" << output::Number<decltype(currentEffectID)>(currentEffectID) << "), ";
|
<< colorlog::Keyword("effect") << "(" << colorlog::Number<decltype(currentEffectID)>(currentEffectID) << "), ";
|
||||||
condition.variable().printNameAsASPPredicate(m_outputStream);
|
condition.variable().printNameAsASPPredicate(m_outputStream);
|
||||||
m_outputStream << ", ";
|
m_outputStream << ", ";
|
||||||
condition.value().printAsASPPredicate(m_outputStream);
|
condition.value().printAsASPPredicate(m_outputStream);
|
||||||
|
@ -207,9 +207,9 @@ void TranslatorASP::translateActions() const
|
||||||
currentEffectID++;
|
currentEffectID++;
|
||||||
});
|
});
|
||||||
|
|
||||||
m_outputStream << output::Function("costs") << "(";
|
m_outputStream << colorlog::Function("costs") << "(";
|
||||||
operator_.printPredicateAsASP(m_outputStream);
|
operator_.printPredicateAsASP(m_outputStream);
|
||||||
m_outputStream << ", " << output::Number<decltype(operator_.costs())>(operator_.costs()) << ")." << std::endl;
|
m_outputStream << ", " << colorlog::Number<decltype(operator_.costs())>(operator_.costs()) << ")." << std::endl;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ void TranslatorASP::translateActions() const
|
||||||
|
|
||||||
void TranslatorASP::translateMutexes() const
|
void TranslatorASP::translateMutexes() const
|
||||||
{
|
{
|
||||||
m_outputStream << output::Heading2("mutex groups");
|
m_outputStream << colorlog::Heading2("mutex groups");
|
||||||
|
|
||||||
const auto &mutexGroups = m_description.mutexGroups();
|
const auto &mutexGroups = m_description.mutexGroups();
|
||||||
|
|
||||||
|
@ -231,9 +231,9 @@ void TranslatorASP::translateMutexes() const
|
||||||
|
|
||||||
m_outputStream
|
m_outputStream
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< output::Function("mutexGroup") << "("
|
<< colorlog::Function("mutexGroup") << "("
|
||||||
<< output::Keyword("mutexGroup") << "("
|
<< colorlog::Keyword("mutexGroup") << "("
|
||||||
<< output::Number<decltype(mutexGroupID)>(mutexGroupID)
|
<< colorlog::Number<decltype(mutexGroupID)>(mutexGroupID)
|
||||||
<< "))." << std::endl;
|
<< "))." << std::endl;
|
||||||
|
|
||||||
const auto &facts = mutexGroup.facts();
|
const auto &facts = mutexGroup.facts();
|
||||||
|
@ -241,7 +241,7 @@ void TranslatorASP::translateMutexes() const
|
||||||
std::for_each(facts.cbegin(), facts.cend(),
|
std::for_each(facts.cbegin(), facts.cend(),
|
||||||
[&](const auto &fact)
|
[&](const auto &fact)
|
||||||
{
|
{
|
||||||
m_outputStream << output::Function("contains") << "(" << output::Keyword("mutexGroup") << "(" << output::Number<decltype(mutexGroupID)>(mutexGroupID) << "), ";
|
m_outputStream << colorlog::Function("contains") << "(" << colorlog::Keyword("mutexGroup") << "(" << colorlog::Number<decltype(mutexGroupID)>(mutexGroupID) << "), ";
|
||||||
fact.variable().printNameAsASPPredicate(m_outputStream);
|
fact.variable().printNameAsASPPredicate(m_outputStream);
|
||||||
m_outputStream << ", ";
|
m_outputStream << ", ";
|
||||||
fact.value().printAsASPPredicate(m_outputStream);
|
fact.value().printAsASPPredicate(m_outputStream);
|
||||||
|
@ -254,7 +254,7 @@ void TranslatorASP::translateMutexes() const
|
||||||
|
|
||||||
void TranslatorASP::translateAxiomRules() const
|
void TranslatorASP::translateAxiomRules() const
|
||||||
{
|
{
|
||||||
m_outputStream << output::Heading2("axiom rules");
|
m_outputStream << colorlog::Heading2("axiom rules");
|
||||||
|
|
||||||
const auto &axiomRules = m_description.axiomRules();
|
const auto &axiomRules = m_description.axiomRules();
|
||||||
|
|
||||||
|
@ -268,9 +268,9 @@ void TranslatorASP::translateAxiomRules() const
|
||||||
|
|
||||||
m_outputStream
|
m_outputStream
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< output::Function("axiomRule") << "("
|
<< colorlog::Function("axiomRule") << "("
|
||||||
<< output::Keyword("axiomRule") << "("
|
<< colorlog::Keyword("axiomRule") << "("
|
||||||
<< output::Number<decltype(axiomRuleID)>(axiomRuleID)
|
<< colorlog::Number<decltype(axiomRuleID)>(axiomRuleID)
|
||||||
<< "))." << std::endl;
|
<< "))." << std::endl;
|
||||||
|
|
||||||
// TODO: Translate axiom rule layer
|
// TODO: Translate axiom rule layer
|
||||||
|
@ -281,8 +281,8 @@ void TranslatorASP::translateAxiomRules() const
|
||||||
[&](const auto &condition)
|
[&](const auto &condition)
|
||||||
{
|
{
|
||||||
m_outputStream
|
m_outputStream
|
||||||
<< output::Function("precondition") << "("
|
<< colorlog::Function("precondition") << "("
|
||||||
<< output::Keyword("axiomRule") << "(" << output::Number<decltype(axiomRuleID)>(axiomRuleID) << "), ";
|
<< colorlog::Keyword("axiomRule") << "(" << colorlog::Number<decltype(axiomRuleID)>(axiomRuleID) << "), ";
|
||||||
condition.variable().printNameAsASPPredicate(m_outputStream);
|
condition.variable().printNameAsASPPredicate(m_outputStream);
|
||||||
m_outputStream << ", ";
|
m_outputStream << ", ";
|
||||||
condition.value().printAsASPPredicate(m_outputStream);
|
condition.value().printAsASPPredicate(m_outputStream);
|
||||||
|
@ -292,9 +292,9 @@ void TranslatorASP::translateAxiomRules() const
|
||||||
const auto &postcondition = axiomRule.postcondition();
|
const auto &postcondition = axiomRule.postcondition();
|
||||||
|
|
||||||
m_outputStream
|
m_outputStream
|
||||||
<< output::Function("postcondition") << "("
|
<< colorlog::Function("postcondition") << "("
|
||||||
<< output::Keyword("axiomRule") << "(" << output::Number<decltype(axiomRuleID)>(axiomRuleID) << "), "
|
<< colorlog::Keyword("axiomRule") << "(" << colorlog::Number<decltype(axiomRuleID)>(axiomRuleID) << "), "
|
||||||
<< output::Keyword("effect") << "(" << output::Reserved("unconditional") << "), ";
|
<< colorlog::Keyword("effect") << "(" << colorlog::Reserved("unconditional") << "), ";
|
||||||
postcondition.variable().printNameAsASPPredicate(m_outputStream);
|
postcondition.variable().printNameAsASPPredicate(m_outputStream);
|
||||||
m_outputStream << ", ";
|
m_outputStream << ", ";
|
||||||
postcondition.value().printAsASPPredicate(m_outputStream);
|
postcondition.value().printAsASPPredicate(m_outputStream);
|
||||||
|
|
|
@ -2,11 +2,12 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <plasp/output/Formatting.h>
|
|
||||||
#include <plasp/sas/Variable.h>
|
|
||||||
|
|
||||||
#include <tokenize/TokenizerException.h>
|
#include <tokenize/TokenizerException.h>
|
||||||
|
|
||||||
|
#include <colorlog/Formatting.h>
|
||||||
|
|
||||||
|
#include <plasp/sas/Variable.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
|
@ -128,22 +129,22 @@ const std::string &Value::name() const
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void Value::printAsASPPredicate(output::ColorStream &stream) const
|
void Value::printAsASPPredicate(colorlog::ColorStream &stream) const
|
||||||
{
|
{
|
||||||
// TODO: do not compare by value
|
// TODO: do not compare by value
|
||||||
if (*this == Value::None)
|
if (*this == Value::None)
|
||||||
{
|
{
|
||||||
stream << output::Keyword("value") << "(" << output::Reserved("none") << ")";
|
stream << colorlog::Keyword("value") << "(" << colorlog::Reserved("none") << ")";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream << output::Keyword("value") << "(" << output::String(m_name.c_str()) << ", "
|
stream << colorlog::Keyword("value") << "(" << colorlog::String(m_name.c_str()) << ", "
|
||||||
<< (m_sign == Sign::Positive ? output::Boolean("true") : output::Boolean("false")) << ")";
|
<< (m_sign == Sign::Positive ? colorlog::Boolean("true") : colorlog::Boolean("false")) << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void Value::printAsSAS(output::ColorStream &stream) const
|
void Value::printAsSAS(colorlog::ColorStream &stream) const
|
||||||
{
|
{
|
||||||
if (m_sign == Value::Sign::Positive)
|
if (m_sign == Value::Sign::Positive)
|
||||||
stream << "Atom ";
|
stream << "Atom ";
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <plasp/output/Formatting.h>
|
|
||||||
|
|
||||||
#include <tokenize/TokenizerException.h>
|
#include <tokenize/TokenizerException.h>
|
||||||
|
|
||||||
|
#include <colorlog/Formatting.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
|
@ -53,10 +53,10 @@ Variable Variable::fromSAS(tokenize::Tokenizer<> &tokenizer)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void Variable::printNameAsASPPredicate(output::ColorStream &stream) const
|
void Variable::printNameAsASPPredicate(colorlog::ColorStream &stream) const
|
||||||
{
|
{
|
||||||
// TODO: assert that name is a number indeed
|
// TODO: assert that name is a number indeed
|
||||||
stream << output::Keyword("variable") << "(" << output::Number<std::string>(m_name) << ")";
|
stream << colorlog::Keyword("variable") << "(" << colorlog::Number<std::string>(m_name) << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -7,6 +7,7 @@ set(includes
|
||||||
${PROJECT_SOURCE_DIR}/include
|
${PROJECT_SOURCE_DIR}/include
|
||||||
${PROJECT_SOURCE_DIR}/lib/catch/single_include
|
${PROJECT_SOURCE_DIR}/lib/catch/single_include
|
||||||
${PROJECT_SOURCE_DIR}/lib/tokenize/include
|
${PROJECT_SOURCE_DIR}/lib/tokenize/include
|
||||||
|
${PROJECT_SOURCE_DIR}/lib/colorlog/include
|
||||||
${PROJECT_SOURCE_DIR}/lib/variant/include
|
${PROJECT_SOURCE_DIR}/lib/variant/include
|
||||||
${PROJECT_SOURCE_DIR}/lib/pddlparse/include
|
${PROJECT_SOURCE_DIR}/lib/pddlparse/include
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,10 +3,11 @@
|
||||||
#include <boost/iostreams/stream.hpp>
|
#include <boost/iostreams/stream.hpp>
|
||||||
#include <boost/iostreams/device/null.hpp>
|
#include <boost/iostreams/device/null.hpp>
|
||||||
|
|
||||||
|
#include <colorlog/Logger.h>
|
||||||
|
|
||||||
#include <pddlparse/AST.h>
|
#include <pddlparse/AST.h>
|
||||||
#include <pddlparse/Parse.h>
|
#include <pddlparse/Parse.h>
|
||||||
|
|
||||||
#include <plasp/output/Logger.h>
|
|
||||||
#include <plasp/pddl/TranslatorASP.h>
|
#include <plasp/pddl/TranslatorASP.h>
|
||||||
|
|
||||||
boost::iostreams::stream<boost::iostreams::null_sink> nullStream((boost::iostreams::null_sink()));
|
boost::iostreams::stream<boost::iostreams::null_sink> nullStream((boost::iostreams::null_sink()));
|
||||||
|
@ -17,7 +18,7 @@ const pddl::Context::WarningCallback ignoreWarnings = [](const auto &, const aut
|
||||||
TEST_CASE("[PDDL translation] Former issues are fixed", "[PDDL translation]")
|
TEST_CASE("[PDDL translation] Former issues are fixed", "[PDDL translation]")
|
||||||
{
|
{
|
||||||
// TODO: refactor
|
// TODO: refactor
|
||||||
plasp::output::Logger logger(nullStream, nullStream);
|
colorlog::Logger logger(nullStream, nullStream);
|
||||||
pddl::Tokenizer tokenizer;
|
pddl::Tokenizer tokenizer;
|
||||||
pddl::Context context(std::move(tokenizer), ignoreWarnings);
|
pddl::Context context(std::move(tokenizer), ignoreWarnings);
|
||||||
|
|
||||||
|
|
Reference in New Issue