82 lines
1.8 KiB
C++
82 lines
1.8 KiB
C++
#include <plasp/pddl/Variable.h>
|
|
|
|
#include <boost/assert.hpp>
|
|
|
|
#include <plasp/pddl/Context.h>
|
|
#include <plasp/pddl/Identifier.h>
|
|
|
|
namespace plasp
|
|
{
|
|
namespace pddl
|
|
{
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Variable
|
|
//
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
Variable::Variable(std::string name)
|
|
: m_isDirty{false},
|
|
m_name(name)
|
|
{
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
Variable Variable::parse(utils::Parser &parser, Context &context)
|
|
{
|
|
parser.skipWhiteSpace();
|
|
|
|
parser.expect<std::string>("?");
|
|
|
|
const auto variableName = parser.parseIdentifier(isIdentifier);
|
|
|
|
Variable variable(variableName);
|
|
variable.setDirty();
|
|
|
|
return variable;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
void Variable::setDirty(bool isDirty)
|
|
{
|
|
m_isDirty = isDirty;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
bool Variable::isDirty() const
|
|
{
|
|
return m_isDirty;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
const std::string &Variable::name() const
|
|
{
|
|
return m_name;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
void Variable::setType(const Type &type)
|
|
{
|
|
m_type = &type;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
const Type &Variable::type() const
|
|
{
|
|
BOOST_ASSERT(m_type != nullptr);
|
|
|
|
return *m_type;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
}
|
|
}
|