Parsing domains in two passes and continued working on parsing the initial state.
This commit is contained in:
@@ -26,7 +26,8 @@ class Domain
|
||||
Domain(Context &context);
|
||||
|
||||
public:
|
||||
void readPDDL();
|
||||
void findSections();
|
||||
void parse();
|
||||
|
||||
void setName(std::string name);
|
||||
const std::string &name() const;
|
||||
@@ -66,10 +67,20 @@ class Domain
|
||||
Context &m_context;
|
||||
|
||||
std::string m_name;
|
||||
|
||||
utils::Parser::Position m_requirementsPosition;
|
||||
Requirements m_requirements;
|
||||
expressions::PrimitiveTypes m_primitiveTypes;
|
||||
|
||||
utils::Parser::Position m_typesPosition;
|
||||
expressions::PrimitiveTypes m_types;
|
||||
|
||||
utils::Parser::Position m_constantsPosition;
|
||||
expressions::Constants m_constants;
|
||||
expressions::PredicateDeclarations m_predicateDeclarations;
|
||||
|
||||
utils::Parser::Position m_predicatesPosition;
|
||||
expressions::PredicateDeclarations m_predicates;
|
||||
|
||||
std::vector<utils::Parser::Position> m_actionPositions;
|
||||
std::vector<std::unique_ptr<Action>> m_actions;
|
||||
};
|
||||
|
||||
|
@@ -7,20 +7,27 @@ namespace plasp
|
||||
{
|
||||
namespace pddl
|
||||
{
|
||||
namespace expressions
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// InitialState
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class InitialState
|
||||
{
|
||||
public:
|
||||
static std::unique_ptr<InitialState> parseDeclaration(Context &context, const Problem &problem);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Type
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
public:
|
||||
const Expressions &facts() const;
|
||||
|
||||
ExpressionPointer parseInitialState(Context &context);
|
||||
private:
|
||||
Expressions m_facts;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <plasp/pddl/Context.h>
|
||||
#include <plasp/pddl/Expression.h>
|
||||
#include <plasp/pddl/InitialState.h>
|
||||
#include <plasp/pddl/Requirement.h>
|
||||
|
||||
namespace plasp
|
||||
@@ -21,7 +22,7 @@ class Problem
|
||||
public:
|
||||
Problem(Context &context, Domain &domain);
|
||||
|
||||
void readPDDL();
|
||||
void parse();
|
||||
|
||||
bool isDeclared() const;
|
||||
|
||||
@@ -37,6 +38,9 @@ class Problem
|
||||
expressions::Constants &objects();
|
||||
const expressions::Constants &objects() const;
|
||||
|
||||
InitialState &initialState();
|
||||
const InitialState &initialState() const;
|
||||
|
||||
void checkConsistency();
|
||||
|
||||
private:
|
||||
@@ -49,6 +53,8 @@ class Problem
|
||||
|
||||
void parseObjectSection();
|
||||
|
||||
void parseInitialStateSection();
|
||||
|
||||
Context &m_context;
|
||||
Domain &m_domain;
|
||||
bool m_isDeclared;
|
||||
@@ -57,6 +63,8 @@ class Problem
|
||||
Requirements m_requirements;
|
||||
|
||||
expressions::Constants m_objects;
|
||||
|
||||
std::unique_ptr<InitialState> m_initialState;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@@ -27,7 +27,8 @@ class Constant: public Expression
|
||||
static void parseTypedDeclaration(Context &context, Problem &problem);
|
||||
static void parseTypedDeclarations(Context &context, Problem &problem);
|
||||
|
||||
static Constant *parseAndFind(Context &context, const ExpressionContext &expressionContext);
|
||||
static Constant *parseAndFind(Context &context, const Domain &domain);
|
||||
static Constant *parseAndFind(Context &context, const Problem &problem);
|
||||
|
||||
public:
|
||||
void accept(ExpressionVisitor &expressionVisitor) const override;
|
||||
|
@@ -21,6 +21,7 @@ class Predicate: public Expression
|
||||
public:
|
||||
static PredicatePointer parse(std::string name, Context &context,
|
||||
ExpressionContext &expressionContext);
|
||||
static PredicatePointer parse(std::string name, Context &context, const Problem &problem);
|
||||
|
||||
public:
|
||||
void accept(ExpressionVisitor &expressionVisitor) const override;
|
||||
|
Reference in New Issue
Block a user