From dd03c85fea8c1da45bee860a3ea397093aa5e0e3 Mon Sep 17 00:00:00 2001 From: gereon Date: Sun, 2 Dec 2012 19:13:48 +0100 Subject: [PATCH] porting PRCTLParser to class API --- src/parser/readPrctlFile.cpp | 12 ++++++------ src/parser/readPrctlFile.h | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/parser/readPrctlFile.cpp b/src/parser/readPrctlFile.cpp index 40aa6deb4..0d744134b 100644 --- a/src/parser/readPrctlFile.cpp +++ b/src/parser/readPrctlFile.cpp @@ -24,7 +24,7 @@ namespace using namespace bs::qi; using namespace bs::standard; - struct PRCTLParser : public grammar< char const* > + struct SpiritParser : public grammar< char const* > { typedef rule< char const* > rule_none; typedef rule< char const*, double() > rule_double; @@ -83,7 +83,7 @@ namespace } }; - PRCTLParser() : PRCTLParser::base_type(file, "PRCTL parser") + SpiritParser() : SpiritParser::base_type(file, "PRCTL parser") { variable %= alnum; ws = *( space ); @@ -106,9 +106,9 @@ namespace }; } -mrmc::formula::PCTLFormula* mrmc::parser::readPrctlFile(const char* filename) +mrmc::parser::PRCTLParser::PRCTLParser(const char* filename) { - PRCTLParser p; + SpiritParser p; mrmc::parser::MappedFile file(filename); char* data = file.data; @@ -117,7 +117,7 @@ mrmc::formula::PCTLFormula* mrmc::parser::readPrctlFile(const char* filename) std::cout << "File was parsed" << std::endl; std::string rest(data, file.dataend); std::cout << "Rest: " << rest << std::endl; - return p.result; + this->formula = p.result; } - else return NULL; + else this->formula = NULL; } diff --git a/src/parser/readPrctlFile.h b/src/parser/readPrctlFile.h index 80393482d..8aceefd87 100644 --- a/src/parser/readPrctlFile.h +++ b/src/parser/readPrctlFile.h @@ -2,6 +2,7 @@ #define READPRCTLFILE_H_ #include "src/formula/PCTLformula.h" +#include "src/parser/parser.h" namespace mrmc { namespace parser { @@ -9,7 +10,22 @@ namespace parser { /*! * @brief Load PRCTL file */ -mrmc::formula::PCTLFormula* readPrctlFile(const char * filename); +class PRCTLParser : Parser +{ + public: + PRCTLParser(const char * filename); + + /*! + * @brief return formula object parsed from file. + */ + mrmc::formula::PCTLFormula* getFormula() + { + return this->formula; + } + + private: + mrmc::formula::PCTLFormula* formula; +}; } // namespace parser } // namespace mrmc