Added debug printing function to facilitate testing expression normalization.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#ifndef __PLASP__PDDL__EXPRESSION_H
|
||||
#define __PLASP__PDDL__EXPRESSION_H
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
|
||||
#include <plasp/utils/Parser.h>
|
||||
@@ -110,6 +112,8 @@ class Expression
|
||||
virtual ExpressionPointer normalized();
|
||||
ExpressionPointer negated();
|
||||
|
||||
virtual void print(std::ostream &ostream) const = 0;
|
||||
|
||||
private:
|
||||
friend void intrusive_ptr_add_ref(Expression *expression);
|
||||
friend void intrusive_ptr_release(Expression *expression);
|
||||
|
@@ -39,6 +39,8 @@ class At: public ExpressionCRTP<At>
|
||||
|
||||
ExpressionPointer normalized() override;
|
||||
|
||||
void print(std::ostream &ostream) const override;
|
||||
|
||||
protected:
|
||||
size_t m_timePoint;
|
||||
|
||||
|
@@ -33,6 +33,8 @@ class Binary: public ExpressionCRTP<Derived>
|
||||
|
||||
ExpressionPointer normalized() override;
|
||||
|
||||
void print(std::ostream &ostream) const override;
|
||||
|
||||
protected:
|
||||
std::array<ExpressionPointer, 2> m_arguments;
|
||||
};
|
||||
@@ -102,6 +104,23 @@ inline ExpressionPointer Binary<Derived>::normalized()
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class Derived>
|
||||
inline void Binary<Derived>::print(std::ostream &ostream) const
|
||||
{
|
||||
ostream << "(" << Derived::Identifier;
|
||||
|
||||
std::for_each(m_arguments.begin(), m_arguments.end(),
|
||||
[&](auto &argument)
|
||||
{
|
||||
ostream << " ";
|
||||
argument->print(ostream);
|
||||
});
|
||||
|
||||
ostream << ")";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,8 @@ class Constant: public ExpressionCRTP<Constant>
|
||||
const std::string &name() const;
|
||||
PrimitiveTypePointer type() const;
|
||||
|
||||
void print(std::ostream &ostream) const override;
|
||||
|
||||
private:
|
||||
static ConstantPointer parseDeclaration(Context &context);
|
||||
static void parseTypedDeclaration(Context &context, Domain &domain, Constants &constants);
|
||||
|
@@ -21,12 +21,13 @@ class Dummy: public ExpressionCRTP<Dummy>
|
||||
public:
|
||||
static const Expression::Type ExpressionType = Expression::Type::Dummy;
|
||||
|
||||
bool isNormalized() const;
|
||||
public:
|
||||
Dummy(std::string name);
|
||||
|
||||
ExpressionPointer normalized() override;
|
||||
void print(std::ostream &ostream) const override;
|
||||
|
||||
private:
|
||||
bool m_isNormalized = false;
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@@ -35,6 +35,8 @@ class NAry: public ExpressionCRTP<Derived>
|
||||
|
||||
ExpressionPointer normalized() override;
|
||||
|
||||
void print(std::ostream &ostream) const override;
|
||||
|
||||
protected:
|
||||
Expressions m_arguments;
|
||||
};
|
||||
@@ -132,6 +134,23 @@ inline ExpressionPointer NAry<Derived>::normalized()
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class Derived>
|
||||
inline void NAry<Derived>::print(std::ostream &ostream) const
|
||||
{
|
||||
ostream << "(" << Derived::Identifier;
|
||||
|
||||
std::for_each(m_arguments.begin(), m_arguments.end(),
|
||||
[&](auto &argument)
|
||||
{
|
||||
ostream << " ";
|
||||
argument->print(ostream);
|
||||
});
|
||||
|
||||
ostream << ")";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -34,6 +34,8 @@ class Not: public ExpressionCRTP<Not>
|
||||
|
||||
ExpressionPointer normalized() override;
|
||||
|
||||
void print(std::ostream &ostream) const override;
|
||||
|
||||
protected:
|
||||
ExpressionPointer m_argument;
|
||||
};
|
||||
|
@@ -30,6 +30,8 @@ class Predicate: public ExpressionCRTP<Predicate>
|
||||
|
||||
bool isDeclared() const;
|
||||
|
||||
void print(std::ostream &ostream) const override;
|
||||
|
||||
private:
|
||||
Predicate();
|
||||
|
||||
|
@@ -31,6 +31,8 @@ class PredicateDeclaration: public ExpressionCRTP<PredicateDeclaration>
|
||||
|
||||
void normalizeParameterNames();
|
||||
|
||||
void print(std::ostream &ostream) const override;
|
||||
|
||||
private:
|
||||
PredicateDeclaration();
|
||||
|
||||
|
@@ -35,6 +35,8 @@ class PrimitiveType: public ExpressionCRTP<PrimitiveType>
|
||||
const std::string &name() const;
|
||||
const PrimitiveTypes &parentTypes() const;
|
||||
|
||||
void print(std::ostream &ostream) const override;
|
||||
|
||||
private:
|
||||
void setDirty(bool isDirty = true);
|
||||
bool isDirty() const;
|
||||
|
@@ -27,6 +27,8 @@ class Unsupported: public ExpressionCRTP<Unsupported>
|
||||
public:
|
||||
const std::string &type() const;
|
||||
|
||||
void print(std::ostream &ostream) const override;
|
||||
|
||||
private:
|
||||
std::string m_type;
|
||||
};
|
||||
|
@@ -37,6 +37,8 @@ class Variable: public ExpressionCRTP<Variable>
|
||||
void setDirty(bool isDirty = true);
|
||||
bool isDirty() const;
|
||||
|
||||
void print(std::ostream &ostream) const override;
|
||||
|
||||
private:
|
||||
static void parseDeclaration(Context &context, Variables ¶meters);
|
||||
|
||||
|
Reference in New Issue
Block a user