2016-06-04 17:10:50 +02:00
|
|
|
#ifndef __PLASP__PDDL__EXPRESSIONS__NOT_H
|
|
|
|
#define __PLASP__PDDL__EXPRESSIONS__NOT_H
|
2016-06-02 22:31:02 +02:00
|
|
|
|
2016-06-04 16:24:10 +02:00
|
|
|
#include <plasp/pddl/Context.h>
|
2016-06-02 22:31:02 +02:00
|
|
|
#include <plasp/pddl/Expression.h>
|
|
|
|
|
|
|
|
namespace plasp
|
|
|
|
{
|
|
|
|
namespace pddl
|
|
|
|
{
|
|
|
|
namespace expressions
|
|
|
|
{
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2016-06-03 13:33:05 +02:00
|
|
|
// Not
|
2016-06-02 22:31:02 +02:00
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-06-12 22:12:09 +02:00
|
|
|
class Not: public ExpressionCRTP<Not>
|
2016-06-02 22:31:02 +02:00
|
|
|
{
|
|
|
|
public:
|
2016-06-12 22:12:09 +02:00
|
|
|
static const Expression::Type ExpressionType = Expression::Type::Not;
|
|
|
|
|
2016-06-02 22:31:02 +02:00
|
|
|
template<typename ExpressionParser>
|
2016-06-07 13:26:19 +02:00
|
|
|
static NotPointer parse(Context &context, ExpressionContext &expressionContext,
|
2016-06-04 16:24:10 +02:00
|
|
|
ExpressionParser parseExpression);
|
2016-06-02 22:31:02 +02:00
|
|
|
|
|
|
|
public:
|
2016-06-13 01:38:56 +02:00
|
|
|
Not();
|
|
|
|
|
|
|
|
const Expression *argument() const;
|
2016-06-02 22:31:02 +02:00
|
|
|
|
|
|
|
private:
|
2016-06-13 01:38:56 +02:00
|
|
|
void setArgument(const Expression *argument);
|
|
|
|
void setArgument(ExpressionPointer &&argument);
|
|
|
|
|
|
|
|
const Expression *m_argument;
|
|
|
|
ExpressionPointer m_argumentStorage;
|
2016-06-02 22:31:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template<typename ExpressionParser>
|
2016-06-07 13:26:19 +02:00
|
|
|
NotPointer Not::parse(Context &context, ExpressionContext &expressionContext,
|
2016-06-04 16:24:10 +02:00
|
|
|
ExpressionParser parseExpression)
|
2016-06-02 22:31:02 +02:00
|
|
|
{
|
2016-06-09 17:51:10 +02:00
|
|
|
auto &parser = context.parser;
|
|
|
|
|
|
|
|
const auto position = parser.position();
|
|
|
|
|
2016-08-02 19:58:54 +02:00
|
|
|
if (!parser.testAndSkip<std::string>("(")
|
|
|
|
|| !parser.testIdentifierAndSkip("not"))
|
2016-06-09 17:51:10 +02:00
|
|
|
{
|
|
|
|
parser.seek(position);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-06-03 13:33:05 +02:00
|
|
|
auto expression = std::make_unique<Not>(Not());
|
2016-06-02 22:31:02 +02:00
|
|
|
|
2016-06-04 16:24:10 +02:00
|
|
|
context.parser.skipWhiteSpace();
|
2016-06-02 22:31:02 +02:00
|
|
|
|
|
|
|
// Parse argument
|
2016-06-13 01:38:56 +02:00
|
|
|
expression->setArgument(parseExpression(context, expressionContext));
|
2016-06-02 22:31:02 +02:00
|
|
|
|
2016-06-09 17:51:10 +02:00
|
|
|
parser.expect<std::string>(")");
|
|
|
|
|
2016-06-02 22:31:02 +02:00
|
|
|
return expression;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|