patrick
/
plasp
Archived
1
0
Fork 0
This repository has been archived on 2023-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
plasp/src/plasp/pddl/Variable.cpp

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;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}