Outsourced SAS value parsing.

This commit is contained in:
Patrick Lühne 2016-05-21 17:09:55 +02:00
parent d219ef0388
commit c7c7a93eba
14 changed files with 394 additions and 171 deletions

View File

@ -0,0 +1,44 @@
#ifndef __SAS__ASSIGNED_VARIABLE_H
#define __SAS__ASSIGNED_VARIABLE_H
#include <iosfwd>
#include <plasp/sas/Value.h>
#include <plasp/sas/Variable.h>
namespace plasp
{
namespace sas
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// AssignedVariable
//
////////////////////////////////////////////////////////////////////////////////////////////////////
class AssignedVariable
{
public:
static AssignedVariable fromSAS(std::istream &istream, const std::vector<Variable> &variables);
static AssignedVariable fromSAS(std::istream &istream, const Variable &variable);
public:
AssignedVariable(const Variable &variable, const Value &value);
const Variable &variable() const;
const Value &value() const;
private:
AssignedVariable();
const Variable *m_variable;
const Value *m_value;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@ -42,11 +42,6 @@ class Description
private:
Description();
const Variable &parseVariable(std::istream &istream) const;
const Value &parseValue(std::istream &istream, const Variable &variable) const;
AssignedVariable parseAssignedVariable(std::istream &istream) const;
VariableTransition parseVariableTransition(std::istream &istream) const;
void parseVersionSection(std::istream &istream) const;
void parseMetricSection(std::istream &istream);
void parseVariablesSection(std::istream &istream);

View File

@ -1,7 +1,7 @@
#ifndef __SAS__MUTEX_GROUP_H
#define __SAS__MUTEX_GROUP_H
#include <plasp/sas/Variable.h>
#include <plasp/sas/AssignedVariable.h>
namespace plasp
{
@ -14,13 +14,21 @@ namespace sas
//
////////////////////////////////////////////////////////////////////////////////////////////////////
// TODO: make consistent with initial state/goal
struct MutexGroup
class MutexGroup
{
public:
using Fact = AssignedVariable;
using Facts = std::vector<Fact>;
Facts facts;
static MutexGroup fromSAS(std::istream &istream, const std::vector<Variable> &variables);
public:
const Facts &facts() const;
private:
MutexGroup() = default;
Facts m_facts;
};
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -10,6 +10,9 @@ namespace plasp
namespace sas
{
// Forward declarations
class Variable;
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Value
@ -28,6 +31,7 @@ struct Value
static const Value Any;
static Value fromSAS(std::istream &istream);
static const Value &referenceFromSAS(std::istream &istream, const Variable &variable);
public:
void printAsSAS(std::ostream &ostream) const;

View File

@ -22,6 +22,7 @@ class Variable
{
public:
static Variable fromSAS(std::istream &istream);
static const Variable &referenceFromSAS(std::istream &istream, const std::vector<Variable> &variables);
public:
const std::string &name() const;
@ -38,23 +39,6 @@ class Variable
////////////////////////////////////////////////////////////////////////////////////////////////////
struct AssignedVariable
{
const Variable &variable;
const Value &value;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
struct VariableTransition
{
const Variable &variable;
const Value &valueBefore;
const Value &valueAfter;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}

View File

@ -0,0 +1,43 @@
#ifndef __SAS__VARIABLE_TRANSITION_H
#define __SAS__VARIABLE_TRANSITION_H
#include <iosfwd>
#include <plasp/sas/Value.h>
#include <plasp/sas/Variable.h>
namespace plasp
{
namespace sas
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// VariableTransition
//
////////////////////////////////////////////////////////////////////////////////////////////////////
class VariableTransition
{
public:
static VariableTransition fromSAS(std::istream &istream, const std::vector<Variable> &variables);
public:
const Variable &variable() const;
const Value &valueBefore() const;
const Value &valueAfter() const;
private:
VariableTransition();
const Variable *m_variable;
const Value *m_valueBefore;
const Value *m_valueAfter;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@ -0,0 +1,79 @@
#include <plasp/sas/AssignedVariable.h>
#include <iostream>
#include <boost/assert.hpp>
#include <plasp/utils/Parsing.h>
namespace plasp
{
namespace sas
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// AssignedVariable
//
////////////////////////////////////////////////////////////////////////////////////////////////////
AssignedVariable::AssignedVariable()
: m_variable{nullptr},
m_value{nullptr}
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
AssignedVariable::AssignedVariable(const Variable &variable, const Value &value)
: m_variable{&variable},
m_value{&value}
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
AssignedVariable AssignedVariable::fromSAS(std::istream &istream, const std::vector<Variable> &variables)
{
AssignedVariable assignedVariable;
assignedVariable.m_variable = &Variable::referenceFromSAS(istream, variables);
assignedVariable.m_value = &Value::referenceFromSAS(istream, *assignedVariable.m_variable);
return assignedVariable;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
AssignedVariable AssignedVariable::fromSAS(std::istream &istream, const Variable &variable)
{
AssignedVariable assignedVariable;
assignedVariable.m_variable = &variable;
assignedVariable.m_value = &Value::referenceFromSAS(istream, *assignedVariable.m_variable);
return assignedVariable;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
const Variable &AssignedVariable::variable() const
{
BOOST_ASSERT(m_variable != nullptr);
return *m_variable;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
const Value &AssignedVariable::value() const
{
BOOST_ASSERT(m_value != nullptr);
return *m_value;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}

View File

@ -8,6 +8,7 @@
#include <plasp/utils/ParserException.h>
#include <plasp/utils/Parsing.h>
#include <plasp/sas/VariableTransition.h>
namespace plasp
{
@ -145,11 +146,11 @@ void Description::print(std::ostream &ostream) const
{
ostream << "\tmutex group:" << std::endl;
std::for_each(mutexGroup.facts.cbegin(), mutexGroup.facts.cend(),
std::for_each(mutexGroup.facts().cbegin(), mutexGroup.facts().cend(),
[&](const auto &fact)
{
ostream << "\t\t" << fact.variable.name() << " = ";
fact.value.printAsSAS(ostream);
ostream << "\t\t" << fact.variable().name() << " = ";
fact.value().printAsSAS(ostream);
ostream << std::endl;
});
});
@ -160,8 +161,8 @@ void Description::print(std::ostream &ostream) const
std::for_each(m_initialStateFacts.cbegin(), m_initialStateFacts.cend(),
[&](const auto &initialStateFact)
{
ostream << "\t" << initialStateFact.variable.name() << " = ";
initialStateFact.value.printAsSAS(ostream);
ostream << "\t" << initialStateFact.variable().name() << " = ";
initialStateFact.value().printAsSAS(ostream);
ostream << std::endl;
});
@ -171,8 +172,8 @@ void Description::print(std::ostream &ostream) const
std::for_each(m_goalFacts.cbegin(), m_goalFacts.cend(),
[&](const auto &goalFact)
{
ostream << "\t" << goalFact.variable.name() << " = ";
goalFact.value.printAsSAS(ostream);
ostream << "\t" << goalFact.variable().name() << " = ";
goalFact.value().printAsSAS(ostream);
ostream << std::endl;
});
@ -188,8 +189,8 @@ void Description::print(std::ostream &ostream) const
std::for_each(operator_.preconditions.cbegin(), operator_.preconditions.cend(),
[&](const auto &precondition)
{
std::cout << "\t\t\t" << precondition.variable.name() << " = ";
precondition.value.printAsSAS(ostream);
std::cout << "\t\t\t" << precondition.variable().name() << " = ";
precondition.value().printAsSAS(ostream);
ostream << std::endl;
});
@ -204,14 +205,14 @@ void Description::print(std::ostream &ostream) const
std::for_each(effect.conditions.cbegin(), effect.conditions.cend(),
[&](const auto &condition)
{
ostream << "\t\t\t\t\t" << condition.variable.name() << " = ";
condition.value.printAsSAS(ostream);
ostream << "\t\t\t\t\t" << condition.variable().name() << " = ";
condition.value().printAsSAS(ostream);
ostream << std::endl;
});
ostream << "\t\t\t\tpostcondition:" << std::endl;
ostream << "\t\t\t\t\t" << effect.postcondition.variable.name() << " = ";
effect.postcondition.value.printAsSAS(ostream);
ostream << "\t\t\t\t\t" << effect.postcondition.variable().name() << " = ";
effect.postcondition.value().printAsSAS(ostream);
ostream << std::endl;
});
@ -230,68 +231,20 @@ void Description::print(std::ostream &ostream) const
std::for_each(axiomRule.conditions.cbegin(), axiomRule.conditions.cend(),
[&](const auto &condition)
{
ostream << "\t\t\t" << condition.variable.name() << " = ";
condition.value.printAsSAS(ostream);
ostream << "\t\t\t" << condition.variable().name() << " = ";
condition.value().printAsSAS(ostream);
ostream << std::endl;
});
ostream << "\t\tpostcondition:" << std::endl;
ostream << "\t\t\t" << axiomRule.postcondition.variable.name() << " = ";
axiomRule.postcondition.value.printAsSAS(ostream);
ostream << "\t\t\t" << axiomRule.postcondition.variable().name() << " = ";
axiomRule.postcondition.value().printAsSAS(ostream);
ostream << std::endl;
});
}
////////////////////////////////////////////////////////////////////////////////////////////////////
const Variable &Description::parseVariable(std::istream &istream) const
{
const auto variableID = utils::parse<size_t>(istream);
if (variableID >= m_variables.size())
throw utils::ParserException("Variable index out of range (index " + std::to_string(variableID) + ")");
return m_variables[variableID];
}
////////////////////////////////////////////////////////////////////////////////////////////////////
const Value &Description::parseValue(std::istream &istream, const Variable &variable) const
{
const auto valueID = utils::parse<int>(istream);
if (valueID == -1)
return Value::Any;
if (valueID < 0 || static_cast<size_t>(valueID) >= variable.values().size())
throw utils::ParserException("Value index out of range (variable " + variable.name() + ", index " + std::to_string(valueID) + ")");
return variable.values()[valueID];
}
////////////////////////////////////////////////////////////////////////////////////////////////////
AssignedVariable Description::parseAssignedVariable(std::istream &istream) const
{
const auto &variable = parseVariable(istream);
const auto &value = parseValue(istream, variable);
return {variable, value};
}
////////////////////////////////////////////////////////////////////////////////////////////////////
VariableTransition Description::parseVariableTransition(std::istream &istream) const
{
const auto &variable = parseVariable(istream);
const auto &valueBefore = parseValue(istream, variable);
const auto &valueAfter = parseValue(istream, variable);
return {variable, valueBefore, valueAfter};
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void Description::parseVersionSection(std::istream &istream) const
{
// Version section
@ -332,25 +285,10 @@ void Description::parseVariablesSection(std::istream &istream)
void Description::parseMutexSection(std::istream &istream)
{
const auto numberOfMutexGroups = utils::parse<size_t>(istream);
m_mutexGroups.resize(numberOfMutexGroups);
m_mutexGroups.reserve(numberOfMutexGroups);
for (size_t i = 0; i < numberOfMutexGroups; i++)
{
utils::parseExpected<std::string>(istream, "begin_mutex_group");
auto &mutexGroup = m_mutexGroups[i];
const auto numberOfFacts = utils::parse<size_t>(istream);
mutexGroup.facts.reserve(numberOfFacts);
for (size_t j = 0; j < numberOfFacts; j++)
{
const auto fact = parseAssignedVariable(istream);
mutexGroup.facts.push_back(std::move(fact));
}
utils::parseExpected<std::string>(istream, "end_mutex_group");
}
m_mutexGroups.emplace_back(MutexGroup::fromSAS(istream, m_variables));
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@ -362,12 +300,7 @@ void Description::parseInitialStateSection(std::istream &istream)
m_initialStateFacts.reserve(m_variables.size());
for (size_t i = 0; i < m_variables.size(); i++)
{
const auto &variable = m_variables[i];
const auto &value = parseValue(istream, variable);
m_initialStateFacts.push_back({variable, value});
}
m_initialStateFacts.emplace_back(AssignedVariable::fromSAS(istream, m_variables[i]));
utils::parseExpected<std::string>(istream, "end_state");
}
@ -382,10 +315,7 @@ void Description::parseGoalSection(std::istream &istream)
m_goalFacts.reserve(numberOfGoalFacts);
for (size_t i = 0; i < numberOfGoalFacts; i++)
{
const auto goalFact = parseAssignedVariable(istream);
m_goalFacts.push_back(std::move(goalFact));
}
m_goalFacts.emplace_back(AssignedVariable::fromSAS(istream, m_variables));
utils::parseExpected<std::string>(istream, "end_goal");
}
@ -430,10 +360,7 @@ void Description::parseOperatorSection(std::istream &istream)
operator_.preconditions.reserve(numberOfPrevailConditions);
for (size_t j = 0; j < numberOfPrevailConditions; j++)
{
const auto precondition = parseAssignedVariable(istream);
operator_.preconditions.push_back(std::move(precondition));
}
operator_.preconditions.emplace_back(AssignedVariable::fromSAS(istream, m_variables));
const auto numberOfEffects = utils::parse<size_t>(istream);
operator_.effects.reserve(numberOfEffects);
@ -446,17 +373,14 @@ void Description::parseOperatorSection(std::istream &istream)
conditions.reserve(numberOfEffectConditions);
for (size_t k = 0; k < numberOfEffectConditions; k++)
{
const auto condition = parseAssignedVariable(istream);
conditions.push_back(std::move(condition));
}
conditions.emplace_back(AssignedVariable::fromSAS(istream, m_variables));
const auto variableTransition = parseVariableTransition(istream);
const auto variableTransition = VariableTransition::fromSAS(istream, m_variables);
if (&variableTransition.valueBefore != &Value::Any)
operator_.preconditions.push_back({variableTransition.variable, variableTransition.valueBefore});
if (&variableTransition.valueBefore() != &Value::Any)
operator_.preconditions.emplace_back(AssignedVariable(variableTransition.variable(), variableTransition.valueBefore()));
const Effect::Condition postcondition = {variableTransition.variable, variableTransition.valueAfter};
const Effect::Condition postcondition = {variableTransition.variable(), variableTransition.valueAfter()};
const Effect effect = {std::move(conditions), std::move(postcondition)};
operator_.effects.push_back(std::move(effect));
}
@ -484,17 +408,14 @@ void Description::parseAxiomSection(std::istream &istream)
conditions.reserve(numberOfConditions);
for (size_t j = 0; j < numberOfConditions; j++)
{
const auto condition = parseAssignedVariable(istream);
conditions.push_back(std::move(condition));
}
conditions.emplace_back(AssignedVariable::fromSAS(istream, m_variables));
const auto variableTransition = parseVariableTransition(istream);
const auto variableTransition = VariableTransition::fromSAS(istream, m_variables);
if (&variableTransition.valueBefore != &Value::Any)
conditions.push_back({variableTransition.variable, variableTransition.valueBefore});
if (&variableTransition.valueBefore() != &Value::Any)
conditions.emplace_back(AssignedVariable(variableTransition.variable(), variableTransition.valueBefore()));
const AxiomRule::Condition postcondition = {variableTransition.variable, variableTransition.valueAfter};
const AxiomRule::Condition postcondition = {variableTransition.variable(), variableTransition.valueAfter()};
const AxiomRule axiomRule = {std::move(conditions), std::move(postcondition)};
m_axiomRules.push_back(std::move(axiomRule));

View File

@ -0,0 +1,47 @@
#include <plasp/sas/MutexGroup.h>
#include <iostream>
#include <plasp/utils/Parsing.h>
namespace plasp
{
namespace sas
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// MutexGroup
//
////////////////////////////////////////////////////////////////////////////////////////////////////
MutexGroup MutexGroup::fromSAS(std::istream &istream, const std::vector<Variable> &variables)
{
MutexGroup mutexGroup;
utils::parseExpected<std::string>(istream, "begin_mutex_group");
const auto numberOfFacts = utils::parse<size_t>(istream);
mutexGroup.m_facts.reserve(numberOfFacts);
for (size_t j = 0; j < numberOfFacts; j++)
{
mutexGroup.m_facts.emplace_back(AssignedVariable::fromSAS(istream, variables));
}
utils::parseExpected<std::string>(istream, "end_mutex_group");
return mutexGroup;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
const MutexGroup::Facts &MutexGroup::facts() const
{
return m_facts;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}

View File

@ -98,7 +98,7 @@ void TranslatorASP::translate(std::ostream &ostream) const
[&](const auto &initialStateFact)
{
ostream << "init(";
initialStateFact.value.printAsASP(ostream);
initialStateFact.value().printAsASP(ostream);
ostream << ")." << std::endl;
});
@ -111,7 +111,7 @@ void TranslatorASP::translate(std::ostream &ostream) const
[&](const auto &goalFact)
{
ostream << "goal(";
goalFact.value.printAsASP(ostream);
goalFact.value().printAsASP(ostream);
ostream << ")." << std::endl;
});
@ -129,8 +129,8 @@ void TranslatorASP::translate(std::ostream &ostream) const
[&](const auto &precondition)
{
ostream << "precondition(" << operator_.predicate
<< ", " << precondition.value.name()
<< ", " << (precondition.value.sign() == Value::Sign::Positive ? "true" : "false")
<< ", " << precondition.value().name()
<< ", " << (precondition.value().sign() == Value::Sign::Positive ? "true" : "false")
<< ")." << std::endl;
});
@ -138,8 +138,8 @@ void TranslatorASP::translate(std::ostream &ostream) const
[&](const auto &effect)
{
ostream << "postcondition(" << operator_.predicate
<< ", " << effect.postcondition.value.name()
<< ", " << (effect.postcondition.value.sign() == Value::Sign::Positive ? "true" : "false")
<< ", " << effect.postcondition.value().name()
<< ", " << (effect.postcondition.value().sign() == Value::Sign::Positive ? "true" : "false")
<< ")." << std::endl;
});
});
@ -154,11 +154,11 @@ void TranslatorASP::translate(std::ostream &ostream) const
{
ostream << ":- time(T)";
std::for_each(mutexGroup.facts.cbegin(), mutexGroup.facts.cend(),
std::for_each(mutexGroup.facts().cbegin(), mutexGroup.facts().cend(),
[&](const auto &fact)
{
ostream << ", holds(";
fact.value.printAsASP(ostream);
fact.value().printAsASP(ostream);
ostream << ", T)";
});

View File

@ -2,6 +2,7 @@
#include <iostream>
#include <plasp/sas/Variable.h>
#include <plasp/utils/Parsing.h>
namespace plasp
@ -73,6 +74,21 @@ Value Value::fromSAS(std::istream &istream)
////////////////////////////////////////////////////////////////////////////////////////////////////
const Value &Value::referenceFromSAS(std::istream &istream, const Variable &variable)
{
const auto valueID = utils::parse<int>(istream);
if (valueID == -1)
return Value::Any;
if (valueID < 0 || static_cast<size_t>(valueID) >= variable.values().size())
throw utils::ParserException("Value index out of range (variable " + variable.name() + ", index " + std::to_string(valueID) + ")");
return variable.values()[valueID];
}
////////////////////////////////////////////////////////////////////////////////////////////////////
Value::Sign Value::sign() const
{
return m_sign;

View File

@ -44,6 +44,18 @@ Variable Variable::fromSAS(std::istream &istream)
////////////////////////////////////////////////////////////////////////////////////////////////////
const Variable &Variable::referenceFromSAS(std::istream &istream, const std::vector<Variable> &variables)
{
const auto variableID = utils::parse<size_t>(istream);
if (variableID >= variables.size())
throw utils::ParserException("Variable index out of range (index " + std::to_string(variableID) + ")");
return variables[variableID];
}
////////////////////////////////////////////////////////////////////////////////////////////////////
const std::string &Variable::name() const
{
return m_name;

View File

@ -0,0 +1,70 @@
#include <plasp/sas/VariableTransition.h>
#include <iostream>
#include <boost/assert.hpp>
#include <plasp/utils/Parsing.h>
namespace plasp
{
namespace sas
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// VariableTransition
//
////////////////////////////////////////////////////////////////////////////////////////////////////
VariableTransition::VariableTransition()
: m_variable{nullptr},
m_valueBefore{nullptr},
m_valueAfter{nullptr}
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
VariableTransition VariableTransition::fromSAS(std::istream &istream, const std::vector<Variable> &variables)
{
VariableTransition variableTransition;
variableTransition.m_variable = &Variable::referenceFromSAS(istream, variables);
variableTransition.m_valueBefore = &Value::referenceFromSAS(istream, *variableTransition.m_variable);
variableTransition.m_valueAfter = &Value::referenceFromSAS(istream, *variableTransition.m_variable);
return variableTransition;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
const Variable &VariableTransition::variable() const
{
BOOST_ASSERT(m_variable != nullptr);
return *m_variable;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
const Value &VariableTransition::valueBefore() const
{
BOOST_ASSERT(m_valueBefore != nullptr);
return *m_valueBefore;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
const Value &VariableTransition::valueAfter() const
{
BOOST_ASSERT(m_valueAfter != nullptr);
return *m_valueAfter;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}

View File

@ -53,18 +53,18 @@ TEST_F(SASParserTests, ParseValidSASFile)
ASSERT_EQ(description.variables()[36].values()[1].name(), "queue-tail-msg(forks-1-, fork)");
ASSERT_EQ(description.mutexGroups().size(), 8);
ASSERT_EQ(description.mutexGroups()[0].facts.size(), 9);
ASSERT_EQ(&description.mutexGroups()[0].facts[0].value, &description.variables()[0].values()[0]);
ASSERT_EQ(description.mutexGroups()[7].facts.size(), 2);
ASSERT_EQ(&description.mutexGroups()[7].facts[1].value, &description.variables()[34].values()[1]);
ASSERT_EQ(description.mutexGroups()[0].facts().size(), 9);
ASSERT_EQ(&description.mutexGroups()[0].facts()[0].value(), &description.variables()[0].values()[0]);
ASSERT_EQ(description.mutexGroups()[7].facts().size(), 2);
ASSERT_EQ(&description.mutexGroups()[7].facts()[1].value(), &description.variables()[34].values()[1]);
ASSERT_EQ(description.initialStateFacts().size(), 37);
ASSERT_EQ(&description.initialStateFacts()[0].value, &description.variables()[0].values()[8]);
ASSERT_EQ(&description.initialStateFacts()[36].value, &description.variables()[36].values()[1]);
ASSERT_EQ(&description.initialStateFacts()[0].value(), &description.variables()[0].values()[8]);
ASSERT_EQ(&description.initialStateFacts()[36].value(), &description.variables()[36].values()[1]);
ASSERT_EQ(description.goalFacts().size(), 2);
ASSERT_EQ(&description.goalFacts()[0].value, &description.variables()[6].values()[0]);
ASSERT_EQ(&description.goalFacts()[1].value, &description.variables()[7].values()[0]);
ASSERT_EQ(&description.goalFacts()[0].value(), &description.variables()[6].values()[0]);
ASSERT_EQ(&description.goalFacts()[1].value(), &description.variables()[7].values()[0]);
ASSERT_EQ(description.operators().size(), 34);
ASSERT_EQ(description.operators()[0].predicate.name, "activate-trans");
@ -72,34 +72,34 @@ TEST_F(SASParserTests, ParseValidSASFile)
ASSERT_EQ(description.operators()[0].predicate.arguments[0], "philosopher-0");
ASSERT_EQ(description.operators()[0].predicate.arguments[4], "state-3");
ASSERT_EQ(description.operators()[0].preconditions.size(), 3);
ASSERT_EQ(&description.operators()[0].preconditions[0].value, &description.variables()[4].values()[4]);
ASSERT_EQ(&description.operators()[0].preconditions[1].value, &description.variables()[16].values()[1]);
ASSERT_EQ(&description.operators()[0].preconditions[2].value, &description.variables()[0].values()[8]);
ASSERT_EQ(&description.operators()[0].preconditions[0].value(), &description.variables()[4].values()[4]);
ASSERT_EQ(&description.operators()[0].preconditions[1].value(), &description.variables()[16].values()[1]);
ASSERT_EQ(&description.operators()[0].preconditions[2].value(), &description.variables()[0].values()[8]);
ASSERT_EQ(description.operators()[0].effects.size(), 1);
ASSERT_EQ(description.operators()[0].effects[0].conditions.size(), 0);
ASSERT_EQ(&description.operators()[0].effects[0].postcondition.value, &description.variables()[0].values()[0]);
ASSERT_EQ(&description.operators()[0].effects[0].postcondition.value(), &description.variables()[0].values()[0]);
ASSERT_EQ(description.operators()[33].predicate.name, "queue-write");
ASSERT_EQ(description.operators()[33].predicate.arguments.size(), 4);
ASSERT_EQ(description.operators()[33].predicate.arguments[0], "philosopher-1");
ASSERT_EQ(description.operators()[33].predicate.arguments[3], "fork");
ASSERT_EQ(description.operators()[33].preconditions.size(), 2);
ASSERT_EQ(&description.operators()[33].preconditions[0].value, &description.variables()[1].values()[3]);
ASSERT_EQ(&description.operators()[33].preconditions[1].value, &description.variables()[2].values()[2]);
ASSERT_EQ(&description.operators()[33].preconditions[0].value(), &description.variables()[1].values()[3]);
ASSERT_EQ(&description.operators()[33].preconditions[1].value(), &description.variables()[2].values()[2]);
ASSERT_EQ(description.operators()[33].effects.size(), 3);
ASSERT_EQ(description.operators()[33].effects[0].conditions.size(), 0);
ASSERT_EQ(&description.operators()[33].effects[0].postcondition.value, &description.variables()[1].values()[7]);
ASSERT_EQ(&description.operators()[33].effects[2].postcondition.value, &description.variables()[35].values()[0]);
ASSERT_EQ(&description.operators()[33].effects[0].postcondition.value(), &description.variables()[1].values()[7]);
ASSERT_EQ(&description.operators()[33].effects[2].postcondition.value(), &description.variables()[35].values()[0]);
ASSERT_EQ(description.axiomRules().size(), 33);
ASSERT_EQ(description.axiomRules()[0].conditions.size(), 4);
ASSERT_EQ(&description.axiomRules()[0].conditions[0].value, &description.variables()[0].values()[0]);
ASSERT_EQ(&description.axiomRules()[0].conditions[2].value, &description.variables()[27].values()[0]);
ASSERT_EQ(&description.axiomRules()[0].conditions[3].value, &description.variables()[8].values()[1]);
ASSERT_EQ(&description.axiomRules()[0].postcondition.value, &description.variables()[8].values()[0]);
ASSERT_EQ(&description.axiomRules()[0].conditions[0].value(), &description.variables()[0].values()[0]);
ASSERT_EQ(&description.axiomRules()[0].conditions[2].value(), &description.variables()[27].values()[0]);
ASSERT_EQ(&description.axiomRules()[0].conditions[3].value(), &description.variables()[8].values()[1]);
ASSERT_EQ(&description.axiomRules()[0].postcondition.value(), &description.variables()[8].values()[0]);
ASSERT_EQ(description.axiomRules()[32].conditions.size(), 2);
ASSERT_EQ(&description.axiomRules()[32].conditions[0].value, &description.variables()[15].values()[0]);
ASSERT_EQ(&description.axiomRules()[32].conditions[1].value, &description.variables()[25].values()[0]);
ASSERT_EQ(&description.axiomRules()[32].postcondition.value, &description.variables()[25].values()[1]);
ASSERT_EQ(&description.axiomRules()[32].conditions[0].value(), &description.variables()[15].values()[0]);
ASSERT_EQ(&description.axiomRules()[32].conditions[1].value(), &description.variables()[25].values()[0]);
ASSERT_EQ(&description.axiomRules()[32].postcondition.value(), &description.variables()[25].values()[1]);
}
catch (const std::exception &e)
{