|
|
@ -17,6 +17,7 @@ |
|
|
|
// Needed for file IO.
|
|
|
|
#include <fstream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
|
|
|
// Some typedefs and namespace definitions to reduce code size.
|
|
|
@ -32,19 +33,19 @@ namespace storm { |
|
|
|
namespace parser { |
|
|
|
|
|
|
|
template<typename Iterator, typename Skipper> |
|
|
|
struct PrctlParser::PrctlGrammar : qi::grammar<Iterator, storm::formula::AbstractFormula<double>*(), Skipper> { |
|
|
|
struct PrctlParser::PrctlGrammar : qi::grammar<Iterator, storm::formula::AbstractFormula<double>*(), Skipper > { |
|
|
|
PrctlGrammar() : PrctlGrammar::base_type(start) { |
|
|
|
freeIdentifierName = qi::lexeme[+(qi::alpha | qi::char_('_'))]; |
|
|
|
|
|
|
|
//This block defines rules for parsing state formulas
|
|
|
|
stateFormula %= orFormula; |
|
|
|
stateFormula.name("state formula"); |
|
|
|
andFormula = notFormula[qi::_val = qi::_1] > *(qi::lit("&") > notFormula)[qi::_val = |
|
|
|
phoenix::new_<storm::formula::And<double>>(qi::_val, qi::_1)]; |
|
|
|
andFormula.name("state formula"); |
|
|
|
orFormula = andFormula[qi::_val = qi::_1] > *(qi::lit("|") > andFormula)[qi::_val = |
|
|
|
phoenix::new_<storm::formula::Or<double>>(qi::_val, qi::_1)]; |
|
|
|
orFormula.name("state formula"); |
|
|
|
andFormula = notFormula[qi::_val = qi::_1] > *(qi::lit("&") > notFormula)[qi::_val = |
|
|
|
phoenix::new_<storm::formula::And<double>>(qi::_val, qi::_1)]; |
|
|
|
andFormula.name("state formula"); |
|
|
|
notFormula = atomicStateFormula[qi::_val = qi::_1] | (qi::lit("!") > atomicStateFormula)[qi::_val = |
|
|
|
phoenix::new_<storm::formula::Not<double>>(qi::_1)]; |
|
|
|
notFormula.name("state formula"); |
|
|
@ -101,11 +102,11 @@ struct PrctlParser::PrctlGrammar : qi::grammar<Iterator, storm::formula::Abstrac |
|
|
|
globally = (qi::lit("G") > stateFormula)[qi::_val = |
|
|
|
phoenix::new_<storm::formula::Globally<double> >(qi::_1)]; |
|
|
|
globally.name("path formula"); |
|
|
|
boundedUntil = (stateFormula >> qi::lit("U") >> qi::lit("<=") > qi::int_ > stateFormula)[qi::_val = |
|
|
|
phoenix::new_<storm::formula::BoundedUntil<double>>(qi::_1, qi::_3, qi::_2)]; |
|
|
|
boundedUntil = (stateFormula[qi::_a = phoenix::construct<std::shared_ptr<storm::formula::AbstractStateFormula<double>>>(qi::_1)] >> qi::lit("U") >> qi::lit("<=") > qi::int_ > stateFormula) |
|
|
|
[qi::_val = phoenix::new_<storm::formula::BoundedUntil<double>>(phoenix::bind(&storm::formula::AbstractStateFormula<double>::clone, phoenix::bind(&std::shared_ptr<storm::formula::AbstractStateFormula<double>>::get, qi::_a)), qi::_3, qi::_2)]; |
|
|
|
boundedUntil.name("path formula"); |
|
|
|
until = (stateFormula >> qi::lit("U") > stateFormula)[qi::_val = |
|
|
|
phoenix::new_<storm::formula::Until<double>>(qi::_1, qi::_2)]; |
|
|
|
until = (stateFormula[qi::_a = phoenix::construct<std::shared_ptr<storm::formula::AbstractStateFormula<double>>>(qi::_1)] >> qi::lit("U") > stateFormula)[qi::_val = |
|
|
|
phoenix::new_<storm::formula::Until<double>>(phoenix::bind(&storm::formula::AbstractStateFormula<double>::clone, phoenix::bind(&std::shared_ptr<storm::formula::AbstractStateFormula<double>>::get, qi::_a)), qi::_2)]; |
|
|
|
until.name("path formula"); |
|
|
|
|
|
|
|
start = (noBoundOperator | stateFormula); |
|
|
@ -132,8 +133,8 @@ struct PrctlParser::PrctlGrammar : qi::grammar<Iterator, storm::formula::Abstrac |
|
|
|
qi::rule<Iterator, storm::formula::BoundedEventually<double>*(), Skipper> boundedEventually; |
|
|
|
qi::rule<Iterator, storm::formula::Eventually<double>*(), Skipper> eventually; |
|
|
|
qi::rule<Iterator, storm::formula::Globally<double>*(), Skipper> globally; |
|
|
|
qi::rule<Iterator, storm::formula::BoundedUntil<double>*(), Skipper> boundedUntil; |
|
|
|
qi::rule<Iterator, storm::formula::Until<double>*(), Skipper> until; |
|
|
|
qi::rule<Iterator, storm::formula::BoundedUntil<double>*(), qi::locals< std::shared_ptr<storm::formula::AbstractStateFormula<double>>>, Skipper> boundedUntil; |
|
|
|
qi::rule<Iterator, storm::formula::Until<double>*(), qi::locals< std::shared_ptr<storm::formula::AbstractStateFormula<double>>>, Skipper> until; |
|
|
|
|
|
|
|
qi::rule<Iterator, std::string(), Skipper> freeIdentifierName; |
|
|
|
|
|
|
@ -142,7 +143,7 @@ struct PrctlParser::PrctlGrammar : qi::grammar<Iterator, storm::formula::Abstrac |
|
|
|
} //namespace storm
|
|
|
|
} //namespace parser
|
|
|
|
|
|
|
|
void storm::parser::PrctlParser::parse(std::string formulaString) { |
|
|
|
storm::parser::PrctlParser::PrctlParser(std::string formulaString) { |
|
|
|
// Prepare iterators to input.
|
|
|
|
BaseIteratorType stringIteratorBegin = formulaString.begin(); |
|
|
|
BaseIteratorType stringIteratorEnd = formulaString.end(); |
|
|
@ -194,9 +195,3 @@ void storm::parser::PrctlParser::parse(std::string formulaString) { |
|
|
|
|
|
|
|
formula = result_pointer; |
|
|
|
} |
|
|
|
|
|
|
|
storm::parser::PrctlParser::PrctlParser(std::string formula) { |
|
|
|
// delegate the string to the parse function
|
|
|
|
// this function has to be separate, as it may be called in subclasses which don't call this constructor
|
|
|
|
parse(formula); |
|
|
|
} |