|
|
@ -44,36 +44,27 @@ namespace storm { |
|
|
|
notStateFormula = (-unaryBooleanOperator_ >> atomicStateFormula)[qi::_val = phoenix::bind(&FormulaParser::createUnaryBooleanStateFormula, phoenix::ref(*this), qi::_2, qi::_1)]; |
|
|
|
notStateFormula.name("negation formula"); |
|
|
|
|
|
|
|
eventuallyFormula = (qi::lit("F") >> simpleFormula)[qi::_val = phoenix::bind(&FormulaParser::createEventuallyFormula, phoenix::ref(*this), qi::_1)]; |
|
|
|
eventuallyFormula = (qi::lit("F") >> -(qi::lit("<=") >> qi::uint_) >> pathFormulaWithoutUntil)[qi::_val = phoenix::bind(&FormulaParser::createEventuallyFormula, phoenix::ref(*this), qi::_1, qi::_2)]; |
|
|
|
eventuallyFormula.name("eventually formula"); |
|
|
|
|
|
|
|
globallyFormula = (qi::lit("G") >> simpleFormula)[qi::_val = phoenix::bind(&FormulaParser::createGloballyFormula, phoenix::ref(*this), qi::_1)]; |
|
|
|
globallyFormula = (qi::lit("G") >> pathFormulaWithoutUntil)[qi::_val = phoenix::bind(&FormulaParser::createGloballyFormula, phoenix::ref(*this), qi::_1)]; |
|
|
|
globallyFormula.name("globally formula"); |
|
|
|
|
|
|
|
nextFormula = (qi::lit("X") >> simpleFormula)[qi::_val = phoenix::bind(&FormulaParser::createNextFormula, phoenix::ref(*this), qi::_1)]; |
|
|
|
nextFormula = (qi::lit("X") >> pathFormulaWithoutUntil)[qi::_val = phoenix::bind(&FormulaParser::createNextFormula, phoenix::ref(*this), qi::_1)]; |
|
|
|
nextFormula.name("next formula"); |
|
|
|
|
|
|
|
boundedUntilFormula = (simpleFormula >> (qi::lit("U<=") >> qi::uint_ >> simpleFormula))[qi::_val = phoenix::bind(&FormulaParser::createBoundedUntilFormula, phoenix::ref(*this), qi::_1, qi::_2, qi::_3)]; |
|
|
|
boundedUntilFormula.name("bounded until formula"); |
|
|
|
pathFormulaWithoutUntil = eventuallyFormula | globallyFormula | nextFormula | stateFormula; |
|
|
|
pathFormulaWithoutUntil.name("path formula"); |
|
|
|
|
|
|
|
untilFormula = (simpleFormula >> (qi::lit("U") >> simpleFormula))[qi::_val = phoenix::bind(&FormulaParser::createUntilFormula, phoenix::ref(*this), qi::_1, qi::_2)]; |
|
|
|
untilFormula = pathFormulaWithoutUntil[qi::_val = qi::_1] >> *(qi::lit("U") >> -(qi::lit("<=") >> qi::uint_) >> pathFormulaWithoutUntil)[qi::_val = phoenix::bind(&FormulaParser::createUntilFormula, phoenix::ref(*this), qi::_val, qi::_1, qi::_2)]; |
|
|
|
untilFormula.name("until formula"); |
|
|
|
|
|
|
|
simplePathFormula = eventuallyFormula | globallyFormula | nextFormula | boundedUntilFormula | untilFormula; |
|
|
|
simplePathFormula.name("simple path formula"); |
|
|
|
|
|
|
|
conditionalFormula = (simplePathFormula >> (qi::lit("||") > simplePathFormula))[qi::_val = phoenix::bind(&FormulaParser::createConditionalFormula, phoenix::ref(*this), qi::_1, qi::_2)]; |
|
|
|
conditionalFormula = untilFormula[qi::_val = qi::_1] >> *(qi::lit("||") >> untilFormula)[qi::_val = phoenix::bind(&FormulaParser::createConditionalFormula, phoenix::ref(*this), qi::_val, qi::_1)]; |
|
|
|
conditionalFormula.name("conditional formula"); |
|
|
|
|
|
|
|
pathFormula = conditionalFormula | simplePathFormula; |
|
|
|
pathFormula = conditionalFormula; |
|
|
|
pathFormula.name("path formula"); |
|
|
|
|
|
|
|
simpleFormula = stateFormula | simplePathFormula; |
|
|
|
simpleFormula.name("simple formula"); |
|
|
|
|
|
|
|
formula = stateFormula | pathFormula; |
|
|
|
formula.name("formula"); |
|
|
|
|
|
|
|
operatorInformation = (-optimalityOperator_[qi::_a = qi::_1] >> ((relationalOperator_[qi::_b = qi::_1] > qi::double_[qi::_c = qi::_1]) | (qi::lit("=") > qi::lit("?"))))[qi::_val = phoenix::construct<std::tuple<boost::optional<storm::logic::OptimalityType>, boost::optional<storm::logic::ComparisonType>, boost::optional<double>>>(qi::_a, qi::_b, qi::_c)]; |
|
|
|
operatorInformation.name("operator information"); |
|
|
|
|
|
|
@ -104,14 +95,13 @@ namespace storm { |
|
|
|
/*!
|
|
|
|
* Enable the following lines to print debug output for most the rules. |
|
|
|
debug(start); |
|
|
|
debug(comments); |
|
|
|
debug(stateFormula); |
|
|
|
debug(orStateFormula); |
|
|
|
debug(andStateFormula); |
|
|
|
debug(probabilityOperator); |
|
|
|
debug(rewardOperator); |
|
|
|
debug(steadyStateOperator); |
|
|
|
debug(formula); |
|
|
|
debug(pathFormulaWithoutUntil); |
|
|
|
debug(pathFormula); |
|
|
|
debug(conditionalFormula); |
|
|
|
debug(nextFormula); |
|
|
@ -136,7 +126,7 @@ namespace storm { |
|
|
|
qi::on_error<qi::fail>(rewardOperator, handler(qi::_1, qi::_2, qi::_3, qi::_4)); |
|
|
|
qi::on_error<qi::fail>(steadyStateOperator, handler(qi::_1, qi::_2, qi::_3, qi::_4)); |
|
|
|
qi::on_error<qi::fail>(operatorInformation, handler(qi::_1, qi::_2, qi::_3, qi::_4)); |
|
|
|
qi::on_error<qi::fail>(formula, handler(qi::_1, qi::_2, qi::_3, qi::_4)); |
|
|
|
qi::on_error<qi::fail>(pathFormulaWithoutUntil, handler(qi::_1, qi::_2, qi::_3, qi::_4)); |
|
|
|
qi::on_error<qi::fail>(pathFormula, handler(qi::_1, qi::_2, qi::_3, qi::_4)); |
|
|
|
qi::on_error<qi::fail>(conditionalFormula, handler(qi::_1, qi::_2, qi::_3, qi::_4)); |
|
|
|
qi::on_error<qi::fail>(untilFormula, handler(qi::_1, qi::_2, qi::_3, qi::_4)); |
|
|
@ -203,9 +193,13 @@ namespace storm { |
|
|
|
return std::shared_ptr<storm::logic::Formula>(new storm::logic::AtomicLabelFormula(label)); |
|
|
|
} |
|
|
|
|
|
|
|
std::shared_ptr<storm::logic::Formula> FormulaParser::createEventuallyFormula(std::shared_ptr<storm::logic::Formula> const& subformula) const { |
|
|
|
std::shared_ptr<storm::logic::Formula> FormulaParser::createEventuallyFormula(boost::optional<unsigned> const& stepBound, std::shared_ptr<storm::logic::Formula> const& subformula) const { |
|
|
|
if (stepBound) { |
|
|
|
return std::shared_ptr<storm::logic::Formula>(new storm::logic::BoundedUntilFormula(createBooleanLiteralFormula(true), subformula, static_cast<uint_fast64_t>(stepBound.get()))); |
|
|
|
} else { |
|
|
|
return std::shared_ptr<storm::logic::Formula>(new storm::logic::EventuallyFormula(subformula)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
std::shared_ptr<storm::logic::Formula> FormulaParser::createGloballyFormula(std::shared_ptr<storm::logic::Formula> const& subformula) const { |
|
|
|
return std::shared_ptr<storm::logic::Formula>(new storm::logic::GloballyFormula(subformula)); |
|
|
@ -215,12 +209,12 @@ namespace storm { |
|
|
|
return std::shared_ptr<storm::logic::Formula>(new storm::logic::NextFormula(subformula)); |
|
|
|
} |
|
|
|
|
|
|
|
std::shared_ptr<storm::logic::Formula> FormulaParser::createUntilFormula(std::shared_ptr<storm::logic::Formula> const& leftSubformula, std::shared_ptr<storm::logic::Formula> const& rightSubformula) { |
|
|
|
std::shared_ptr<storm::logic::Formula> FormulaParser::createUntilFormula(std::shared_ptr<storm::logic::Formula> const& leftSubformula, boost::optional<unsigned> const& stepBound, std::shared_ptr<storm::logic::Formula> const& rightSubformula) { |
|
|
|
if (stepBound) { |
|
|
|
return std::shared_ptr<storm::logic::Formula>(new storm::logic::BoundedUntilFormula(leftSubformula, rightSubformula, static_cast<uint_fast64_t>(stepBound.get()))); |
|
|
|
} else { |
|
|
|
return std::shared_ptr<storm::logic::Formula>(new storm::logic::UntilFormula(leftSubformula, rightSubformula)); |
|
|
|
} |
|
|
|
|
|
|
|
std::shared_ptr<storm::logic::Formula> FormulaParser::createBoundedUntilFormula(std::shared_ptr<storm::logic::Formula> const& leftSubformula, unsigned stepBound, std::shared_ptr<storm::logic::Formula> const& rightSubformula) const { |
|
|
|
return std::shared_ptr<storm::logic::Formula>(new storm::logic::BoundedUntilFormula(leftSubformula, rightSubformula, static_cast<uint_fast64_t>(stepBound))); |
|
|
|
} |
|
|
|
|
|
|
|
std::shared_ptr<storm::logic::Formula> FormulaParser::createConditionalFormula(std::shared_ptr<storm::logic::Formula> const& leftSubformula, std::shared_ptr<storm::logic::Formula> const& rightSubformula) const { |
|
|
|