Browse Source

The MA transition parser is now able to handle arbitrary labels.

Former-commit-id: 9643f41141
tempestpy_adaptions
masawei 11 years ago
parent
commit
9ce47989ed
  1. 12
      src/parser/MarkovAutomatonSparseTransitionParser.cpp
  2. 12
      src/parser/Parser.cpp
  3. 5
      src/parser/Parser.h

12
src/parser/MarkovAutomatonSparseTransitionParser.cpp

@ -57,12 +57,12 @@ namespace storm {
// Depending on the action name, the choice is either a probabilitic one or a markovian one.
bool isMarkovianChoice = false;
if (buf[0] == '!') {
if (buf[0] == '!' && skipWord(buf) - buf == 1) {
isMarkovianChoice = true;
} else {
}else {
isMarkovianChoice = false;
}
++buf;
buf = skipWord(buf);
if (isMarkovianChoice) {
if (stateHasMarkovianChoice) {
@ -99,7 +99,7 @@ namespace storm {
}
} else if (buf[0] == '*') {
// As we have encountered a "*", we know that there is an additional successor state for the current choice.
++buf;
buf= skipWord(buf);
// Now we need to read the successor state and check if we already saw a higher state index.
target = checked_strtol(buf, &buf);
@ -180,7 +180,7 @@ namespace storm {
// Depending on the action name, the choice is either a probabilitic one or a markovian one.
bool isMarkovianChoice = false;
if (buf[0] == '!') {
if (buf[0] == '!' && skipWord(buf) - buf == 1) {
isMarkovianChoice = true;
// Mark the current state as a Markovian one.
@ -209,7 +209,7 @@ namespace storm {
hasSuccessorState = true;
// As we have encountered a "*", we know that there is an additional successor state for the current choice.
++buf;
buf = skipWord(buf);
// Now we need to read the successor state and check if we already saw a higher state index.
target = checked_strtol(buf, &buf);

12
src/parser/Parser.cpp

@ -60,7 +60,16 @@ bool storm::parser::fileExistsAndIsReadable(const char* fileName) {
}
/*!
* Skips spaces, tabs, newlines and carriage returns. Returns pointer
* Skips all numbers, letters and special characters.
* Returns a pointer to the first char that is a whitespace.
*/
char* storm::parser::skipWord(char* buf){
while((*buf != ' ') && (*buf != '\t') && (*buf != '\n') && (*buf != '\r')) buf++;
return buf;
}
/*!
* Skips spaces, tabs, newlines and carriage returns. Returns a pointer
* to first char that is not a whitespace.
* @param buf String buffer
* @return pointer to first non-whitespace character
@ -78,7 +87,6 @@ storm::parser::SupportedLineEndingsEnum storm::parser::findUsedLineEndings(std::
char* buf = nullptr;
char* const bufferEnd = fileMap.dataend;
bool sawR = false;
for (buf = fileMap.data; buf != bufferEnd; ++buf) {
if (*buf == '\r') {
// check for following \n

5
src/parser/Parser.h

@ -125,6 +125,11 @@ namespace parser {
*/
double checked_strtod(const char* str, char** end);
/*!
* @brief Skips all non whitespace characters until the next whitespace.
*/
char* skipWord(char* buf);
/*!
* @brief Skips common whitespaces in a string.
*/

Loading…
Cancel
Save