Browse Source
Almost finished restruction of PRCTL formulas; adapted code (including
Almost finished restruction of PRCTL formulas; adapted code (including
test cases) to work correctly with the new structuremain
52 changed files with 656 additions and 715 deletions
-
2src/formula/AbstractFormulaChecker.h
-
20src/formula/ComparisonType.h
-
13src/formula/Prctl.h
-
80src/formula/Prctl/AbstractNoBoundOperator.h
-
8src/formula/Prctl/AbstractPathFormula.h
-
28src/formula/Prctl/AbstractPrctlFormula.h
-
14src/formula/Prctl/AbstractStateFormula.h
-
3src/formula/Prctl/Ap.h
-
2src/formula/Prctl/Eventually.h
-
10src/formula/Prctl/Globally.h
-
4src/formula/Prctl/ProbabilisticBoundOperator.h
-
26src/formula/Prctl/ProbabilisticNoBoundOperator.h
-
18src/formula/Prctl/RewardBoundOperator.h
-
27src/formula/Prctl/RewardNoBoundOperator.h
-
2src/formula/Prctl/SteadyStateReward.h
-
8src/formula/abstract/AbstractFormula.h
-
2src/formula/abstract/And.h
-
2src/formula/abstract/Ap.h
-
2src/formula/abstract/BoundedEventually.h
-
2src/formula/abstract/BoundedNaryUntil.h
-
2src/formula/abstract/BoundedUntil.h
-
2src/formula/abstract/CumulativeReward.h
-
2src/formula/abstract/Eventually.h
-
2src/formula/abstract/Globally.h
-
2src/formula/abstract/InstantaneousReward.h
-
2src/formula/abstract/Next.h
-
2src/formula/abstract/Not.h
-
18src/formula/abstract/OptimizingOperator.h
-
2src/formula/abstract/Or.h
-
15src/formula/abstract/PathBoundOperator.h
-
37src/formula/abstract/PathNoBoundOperator.h
-
19src/formula/abstract/ProbabilisticBoundOperator.h
-
10src/formula/abstract/ProbabilisticNoBoundOperator.h
-
17src/formula/abstract/RewardBoundOperator.h
-
8src/formula/abstract/RewardNoBoundOperator.h
-
2src/formula/abstract/StateBoundOperator.h
-
2src/formula/abstract/SteadyStateReward.h
-
2src/formula/abstract/Until.h
-
52src/modelchecker/AbstractModelChecker.h
-
35src/modelchecker/SparseDtmcPrctlModelChecker.h
-
28src/modelchecker/SparseMdpPrctlModelChecker.h
-
229src/parser/CslParser.cpp
-
53src/parser/CslParser.h
-
4src/parser/PrctlFileParser.cpp
-
2src/parser/PrctlFileParser.h
-
101src/parser/PrctlParser.cpp
-
6src/parser/PrctlParser.h
-
232src/storm.cpp
-
79test/functional/GmmxxDtmcPrctModelCheckerTest.cpp
-
120test/functional/GmmxxMdpPrctModelCheckerTest.cpp
-
3test/parser/CslParserTest.cpp
-
8test/parser/PrctlParserTest.cpp
@ -0,0 +1,20 @@ |
|||
/* |
|||
* ComparisonType.h |
|||
* |
|||
* Created on: 17.04.2013 |
|||
* Author: thomas |
|||
*/ |
|||
|
|||
#ifndef STORM_FORMULA_COMPARISONTYPE_H_ |
|||
#define STORM_FORMULA_COMPARISONTYPE_H_ |
|||
|
|||
namespace storm { |
|||
namespace formula { |
|||
|
|||
enum ComparisonType { LESS, LESS_EQUAL, GREATER, GREATER_EQUAL }; |
|||
|
|||
} |
|||
} |
|||
|
|||
|
|||
#endif /* STORM_FORMULA_COMPARISONTYPE_H_ */ |
@ -0,0 +1,80 @@ |
|||
/* |
|||
* AbstractNoBoundOperator.h |
|||
* |
|||
* Created on: 16.04.2013 |
|||
* Author: thomas |
|||
*/ |
|||
|
|||
#ifndef ABSTRACTNOBOUNDOPERATOR_H_ |
|||
#define ABSTRACTNOBOUNDOPERATOR_H_ |
|||
|
|||
#include "AbstractPrctlFormula.h" |
|||
#include "src/formula/abstract/IOptimizingOperator.h" |
|||
|
|||
namespace storm { |
|||
namespace formula { |
|||
namespace prctl { |
|||
|
|||
template <class T> |
|||
class AbstractNoBoundOperator; |
|||
|
|||
/*! |
|||
* @brief Interface class for model checkers that support PathNoBoundOperator. |
|||
* |
|||
* All model checkers that support the formula class NoBoundOperator must inherit |
|||
* this pure virtual class. |
|||
*/ |
|||
template <class T> |
|||
class INoBoundOperatorModelChecker { |
|||
public: |
|||
/*! |
|||
* @brief Evaluates NoBoundOperator formula within a model checker. |
|||
* |
|||
* @param obj Formula object with subformulas. |
|||
* @return Result of the formula for every node. |
|||
*/ |
|||
virtual std::vector<T>* checkNoBoundOperator(const AbstractNoBoundOperator<T>& obj) const = 0; |
|||
|
|||
|
|||
}; |
|||
|
|||
template <class T> |
|||
class AbstractNoBoundOperator: public AbstractPrctlFormula<T>, |
|||
public virtual storm::formula::abstract::IOptimizingOperator { |
|||
public: |
|||
AbstractNoBoundOperator() { |
|||
// TODO Auto-generated constructor stub |
|||
|
|||
} |
|||
virtual ~AbstractNoBoundOperator() { |
|||
// TODO Auto-generated destructor stub |
|||
} |
|||
|
|||
/*! |
|||
* Clones the called object. |
|||
* |
|||
* Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones |
|||
* |
|||
* @note This function is not implemented in this class. |
|||
* @returns a new AND-object that is identical the called object. |
|||
*/ |
|||
virtual AbstractNoBoundOperator<T>* clone() const = 0; |
|||
|
|||
/*! |
|||
* Calls the model checker to check this formula. |
|||
* Needed to infer the correct type of formula class. |
|||
* |
|||
* @note This function should only be called in a generic check function of a model checker class. For other uses, |
|||
* the methods of the model checker should be used. |
|||
* |
|||
* @note This function is not implemented in this class. |
|||
* |
|||
* @returns A vector indicating the probability that the formula holds for each state. |
|||
*/ |
|||
virtual std::vector<T>* check(const storm::modelchecker::AbstractModelChecker<T>& modelChecker, bool qualitative=false) const = 0; |
|||
}; |
|||
|
|||
} /* namespace prctl */ |
|||
} /* namespace formula */ |
|||
} /* namespace storm */ |
|||
#endif /* ABSTRACTNOBOUNDOPERATOR_H_ */ |
@ -0,0 +1,28 @@ |
|||
/* |
|||
* AbstractPrctlFormula.h |
|||
* |
|||
* Created on: 16.04.2013 |
|||
* Author: thomas |
|||
*/ |
|||
|
|||
#ifndef STORM_FORMULA_PRCTL_ABSTRACTPRCTLFORMULA_H_ |
|||
#define STORM_FORMULA_PRCTL_ABSTRACTPRCTLFORMULA_H_ |
|||
|
|||
#include "src/formula/abstract/AbstractFormula.h" |
|||
|
|||
namespace storm { |
|||
namespace formula { |
|||
namespace prctl { |
|||
|
|||
template<class T> |
|||
class AbstractPrctlFormula : public virtual storm::formula::abstract::AbstractFormula<T> { |
|||
public: |
|||
virtual ~AbstractPrctlFormula() { |
|||
// Intentionally left empty |
|||
} |
|||
}; |
|||
|
|||
} /* namespace prctl */ |
|||
} /* namespace formula */ |
|||
} /* namespace storm */ |
|||
#endif /* ABSTRACTPRCTLFORMULA_H_ */ |
@ -1,229 +0,0 @@ |
|||
/*
|
|||
* CslParser.cpp |
|||
* |
|||
* Created on: 08.04.2013 |
|||
* Author: Thomas Heinemann |
|||
*/ |
|||
|
|||
#include "src/parser/PrctlParser.h"
|
|||
#include "src/utility/OsDetection.h"
|
|||
#include "src/utility/ConstTemplates.h"
|
|||
|
|||
// If the parser fails due to ill-formed data, this exception is thrown.
|
|||
#include "src/exceptions/WrongFormatException.h"
|
|||
|
|||
// Used for Boost spirit.
|
|||
#include <boost/typeof/typeof.hpp>
|
|||
#include <boost/spirit/include/qi.hpp>
|
|||
#include <boost/spirit/include/phoenix.hpp>
|
|||
|
|||
// Include headers for spirit iterators. Needed for diagnostics and input stream iteration.
|
|||
#include <boost/spirit/include/classic_position_iterator.hpp>
|
|||
#include <boost/spirit/include/support_multi_pass.hpp>
|
|||
|
|||
// Needed for file IO.
|
|||
#include <fstream>
|
|||
#include <iomanip>
|
|||
#include <map>
|
|||
|
|||
|
|||
// Some typedefs and namespace definitions to reduce code size.
|
|||
typedef std::string::const_iterator BaseIteratorType; |
|||
typedef boost::spirit::classic::position_iterator2<BaseIteratorType> PositionIteratorType; |
|||
namespace qi = boost::spirit::qi; |
|||
namespace phoenix = boost::phoenix; |
|||
|
|||
#include "CslParser.h"
|
|||
|
|||
|
|||
namespace storm { |
|||
namespace parser { |
|||
|
|||
template<typename Iterator, typename Skipper> |
|||
struct CslParser::CslGrammar : qi::grammar<Iterator, storm::formula::AbstractFormula<double>*(), Skipper > { |
|||
CslGrammar() : CslGrammar::base_type(start) { |
|||
freeIdentifierName = qi::lexeme[+(qi::alpha | qi::char_('_'))]; |
|||
|
|||
//This block defines rules for parsing state formulas
|
|||
stateFormula %= orFormula; |
|||
stateFormula.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"); |
|||
|
|||
//This block defines rules for "atomic" state formulas
|
|||
//(Propositions, probabilistic/reward formulas, and state formulas in brackets)
|
|||
atomicStateFormula %= probabilisticBoundOperator | steadyStateBoundOperator | atomicProposition | qi::lit("(") >> stateFormula >> qi::lit(")"); |
|||
atomicStateFormula.name("state formula"); |
|||
atomicProposition = (freeIdentifierName)[qi::_val = |
|||
phoenix::new_<storm::formula::Ap<double>>(qi::_1)]; |
|||
atomicProposition.name("state formula"); |
|||
probabilisticBoundOperator = ( |
|||
(qi::lit("P") >> qi::lit(">") >> qi::double_ > qi::lit("[") > pathFormula > qi::lit("]"))[qi::_val = |
|||
phoenix::new_<storm::formula::ProbabilisticBoundOperator<double> >(storm::formula::PathBoundOperator<double>::GREATER, qi::_1, qi::_2)] | |
|||
(qi::lit("P") >> qi::lit(">=") > qi::double_ > qi::lit("[") > pathFormula > qi::lit("]"))[qi::_val = |
|||
phoenix::new_<storm::formula::ProbabilisticBoundOperator<double> >(storm::formula::PathBoundOperator<double>::GREATER_EQUAL, qi::_1, qi::_2)] | |
|||
(qi::lit("P") >> qi::lit("<") >> qi::double_ > qi::lit("[") > pathFormula > qi::lit("]"))[qi::_val = |
|||
phoenix::new_<storm::formula::ProbabilisticBoundOperator<double> >(storm::formula::PathBoundOperator<double>::LESS, qi::_1, qi::_2)] | |
|||
(qi::lit("P") > qi::lit("<=") > qi::double_ > qi::lit("[") > pathFormula > qi::lit("]"))[qi::_val = |
|||
phoenix::new_<storm::formula::ProbabilisticBoundOperator<double> >(storm::formula::PathBoundOperator<double>::LESS_EQUAL, qi::_1, qi::_2)] |
|||
); |
|||
probabilisticBoundOperator.name("state formula"); |
|||
steadyStateBoundOperator = ( |
|||
(qi::lit("S") >> qi::lit(">") >> qi::double_ > qi::lit("[") > stateFormula > qi::lit("]"))[qi::_val = |
|||
phoenix::new_<storm::formula::SteadyStateBoundOperator<double> >(storm::formula::StateBoundOperator<double>::GREATER, qi::_1, qi::_2)] | |
|||
(qi::lit("S") >> qi::lit(">=") >> qi::double_ > qi::lit("[") > stateFormula > qi::lit("]"))[qi::_val = |
|||
phoenix::new_<storm::formula::SteadyStateBoundOperator<double> >(storm::formula::StateBoundOperator<double>::GREATER_EQUAL, qi::_1, qi::_2)] | |
|||
(qi::lit("S") >> qi::lit("<") >> qi::double_ > qi::lit("[") > stateFormula > qi::lit("]"))[qi::_val = |
|||
phoenix::new_<storm::formula::SteadyStateBoundOperator<double> >(storm::formula::StateBoundOperator<double>::LESS, qi::_1, qi::_2)] | |
|||
(qi::lit("S") > qi::lit("<=") >> qi::double_ > qi::lit("[") > stateFormula > qi::lit("]"))[qi::_val = |
|||
phoenix::new_<storm::formula::SteadyStateBoundOperator<double> >(storm::formula::StateBoundOperator<double>::LESS_EQUAL, qi::_1, qi::_2)] |
|||
); |
|||
steadyStateBoundOperator.name("state formula"); |
|||
|
|||
//This block defines rules for parsing formulas with noBoundOperators
|
|||
noBoundOperator = (probabilisticNoBoundOperator | steadyStateNoBoundOperator); |
|||
noBoundOperator.name("no bound operator"); |
|||
probabilisticNoBoundOperator = (qi::lit("P") >> qi::lit("=") >> qi::lit("?") >> qi::lit("[") >> pathFormula >> qi::lit("]"))[qi::_val = |
|||
phoenix::new_<storm::formula::ProbabilisticNoBoundOperator<double> >(qi::_1)]; |
|||
probabilisticNoBoundOperator.name("no bound operator"); |
|||
steadyStateNoBoundOperator = (qi::lit("S") >> qi::lit("=") >> qi::lit("?") >> qi::lit("[") >> stateFormula >> qi::lit("]"))[qi::_val = |
|||
phoenix::new_<storm::formula::SteadyStateNoBoundOperator<double> >(qi::_1)]; |
|||
steadyStateNoBoundOperator.name("no bound operator"); |
|||
|
|||
//This block defines rules for parsing probabilistic path formulas
|
|||
pathFormula = (timeBoundedEventually | eventually | globally | timeBoundedUntil | until); |
|||
pathFormula.name("path formula"); |
|||
timeBoundedEventually = ( |
|||
(qi::lit("F") >> qi::lit("[") > qi::double_ > qi::lit(",") > qi::double_ > qi::lit("]") > stateFormula)[qi::_val = |
|||
phoenix::new_<storm::formula::TimeBoundedEventually<double>>(qi::_1, qi::_2, qi::_3)] | |
|||
(qi::lit("F") >> (qi::lit("<=") | qi::lit("<")) > qi::double_ > stateFormula)[qi::_val = |
|||
phoenix::new_<storm::formula::TimeBoundedEventually<double>>(0, qi::_1, qi::_2)] | |
|||
(qi::lit("F") >> (qi::lit(">=") | qi::lit(">")) > qi::double_ > stateFormula)[qi::_val = |
|||
phoenix::new_<storm::formula::TimeBoundedEventually<double>>(qi::_1, std::numeric_limits<double>::infinity(), qi::_2)] |
|||
); |
|||
timeBoundedEventually.name("path formula (for probabilistic operator)"); |
|||
eventually = (qi::lit("F") > stateFormula)[qi::_val = |
|||
phoenix::new_<storm::formula::Eventually<double> >(qi::_1)]; |
|||
eventually.name("path formula (for probabilistic operator)"); |
|||
globally = (qi::lit("G") > stateFormula)[qi::_val = |
|||
phoenix::new_<storm::formula::Globally<double> >(qi::_1)]; |
|||
globally.name("path formula (for probabilistic operator)"); |
|||
timeBoundedUntil = ( |
|||
(stateFormula[qi::_a = phoenix::construct<std::shared_ptr<storm::formula::AbstractStateFormula<double>>>(qi::_1)] >> qi::lit("U") >> qi::lit("[") > qi::double_ > qi::lit(",") > qi::double_ > qi::lit("]") > stateFormula) |
|||
[qi::_val = phoenix::new_<storm::formula::TimeBoundedUntil<double>>(qi::_2, qi::_3, phoenix::bind(&storm::formula::AbstractStateFormula<double>::clone, phoenix::bind(&std::shared_ptr<storm::formula::AbstractStateFormula<double>>::get, qi::_a)), qi::_4)] | |
|||
(stateFormula[qi::_a = phoenix::construct<std::shared_ptr<storm::formula::AbstractStateFormula<double>>>(qi::_1)] >> qi::lit("U") >> (qi::lit("<=") | qi::lit("<")) > qi::double_ > stateFormula) |
|||
[qi::_val = phoenix::new_<storm::formula::TimeBoundedUntil<double>>(0, qi::_2, phoenix::bind(&storm::formula::AbstractStateFormula<double>::clone, phoenix::bind(&std::shared_ptr<storm::formula::AbstractStateFormula<double>>::get, qi::_a)), qi::_3)] | |
|||
(stateFormula[qi::_a = phoenix::construct<std::shared_ptr<storm::formula::AbstractStateFormula<double>>>(qi::_1)] >> qi::lit("U") >> (qi::lit(">=") | qi::lit(">")) > qi::double_ > stateFormula) |
|||
[qi::_val = phoenix::new_<storm::formula::TimeBoundedUntil<double>>(qi::_2, std::numeric_limits<double>::infinity(), phoenix::bind(&storm::formula::AbstractStateFormula<double>::clone, phoenix::bind(&std::shared_ptr<storm::formula::AbstractStateFormula<double>>::get, qi::_a)), qi::_3)] |
|||
); |
|||
timeBoundedUntil.name("path formula (for probabilistic operator)"); |
|||
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 (for probabilistic operator)"); |
|||
|
|||
start = (noBoundOperator | stateFormula); |
|||
start.name("CSL formula"); |
|||
} |
|||
|
|||
qi::rule<Iterator, storm::formula::AbstractFormula<double>*(), Skipper> start; |
|||
|
|||
qi::rule<Iterator, storm::formula::AbstractStateFormula<double>*(), Skipper> stateFormula; |
|||
qi::rule<Iterator, storm::formula::AbstractStateFormula<double>*(), Skipper> atomicStateFormula; |
|||
|
|||
qi::rule<Iterator, storm::formula::AbstractStateFormula<double>*(), Skipper> andFormula; |
|||
qi::rule<Iterator, storm::formula::AbstractStateFormula<double>*(), Skipper> atomicProposition; |
|||
qi::rule<Iterator, storm::formula::AbstractStateFormula<double>*(), Skipper> orFormula; |
|||
qi::rule<Iterator, storm::formula::AbstractStateFormula<double>*(), Skipper> notFormula; |
|||
qi::rule<Iterator, storm::formula::ProbabilisticBoundOperator<double>*(), Skipper> probabilisticBoundOperator; |
|||
qi::rule<Iterator, storm::formula::SteadyStateBoundOperator<double>*(), Skipper> steadyStateBoundOperator; |
|||
qi::rule<Iterator, storm::formula::RewardBoundOperator<double>*(), Skipper> rewardBoundOperator; |
|||
|
|||
qi::rule<Iterator, storm::formula::AbstractFormula<double>*(), Skipper> noBoundOperator; |
|||
qi::rule<Iterator, storm::formula::PathNoBoundOperator<double>*(), Skipper> probabilisticNoBoundOperator; |
|||
qi::rule<Iterator, storm::formula::StateNoBoundOperator<double>*(), Skipper> steadyStateNoBoundOperator; |
|||
|
|||
qi::rule<Iterator, storm::formula::AbstractPathFormula<double>*(), Skipper> pathFormula; |
|||
qi::rule<Iterator, storm::formula::TimeBoundedEventually<double>*(), Skipper> timeBoundedEventually; |
|||
qi::rule<Iterator, storm::formula::Eventually<double>*(), Skipper> eventually; |
|||
qi::rule<Iterator, storm::formula::Globally<double>*(), Skipper> globally; |
|||
qi::rule<Iterator, storm::formula::TimeBoundedUntil<double>*(), qi::locals< std::shared_ptr<storm::formula::AbstractStateFormula<double>>>, Skipper> timeBoundedUntil; |
|||
qi::rule<Iterator, storm::formula::Until<double>*(), qi::locals< std::shared_ptr<storm::formula::AbstractStateFormula<double>>>, Skipper> until; |
|||
|
|||
qi::rule<Iterator, storm::formula::AbstractPathFormula<double>*(), Skipper> rewardPathFormula; |
|||
qi::rule<Iterator, storm::formula::CumulativeReward<double>*(), Skipper> cumulativeReward; |
|||
qi::rule<Iterator, storm::formula::ReachabilityReward<double>*(), Skipper> reachabilityReward; |
|||
qi::rule<Iterator, storm::formula::InstantaneousReward<double>*(), Skipper> instantaneousReward; |
|||
qi::rule<Iterator, storm::formula::SteadyStateReward<double>*(), Skipper> steadyStateReward; |
|||
|
|||
|
|||
qi::rule<Iterator, std::string(), Skipper> freeIdentifierName; |
|||
|
|||
}; |
|||
|
|||
CslParser::CslParser(std::string formulaString) { |
|||
// Prepare iterators to input.
|
|||
BaseIteratorType stringIteratorBegin = formulaString.begin(); |
|||
BaseIteratorType stringIteratorEnd = formulaString.end(); |
|||
PositionIteratorType positionIteratorBegin(stringIteratorBegin, stringIteratorEnd, formulaString); |
|||
PositionIteratorType positionIteratorEnd; |
|||
|
|||
|
|||
// Prepare resulting intermediate representation of input.
|
|||
storm::formula::AbstractFormula<double>* result_pointer = nullptr; |
|||
|
|||
CslGrammar<PositionIteratorType, BOOST_TYPEOF(boost::spirit::ascii::space)> grammar; |
|||
|
|||
// Now, parse the formula from the given string
|
|||
try { |
|||
qi::phrase_parse(positionIteratorBegin, positionIteratorEnd, grammar, boost::spirit::ascii::space, result_pointer); |
|||
} catch(const qi::expectation_failure<PositionIteratorType>& e) { |
|||
// If the parser expected content different than the one provided, display information
|
|||
// about the location of the error.
|
|||
const boost::spirit::classic::file_position_base<std::string>& pos = e.first.get_position(); |
|||
|
|||
// Construct the error message including a caret display of the position in the
|
|||
// erroneous line.
|
|||
std::stringstream msg; |
|||
msg << pos.file << ", line " << pos.line << ", column " << pos.column |
|||
<< ": parse error: expected " << e.what_ << std::endl << "\t" |
|||
<< e.first.get_currentline() << std::endl << "\t"; |
|||
int i = 0; |
|||
for (i = 0; i < pos.column; ++i) { |
|||
msg << "-"; |
|||
} |
|||
msg << "^"; |
|||
for (; i < 80; ++i) { |
|||
msg << "-"; |
|||
} |
|||
msg << std::endl; |
|||
|
|||
std::cerr << msg.str(); |
|||
|
|||
// Now propagate exception.
|
|||
throw storm::exceptions::WrongFormatException() << msg.str(); |
|||
} |
|||
|
|||
// The syntax can be so wrong that no rule can be matched at all
|
|||
// In that case, no expectation failure is thrown, but the parser just returns nullptr
|
|||
// Then, of course the result is not usable, hence we throw a WrongFormatException, too.
|
|||
if (result_pointer == nullptr) { |
|||
throw storm::exceptions::WrongFormatException() << "Syntax error in formula"; |
|||
} |
|||
|
|||
formula = result_pointer; |
|||
} |
|||
|
|||
CslParser::~CslParser() { |
|||
// Intentionally left empty
|
|||
// Parsed formula is not deleted with the parser!
|
|||
} |
|||
|
|||
} /* namespace parser */ |
|||
} /* namespace storm */ |
@ -1,53 +0,0 @@ |
|||
/* |
|||
* CslParser.h |
|||
* |
|||
* Created on: 08.04.2013 |
|||
* Author: Thomas Heinemann |
|||
*/ |
|||
|
|||
#ifndef STORM_PARSER_CSLPARSER_H_ |
|||
#define STORM_PARSER_CSLPARSER_H_ |
|||
|
|||
#include "Parser.h" |
|||
|
|||
#include "src/formula/Formulas.h" |
|||
//#include <memory> |
|||
|
|||
namespace storm { |
|||
namespace parser { |
|||
|
|||
class CslParser: public storm::parser::Parser { |
|||
public: |
|||
/*! |
|||
* Reads a CSL formula from its string representation and parses it into a formula tree, consisting of |
|||
* classes in the namespace storm::formula. |
|||
* |
|||
* If the string could not be parsed successfully, it will throw a wrongFormatException. |
|||
* |
|||
* @param formulaString The string representation of the formula |
|||
* @throw wrongFormatException If the input could not be parsed successfully |
|||
*/ |
|||
CslParser(std::string formulaString); |
|||
virtual ~CslParser(); |
|||
|
|||
/*! |
|||
* @return a pointer to the parsed formula object |
|||
*/ |
|||
storm::formula::AbstractFormula<double>* getFormula() { |
|||
return this->formula; |
|||
} |
|||
|
|||
private: |
|||
private: |
|||
storm::formula::AbstractFormula<double>* formula; |
|||
|
|||
/*! |
|||
* Struct for the CSL grammar, that Boost::Spirit uses to parse the formulas. |
|||
*/ |
|||
template<typename Iterator, typename Skipper> |
|||
struct CslGrammar; |
|||
}; |
|||
|
|||
} /* namespace parser */ |
|||
} /* namespace storm */ |
|||
#endif /* STORM_PARSER_CSLPARSER_H_ */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue