gereon
12 years ago
7 changed files with 101 additions and 52 deletions
-
16src/parser/parser.h
-
5src/parser/readLabFile.h
-
32src/parser/readPctlFile.cpp
-
15src/parser/readPctlFile.h
-
66src/parser/readPrctlFile.cpp
-
15src/parser/readPrctlFile.h
-
4src/parser/readTraFile.h
@ -1,32 +0,0 @@ |
|||
#include "src/parser/readPctlFile.h"
|
|||
|
|||
#include <boost/spirit/include/classic_core.hpp>
|
|||
#include <boost/spirit/include/qi_grammar.hpp>
|
|||
#include <boost/spirit/include/qi.hpp>
|
|||
#include <boost/spirit/include/qi_char_class.hpp>
|
|||
|
|||
namespace bs = boost::spirit; |
|||
namespace bsq = bs::qi; |
|||
|
|||
namespace |
|||
{ |
|||
using namespace bsq; |
|||
struct Parser : public bsq::grammar< char const* > |
|||
{ |
|||
typedef rule< char const* > rule_t; |
|||
|
|||
rule_t atom, term, formula; |
|||
|
|||
Parser() : Parser::base_type(formula, "PCTL parser") |
|||
{ |
|||
atom = double_ | (char_('(') >> formula >> char_(')') ); |
|||
term = atom >> *( char_('*') >> atom ); |
|||
formula = term >> *( char_('+') >> term ); |
|||
} |
|||
}; |
|||
} |
|||
|
|||
void readPctlFile(const char* filename) |
|||
{ |
|||
Parser p; |
|||
} |
@ -1,15 +0,0 @@ |
|||
#ifndef READPCTLFILE_H_ |
|||
#define READPCTLFILE_H_ |
|||
|
|||
namespace mrmc { |
|||
namespace parser { |
|||
|
|||
/*! |
|||
* @brief Load PCTL file |
|||
*/ |
|||
void readPctlFile(const char * filename); |
|||
|
|||
} // namespace parser |
|||
} // namespace mrmc |
|||
|
|||
#endif /* READPCTLFILE_H_ */ |
@ -0,0 +1,66 @@ |
|||
#include "src/parser/readPrctlFile.h"
|
|||
|
|||
#include "src/parser/parser.h"
|
|||
|
|||
#include <iostream>
|
|||
|
|||
#include <boost/spirit/include/classic_core.hpp>
|
|||
#include <boost/spirit/include/qi_grammar.hpp>
|
|||
#include <boost/spirit/include/qi.hpp>
|
|||
#include <boost/spirit/include/qi_char_class.hpp>
|
|||
|
|||
namespace bs = boost::spirit; |
|||
|
|||
namespace |
|||
{ |
|||
using namespace bs::qi; |
|||
using namespace bs::standard; |
|||
|
|||
struct PRCTLParser : public grammar< char const* > |
|||
{ |
|||
typedef rule< char const* > rule_t; |
|||
|
|||
/*!
|
|||
* @brief Generic Nonterminals. |
|||
*/ |
|||
rule_t variable, value; |
|||
|
|||
/*!
|
|||
* @brief Nonterminals for file header. |
|||
*/ |
|||
rule_t varDef, type; |
|||
|
|||
/*!
|
|||
* @brief Nonterminals for formula. |
|||
*/ |
|||
rule_t formula, opP; |
|||
|
|||
/*!
|
|||
* @brief Nonterminals for high-level file structure. |
|||
*/ |
|||
rule_t file, header; |
|||
|
|||
PRCTLParser() : PRCTLParser::base_type(file, "PRCTL parser") |
|||
{ |
|||
variable = alnum; |
|||
value = int_ | double_; |
|||
type = string("int") | string("double"); |
|||
varDef = string("const") >> type >> variable >> string("=") >> value >> string(";"); |
|||
|
|||
header = *( varDef ); |
|||
|
|||
file = header; |
|||
} |
|||
}; |
|||
} |
|||
|
|||
void readPrctlFile(const char* filename) |
|||
{ |
|||
PRCTLParser p; |
|||
mrmc::parser::MappedFile file(filename); |
|||
|
|||
if (bs::qi::parse< char const* >(file.data, file.dataend, p)) |
|||
{ |
|||
std::cout << "File was parsed" << std::endl; |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
#ifndef READPRCTLFILE_H_ |
|||
#define READPRCTLFILE_H_ |
|||
|
|||
namespace mrmc { |
|||
namespace parser { |
|||
|
|||
/*! |
|||
* @brief Load PRCTL file |
|||
*/ |
|||
void readPrctlFile(const char * filename); |
|||
|
|||
} // namespace parser |
|||
} // namespace mrmc |
|||
|
|||
#endif /* READPRCTLFILE_H_ */ |
Write
Preview
Loading…
Cancel
Save
Reference in new issue