Moved basic parsing to a separate module.

This commit is contained in:
2017-05-09 15:05:59 +02:00
parent 386e5356af
commit 27c6b69874
64 changed files with 322 additions and 234 deletions

View File

@@ -2,7 +2,8 @@
#define __PLASP__LANGUAGE_DETECTION_H
#include <plasp/Language.h>
#include <plasp/input/Parser.h>
#include <parsebase/Parser.h>
namespace plasp
{
@@ -13,7 +14,7 @@ namespace plasp
//
////////////////////////////////////////////////////////////////////////////////////////////////////
Language::Type detectLanguage(input::Parser<input::CaseInsensitiveParserPolicy> &parser)
Language::Type detectLanguage(parsebase::Parser<parsebase::CaseInsensitiveParserPolicy> &parser)
{
parser.skipWhiteSpace();

View File

@@ -1,34 +0,0 @@
#ifndef __PLASP__INPUT__LOCATION_H
#define __PLASP__INPUT__LOCATION_H
#include <cstdlib>
namespace plasp
{
namespace input
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Location
//
////////////////////////////////////////////////////////////////////////////////////////////////////
struct Location
{
const char *sectionStart = nullptr;
const char *sectionEnd = nullptr;
std::size_t rowStart = -1;
std::size_t rowEnd = -1;
std::size_t columnStart = -1;
std::size_t columnEnd = -1;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -1,570 +0,0 @@
#ifndef __PLASP__INPUT__PARSER_H
#define __PLASP__INPUT__PARSER_H
#include <iostream>
#include <iterator>
#include <sstream>
#include <vector>
#include <boost/filesystem.hpp>
#include <plasp/input/ParserException.h>
#include <plasp/input/ParserPolicy.h>
#include <plasp/input/Stream.h>
namespace plasp
{
namespace input
{
template<typename Type>
struct Tag
{
};
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Parser
//
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy = CaseSensitiveParserPolicy>
class Parser: public Stream, public ParserPolicy
{
template<class OtherParserPolicy>
friend class Parser;
public:
explicit Parser();
explicit Parser(std::string streamName, std::istream &istream);
template<class OtherParser>
Parser(OtherParser &&otherParser)
{
m_stream = std::move(otherParser.m_stream);
m_delimiters = std::move(otherParser.m_delimiters);
}
void removeComments(const std::string &startSequence, const std::string &endSequence, bool removeEnd);
char currentCharacter() const;
template<typename Type>
Type parse();
template<typename Type>
bool testAndReturn(const Type &expectedValue);
template<typename Type>
bool testAndSkip(const Type &expectedValue);
template<typename Type>
void expect(const Type &expectedValue);
std::string parseIdentifier();
bool testIdentifierAndReturn(const std::string &identifier);
bool testIdentifierAndSkip(const std::string &identifier);
// TODO: remove
bool probeNumber();
std::string parseLine();
void skipWhiteSpace();
void skipBlankSpace();
void skipLine();
private:
std::string parseImpl(Tag<std::string>);
char parseImpl(Tag<char>);
uint64_t parseImpl(Tag<uint64_t>);
int64_t parseImpl(Tag<int64_t>);
uint32_t parseImpl(Tag<uint32_t>);
int32_t parseImpl(Tag<int32_t>);
bool parseImpl(Tag<bool>);
bool testImpl(const std::string &expectedValue);
bool testImpl(char expectedValue);
bool testImpl(uint64_t expectedValue);
bool testImpl(int64_t expectedValue);
bool testImpl(uint32_t expectedValue);
bool testImpl(int32_t expectedValue);
bool testImpl(bool expectedValue);
uint64_t parseIntegerBody();
};
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
Parser<ParserPolicy>::Parser()
: Stream()
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
Parser<ParserPolicy>::Parser(std::string streamName, std::istream &istream)
: Stream(streamName, istream)
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
void Parser<ParserPolicy>::skipWhiteSpace()
{
check();
while (!atEnd() && ParserPolicy::isWhiteSpaceCharacter(currentCharacter()))
advance();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
void Parser<ParserPolicy>::skipBlankSpace()
{
check();
while (!atEnd() && ParserPolicy::isBlankCharacter(currentCharacter()))
advance();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
void Parser<ParserPolicy>::skipLine()
{
check();
while (currentCharacter() != '\n')
advance();
advance();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
template<typename Type>
Type Parser<ParserPolicy>::parse()
{
return parseImpl(Tag<Type>());
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
template<typename Type>
bool Parser<ParserPolicy>::testAndReturn(const Type &expectedValue)
{
const auto previousPosition = position();
const auto result = testImpl(expectedValue);
seek(previousPosition);
return result;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
template<typename Type>
bool Parser<ParserPolicy>::testAndSkip(const Type &expectedValue)
{
const auto previousPosition = position();
const auto result = testImpl(expectedValue);
if (result == false)
seek(previousPosition);
return result;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
template<typename Type>
void Parser<ParserPolicy>::expect(const Type &expectedValue)
{
if (testAndSkip(expectedValue))
return;
std::stringstream message;
message << "unexpected value, expected “" << expectedValue << "";
throw ParserException(location(), message.str());
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
std::string Parser<ParserPolicy>::parseIdentifier()
{
skipWhiteSpace();
std::string value;
while (true)
{
const auto character = currentCharacter();
if (!ParserPolicy::isIdentifierCharacter(character))
return value;
value.push_back(character);
advance();
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
bool Parser<ParserPolicy>::testIdentifierAndSkip(const std::string &expectedValue)
{
return testAndSkip(expectedValue) && !ParserPolicy::isIdentifierCharacter(currentCharacter());
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
bool Parser<ParserPolicy>::probeNumber()
{
const auto previousPosition = position();
skipWhiteSpace();
while (!ParserPolicy::isWhiteSpaceCharacter(currentCharacter()))
if (!std::isdigit(currentCharacter()))
{
seek(previousPosition);
return false;
}
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
std::string Parser<ParserPolicy>::parseLine()
{
std::string value;
while (true)
{
const auto character = currentCharacter();
advance();
if (character == '\n')
break;
else if (character == '\r')
continue;
value.push_back(character);
}
return value;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
void Parser<ParserPolicy>::removeComments(const std::string &startSequence, const std::string &endSequence, bool removeEnd)
{
const auto inPosition = m_stream.tellg();
const auto outPosition = m_stream.tellp();
m_stream.seekg(0);
const auto removeRange =
[&](const auto &start, const auto &end)
{
BOOST_ASSERT(start != -1);
m_stream.clear();
m_stream.seekp(start);
m_stream.seekg(start);
auto position = start;
while (end == -1 || position < end)
{
m_stream.ignore(1);
if (atEnd())
return;
m_stream.put(' ');
position += static_cast<std::streamoff>(1);
}
};
while (!atEnd())
{
Position startPosition = m_stream.tellg();
while (!atEnd())
{
startPosition = m_stream.tellg();
if (testAndSkip(startSequence))
break;
advance();
}
Position endPosition = m_stream.tellg();
while (!atEnd())
{
endPosition = m_stream.tellg();
if (testAndSkip(endSequence))
break;
advance();
}
if (removeEnd)
endPosition = m_stream.tellg();
removeRange(startPosition, endPosition);
}
m_stream.clear();
m_stream.seekg(inPosition);
m_stream.seekp(outPosition);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
char Parser<ParserPolicy>::currentCharacter() const
{
return ParserPolicy::transformCharacter(Stream::currentCharacter());
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
std::string Parser<ParserPolicy>::parseImpl(Tag<std::string>)
{
skipWhiteSpace();
const auto startPosition = position();
while (!ParserPolicy::isWhiteSpaceCharacter(currentCharacter()))
advance();
const auto endPosition = position();
const auto length = static_cast<size_t>(endPosition - startPosition);
std::string value;
value.reserve(length);
seek(startPosition);
for (size_t i = 0; i < length; i++)
{
value.push_back(currentCharacter());
advance();
}
return value;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
char Parser<ParserPolicy>::parseImpl(Tag<char>)
{
const auto value = currentCharacter();
advance();
return value;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
uint64_t Parser<ParserPolicy>::parseIntegerBody()
{
check();
if (!std::isdigit(currentCharacter()))
throw ParserException(location(), "could not parse integer value");
uint64_t value = 0;
while (!atEnd())
{
const auto character = currentCharacter();
if (!std::isdigit(character))
break;
value *= 10;
value += character - '0';
advance();
}
return value;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
int64_t Parser<ParserPolicy>::parseImpl(Tag<int64_t>)
{
skipWhiteSpace();
bool positive = testAndSkip<char>('+') || !testAndSkip<char>('-');
const auto value = parseIntegerBody();
return (positive ? value : -value);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
uint64_t Parser<ParserPolicy>::parseImpl(Tag<uint64_t>)
{
skipWhiteSpace();
if (currentCharacter() == '-')
throw ParserException(location(), "expected unsigned integer, got signed one");
return parseIntegerBody();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
int32_t Parser<ParserPolicy>::parseImpl(Tag<int32_t>)
{
return static_cast<int32_t>(parseImpl(Tag<int64_t>()));
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
uint32_t Parser<ParserPolicy>::parseImpl(Tag<uint32_t>)
{
return static_cast<uint32_t>(parseImpl(Tag<uint64_t>()));
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
bool Parser<ParserPolicy>::parseImpl(Tag<bool>)
{
skipWhiteSpace();
if (testAndSkip<char>('0'))
return false;
if (testAndSkip<char>('1'))
return true;
throw ParserException(location(), "could not parse Boolean value");
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
bool Parser<ParserPolicy>::testImpl(const std::string &expectedValue)
{
if (!ParserPolicy::isWhiteSpaceCharacter(expectedValue.front()))
skipWhiteSpace();
const auto match = std::find_if(expectedValue.cbegin(), expectedValue.cend(),
[&](const auto &expectedCharacter)
{
const auto character = static_cast<char>(this->currentCharacter());
if (character != expectedCharacter)
return true;
this->advance();
return false;
});
return (match == expectedValue.cend());
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
bool Parser<ParserPolicy>::testImpl(char expectedValue)
{
const auto result = (currentCharacter() == expectedValue);
advance();
return result;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
bool Parser<ParserPolicy>::testImpl(int64_t expectedValue)
{
const auto value = parseImpl(Tag<int64_t>());
return (value == expectedValue);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
bool Parser<ParserPolicy>::testImpl(uint64_t expectedValue)
{
const auto value = parseImpl(Tag<uint64_t>());
return (value == expectedValue);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
bool Parser<ParserPolicy>::testImpl(int32_t expectedValue)
{
return testImpl(static_cast<int64_t>(expectedValue));
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
bool Parser<ParserPolicy>::testImpl(uint32_t expectedValue)
{
return testImpl(static_cast<uint64_t>(expectedValue));
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
bool Parser<ParserPolicy>::testImpl(bool expectedValue)
{
const auto value = parseImpl(Tag<bool>());
return (value == expectedValue);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -1,72 +0,0 @@
#ifndef __PLASP__INPUT__PARSER_EXCEPTION_H
#define __PLASP__INPUT__PARSER_EXCEPTION_H
#include <exception>
#include <string>
#include <plasp/input/Location.h>
namespace plasp
{
namespace input
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// ParserException
//
////////////////////////////////////////////////////////////////////////////////////////////////////
class ParserException: public std::exception
{
public:
explicit ParserException(const input::Location &location)
: ParserException(location, "unspecified parser error")
{
}
explicit ParserException(const input::Location &location, const char *message)
: ParserException(location, static_cast<std::string>(message))
{
}
explicit ParserException(const input::Location &location, const std::string &message)
: m_location{location},
m_message{message},
// TODO: refactor
m_plainMessage{std::string(m_location.sectionStart) + ":" + std::to_string(m_location.rowStart)
+ ":" + std::to_string(m_location.columnStart) + " " + m_message}
{
}
~ParserException() throw()
{
}
const char *what() const throw()
{
return m_plainMessage.c_str();
}
const input::Location &location() const
{
return m_location;
}
const std::string &message() const
{
return m_message;
}
private:
input::Location m_location;
std::string m_message;
std::string m_plainMessage;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -1,72 +0,0 @@
#ifndef __PLASP__INPUT__PARSER_POLICY_H
#define __PLASP__INPUT__PARSER_POLICY_H
#include <iostream>
namespace plasp
{
namespace input
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// ParserPolicy
//
////////////////////////////////////////////////////////////////////////////////////////////////////
class CaseSensitiveParserPolicy
{
public:
static constexpr char transformCharacter(char c) noexcept
{
return c;
}
static bool isWhiteSpaceCharacter(char c)
{
return std::iswspace(c);
}
static bool isBlankCharacter(char c)
{
return std::isblank(c);
}
static bool isIdentifierCharacter(char c)
{
return std::isgraph(c);
}
};
////////////////////////////////////////////////////////////////////////////////////////////////////
class CaseInsensitiveParserPolicy
{
public:
static char transformCharacter(char c) noexcept
{
return std::tolower(c);
}
static bool isWhiteSpaceCharacter(char c)
{
return std::iswspace(c);
}
static bool isBlankCharacter(char c)
{
return std::isblank(c);
}
static bool isIdentifierCharacter(char c)
{
return std::isgraph(c);
}
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -1,83 +0,0 @@
#ifndef __PLASP__INPUT__STREAM_H
#define __PLASP__INPUT__STREAM_H
#include <iostream>
#include <iterator>
#include <sstream>
#include <vector>
#include <boost/filesystem.hpp>
#include <plasp/input/Location.h>
namespace plasp
{
namespace input
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Stream
//
////////////////////////////////////////////////////////////////////////////////////////////////////
class Stream
{
public:
using Position = std::stringstream::pos_type;
struct Delimiter
{
Position position;
std::string sectionName;
};
public:
explicit Stream();
explicit Stream(std::string streamName, std::istream &istream);
Stream(const Stream &other) = delete;
Stream &operator=(const Stream &other) = delete;
Stream(Stream &&other)
: m_stream{std::move(other.m_stream)},
m_delimiters{std::move(other.m_delimiters)}
{
}
Stream &operator=(Stream &&other)
{
m_stream = std::move(other.m_stream);
m_delimiters = std::move(other.m_delimiters);
return *this;
}
~Stream() = default;
void read(std::string streamName, std::istream &istream);
void read(const boost::filesystem::path &path);
void reset();
void seek(Position position);
Position position() const;
Location location() const;
char currentCharacter() const;
void advance();
bool atEnd() const;
void check() const;
protected:
mutable std::stringstream m_stream;
std::vector<Delimiter> m_delimiters;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -3,10 +3,11 @@
#include <string>
#include <plasp/input/Location.h>
#include <plasp/output/ColorStream.h>
#include <plasp/output/Priority.h>
#include <parsebase/Location.h>
namespace plasp
{
namespace output
@@ -36,8 +37,8 @@ class Logger
void log(Priority priority, const char *message);
void log(Priority priority, const std::string &message);
void log(Priority priority, const input::Location &location, const char *message);
void log(Priority priority, const input::Location &location, const std::string &message);
void log(Priority priority, const parsebase::Location &location, const char *message);
void log(Priority priority, const parsebase::Location &location, const std::string &message);
private:
ColorStream m_outputStream;

View File

@@ -3,10 +3,11 @@
#include <vector>
#include <plasp/input/Parser.h>
#include <plasp/pddl/Expression.h>
#include <plasp/pddl/expressions/Variable.h>
#include <parsebase/Parser.h>
namespace plasp
{
namespace pddl

View File

@@ -5,7 +5,8 @@
#include <plasp/pddl/Domain.h>
#include <plasp/pddl/Problem.h>
#include <plasp/input/Parser.h>
#include <parsebase/Parser.h>
namespace plasp
{
@@ -47,9 +48,9 @@ class Description
Context &m_context;
input::Stream::Position m_domainPosition;
parsebase::Stream::Position m_domainPosition;
std::unique_ptr<Domain> m_domain;
input::Stream::Position m_problemPosition;
parsebase::Stream::Position m_problemPosition;
std::unique_ptr<Problem> m_problem;
};

View File

@@ -75,19 +75,19 @@ class Domain
std::string m_name;
input::Stream::Position m_requirementsPosition;
parsebase::Stream::Position m_requirementsPosition;
Requirements m_requirements;
input::Stream::Position m_typesPosition;
parsebase::Stream::Position m_typesPosition;
expressions::PrimitiveTypes m_types;
input::Stream::Position m_constantsPosition;
parsebase::Stream::Position m_constantsPosition;
expressions::Constants m_constants;
input::Stream::Position m_predicatesPosition;
parsebase::Stream::Position m_predicatesPosition;
expressions::PredicateDeclarations m_predicates;
std::vector<input::Stream::Position> m_actionPositions;
std::vector<parsebase::Stream::Position> m_actionPositions;
std::vector<std::unique_ptr<Action>> m_actions;
expressions::DerivedPredicates m_derivedPredicates;

View File

@@ -6,7 +6,7 @@
#include <boost/intrusive_ptr.hpp>
#include <plasp/input/Parser.h>
#include <parsebase/Parser.h>
namespace plasp
{

View File

@@ -1,7 +1,7 @@
#ifndef __PLASP__PDDL__PARSER_H
#define __PLASP__PDDL__PARSER_H
#include <plasp/input/Parser.h>
#include <parsebase/Parser.h>
namespace plasp
{
@@ -44,7 +44,7 @@ class PDDLParserPolicy
////////////////////////////////////////////////////////////////////////////////////////////////////
using Parser = input::Parser<PDDLParserPolicy>;
using Parser = parsebase::Parser<PDDLParserPolicy>;
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -64,18 +64,18 @@ class Problem
std::string m_name;
input::Stream::Position m_domainPosition;
parsebase::Stream::Position m_domainPosition;
input::Stream::Position m_requirementsPosition;
parsebase::Stream::Position m_requirementsPosition;
Requirements m_requirements;
input::Stream::Position m_objectsPosition;
parsebase::Stream::Position m_objectsPosition;
expressions::Constants m_objects;
input::Stream::Position m_initialStatePosition;
parsebase::Stream::Position m_initialStatePosition;
std::unique_ptr<InitialState> m_initialState;
input::Stream::Position m_goalPosition;
parsebase::Stream::Position m_goalPosition;
ExpressionPointer m_goal;
};

View File

@@ -4,10 +4,11 @@
#include <iosfwd>
#include <vector>
#include <plasp/input/Parser.h>
#include <plasp/sas/Value.h>
#include <plasp/sas/Variable.h>
#include <parsebase/Parser.h>
namespace plasp
{
namespace sas
@@ -27,8 +28,8 @@ using AssignedVariables = std::vector<AssignedVariable>;
class AssignedVariable
{
public:
static AssignedVariable fromSAS(input::Parser<> &parser, const Variables &variables);
static AssignedVariable fromSAS(input::Parser<> &parser, const Variable &variable);
static AssignedVariable fromSAS(parsebase::Parser<> &parser, const Variables &variables);
static AssignedVariable fromSAS(parsebase::Parser<> &parser, const Variable &variable);
public:
explicit AssignedVariable(const Variable &variable, const Value &value);

View File

@@ -3,10 +3,11 @@
#include <vector>
#include <plasp/input/Parser.h>
#include <plasp/sas/AssignedVariable.h>
#include <plasp/sas/Variable.h>
#include <parsebase/Parser.h>
namespace plasp
{
namespace sas
@@ -29,7 +30,7 @@ class AxiomRule
using Condition = AssignedVariable;
using Conditions = AssignedVariables;
static AxiomRule fromSAS(input::Parser<> &parser, const Variables &variables);
static AxiomRule fromSAS(parsebase::Parser<> &parser, const Variables &variables);
public:
const Conditions &conditions() const;

View File

@@ -1,13 +1,12 @@
#ifndef __PLASP__SAS__DESCRIPTION_H
#define __PLASP__SAS__DESCRIPTION_H
#include <experimental/filesystem>
#include <iosfwd>
#include <memory>
#include <vector>
#include <boost/filesystem/path.hpp>
#include <plasp/input/Parser.h>
#include <plasp/sas/AxiomRule.h>
#include <plasp/sas/Goal.h>
#include <plasp/sas/InitialState.h>
@@ -15,6 +14,8 @@
#include <plasp/sas/Operator.h>
#include <plasp/sas/Variable.h>
#include <parsebase/Parser.h>
namespace plasp
{
namespace sas
@@ -29,9 +30,9 @@ namespace sas
class Description
{
public:
static Description fromParser(input::Parser<> &&parser);
static Description fromParser(parsebase::Parser<> &&parser);
static Description fromStream(std::istream &istream);
static Description fromFile(const boost::filesystem::path &path);
static Description fromFile(const std::experimental::filesystem::path &path);
public:
bool usesActionCosts() const;
@@ -50,16 +51,16 @@ class Description
private:
Description();
void parseContent(input::Parser<> &parser);
void parseContent(parsebase::Parser<> &parser);
void parseVersionSection(input::Parser<> &parser) const;
void parseMetricSection(input::Parser<> &parser);
void parseVariablesSection(input::Parser<> &parser);
void parseMutexSection(input::Parser<> &parser);
void parseInitialStateSection(input::Parser<> &parser);
void parseGoalSection(input::Parser<> &parser);
void parseOperatorSection(input::Parser<> &parser);
void parseAxiomSection(input::Parser<> &parser);
void parseVersionSection(parsebase::Parser<> &parser) const;
void parseMetricSection(parsebase::Parser<> &parser);
void parseVariablesSection(parsebase::Parser<> &parser);
void parseMutexSection(parsebase::Parser<> &parser);
void parseInitialStateSection(parsebase::Parser<> &parser);
void parseGoalSection(parsebase::Parser<> &parser);
void parseOperatorSection(parsebase::Parser<> &parser);
void parseAxiomSection(parsebase::Parser<> &parser);
bool m_usesActionCosts;

View File

@@ -3,10 +3,11 @@
#include <vector>
#include <plasp/input/Parser.h>
#include <plasp/sas/AssignedVariable.h>
#include <plasp/sas/Variable.h>
#include <parsebase/Parser.h>
namespace plasp
{
namespace sas
@@ -29,7 +30,7 @@ class Effect
using Condition = AssignedVariable;
using Conditions = AssignedVariables;
static Effect fromSAS(input::Parser<> &parser, const Variables &variables, Conditions &preconditions);
static Effect fromSAS(parsebase::Parser<> &parser, const Variables &variables, Conditions &preconditions);
public:
const Conditions &conditions() const;

View File

@@ -1,9 +1,10 @@
#ifndef __PLASP__SAS__GOAL_H
#define __PLASP__SAS__GOAL_H
#include <plasp/input/Parser.h>
#include <plasp/sas/AssignedVariable.h>
#include <parsebase/Parser.h>
namespace plasp
{
namespace sas
@@ -21,7 +22,7 @@ class Goal
using Fact = AssignedVariable;
using Facts = AssignedVariables;
static Goal fromSAS(input::Parser<> &parser, const Variables &variables);
static Goal fromSAS(parsebase::Parser<> &parser, const Variables &variables);
public:
const Facts &facts() const;

View File

@@ -1,9 +1,10 @@
#ifndef __PLASP__SAS__INITIAL_STATE_H
#define __PLASP__SAS__INITIAL_STATE_H
#include <plasp/input/Parser.h>
#include <plasp/sas/AssignedVariable.h>
#include <parsebase/Parser.h>
namespace plasp
{
namespace sas
@@ -21,7 +22,7 @@ class InitialState
using Fact = AssignedVariable;
using Facts = AssignedVariables;
static InitialState fromSAS(input::Parser<> &parser, const Variables &variables);
static InitialState fromSAS(parsebase::Parser<> &parser, const Variables &variables);
public:
const Facts &facts() const;

View File

@@ -3,9 +3,10 @@
#include <vector>
#include <plasp/input/Parser.h>
#include <plasp/sas/AssignedVariable.h>
#include <parsebase/Parser.h>
namespace plasp
{
namespace sas
@@ -28,7 +29,7 @@ class MutexGroup
using Fact = AssignedVariable;
using Facts = AssignedVariables;
static MutexGroup fromSAS(input::Parser<> &parser, const Variables &variables);
static MutexGroup fromSAS(parsebase::Parser<> &parser, const Variables &variables);
public:
const Facts &facts() const;

View File

@@ -4,13 +4,14 @@
#include <string>
#include <vector>
#include <plasp/input/Parser.h>
#include <plasp/output/ColorStream.h>
#include <plasp/sas/AssignedVariable.h>
#include <plasp/sas/Effect.h>
#include <plasp/sas/Predicate.h>
#include <plasp/sas/Variable.h>
#include <parsebase/Parser.h>
namespace plasp
{
namespace sas
@@ -33,7 +34,7 @@ class Operator
using Condition = AssignedVariable;
using Conditions = AssignedVariables;
static Operator fromSAS(input::Parser<> &parser, const Variables &variables);
static Operator fromSAS(parsebase::Parser<> &parser, const Variables &variables);
public:
void printPredicateAsASP(output::ColorStream &stream) const;

View File

@@ -5,9 +5,10 @@
#include <string>
#include <vector>
#include <plasp/input/Parser.h>
#include <plasp/output/ColorStream.h>
#include <parsebase/Parser.h>
namespace plasp
{
namespace sas
@@ -22,7 +23,7 @@ namespace sas
class Predicate
{
public:
static Predicate fromSAS(input::Parser<> &parser);
static Predicate fromSAS(parsebase::Parser<> &parser);
using Arguments = std::vector<std::string>;

View File

@@ -1,11 +1,11 @@
#ifndef __PLASP__SAS__TRANSLATOR_ASP_H
#define __PLASP__SAS__TRANSLATOR_ASP_H
#include <iosfwd>
#include <plasp/output/ColorStream.h>
#include <plasp/sas/Description.h>
#include <iosfwd>
namespace plasp
{
namespace sas

View File

@@ -5,9 +5,10 @@
#include <string>
#include <vector>
#include <plasp/input/Parser.h>
#include <plasp/output/ColorStream.h>
#include <parsebase/Parser.h>
namespace plasp
{
namespace sas
@@ -39,8 +40,8 @@ struct Value
static const Value Any;
static const Value None;
static Value fromSAS(input::Parser<> &parser);
static const Value &referenceFromSAS(input::Parser<> &parser, const Variable &variable);
static Value fromSAS(parsebase::Parser<> &parser);
static const Value &referenceFromSAS(parsebase::Parser<> &parser, const Variable &variable);
public:
Value negated() const;

View File

@@ -5,10 +5,11 @@
#include <string>
#include <vector>
#include <plasp/input/Parser.h>
#include <plasp/output/ColorStream.h>
#include <plasp/sas/Value.h>
#include <parsebase/Parser.h>
namespace plasp
{
namespace sas
@@ -28,8 +29,8 @@ using Variables = std::vector<Variable>;
class Variable
{
public:
static Variable fromSAS(input::Parser<> &parser);
static const Variable &referenceFromSAS(input::Parser<> &parser, const Variables &variables);
static Variable fromSAS(parsebase::Parser<> &parser);
static const Variable &referenceFromSAS(parsebase::Parser<> &parser, const Variables &variables);
public:
void printNameAsASPPredicate(output::ColorStream &outputStream) const;

View File

@@ -3,10 +3,11 @@
#include <iosfwd>
#include <plasp/input/Parser.h>
#include <plasp/sas/Value.h>
#include <plasp/sas/Variable.h>
#include <parsebase/Parser.h>
namespace plasp
{
namespace sas
@@ -26,7 +27,7 @@ using VariableTransitions = std::vector<VariableTransition>;
class VariableTransition
{
public:
static VariableTransition fromSAS(input::Parser<> &parser, const Variables &variables);
static VariableTransition fromSAS(parsebase::Parser<> &parser, const Variables &variables);
public:
const Variable &variable() const;