Implemented parsing of PDDL constants.
This commit is contained in:
60
include/plasp/pddl/Constant.h
Normal file
60
include/plasp/pddl/Constant.h
Normal file
@@ -0,0 +1,60 @@
|
||||
#ifndef __PLASP__PDDL__CONSTANT_H
|
||||
#define __PLASP__PDDL__CONSTANT_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <plasp/pddl/Type.h>
|
||||
#include <plasp/utils/Parser.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace pddl
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Constant
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class Context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class Constant
|
||||
{
|
||||
public:
|
||||
static Constant &parse(utils::Parser &parser, Context &context);
|
||||
static Constant &parseDeclaration(utils::Parser &parser, Context &context);
|
||||
|
||||
public:
|
||||
const std::string &name() const;
|
||||
const PrimitiveType *type() const;
|
||||
|
||||
bool isDeclared() const;
|
||||
|
||||
private:
|
||||
Constant(std::string name);
|
||||
|
||||
void setDirty(bool isDirty = true);
|
||||
bool isDirty() const;
|
||||
|
||||
void setDeclared();
|
||||
|
||||
void setType(const PrimitiveType *parentType);
|
||||
|
||||
bool m_isDirty;
|
||||
bool m_isDeclared;
|
||||
|
||||
std::string m_name;
|
||||
|
||||
const PrimitiveType *m_type;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@@ -5,6 +5,7 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <plasp/pddl/Constant.h>
|
||||
#include <plasp/pddl/Predicate.h>
|
||||
#include <plasp/pddl/Type.h>
|
||||
|
||||
@@ -27,6 +28,9 @@ class Context
|
||||
|
||||
std::vector<std::unique_ptr<EitherType>> eitherTypes;
|
||||
|
||||
std::vector<std::unique_ptr<Constant>> constants;
|
||||
std::unordered_map<std::string, Constant *> constantsHashMap;
|
||||
|
||||
std::vector<std::unique_ptr<Predicate>> predicates;
|
||||
std::unordered_map<PredicateHashMapKey, Predicate *> predicatesHashMap;
|
||||
};
|
||||
|
@@ -29,6 +29,7 @@ class Domain
|
||||
const std::string &name() const;
|
||||
const Requirements &requirements() const;
|
||||
const std::vector<std::unique_ptr<PrimitiveType>> &types() const;
|
||||
const std::vector<std::unique_ptr<Constant>> &constants() const;
|
||||
const std::vector<std::unique_ptr<Predicate>> &predicates() const;
|
||||
|
||||
private:
|
||||
@@ -42,6 +43,8 @@ class Domain
|
||||
|
||||
void parseTypeSection(utils::Parser &parser);
|
||||
|
||||
void parseConstantSection(utils::Parser &parser);
|
||||
|
||||
void parsePredicateSection(utils::Parser &parser);
|
||||
|
||||
void checkConsistency();
|
||||
|
@@ -41,7 +41,7 @@ class PrimitiveType
|
||||
|
||||
void setDeclared();
|
||||
|
||||
void addParentType(const PrimitiveType &parentType);
|
||||
void addParentType(const PrimitiveType *parentType);
|
||||
|
||||
bool m_isDirty;
|
||||
bool m_isDeclared;
|
||||
|
Reference in New Issue
Block a user