|
@ -7,20 +7,22 @@ |
|
|
|
|
|
|
|
|
#include "src/parser/AtomicPropositionLabelingParser.h"
|
|
|
#include "src/parser/AtomicPropositionLabelingParser.h"
|
|
|
|
|
|
|
|
|
#include "src/exceptions/WrongFileFormatException.h"
|
|
|
|
|
|
#include "src/exceptions/FileIoException.h"
|
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
#include <locale.h>
|
|
|
|
|
|
|
|
|
#include "src/utility/OsDetection.h"
|
|
|
|
|
|
#include <cstdlib>
|
|
|
#include <cstdlib>
|
|
|
#include <cstdio>
|
|
|
#include <cstdio>
|
|
|
#include <cstring>
|
|
|
#include <cstring>
|
|
|
|
|
|
#include <string>
|
|
|
#include <clocale>
|
|
|
#include <clocale>
|
|
|
#include <iostream>
|
|
|
#include <iostream>
|
|
|
#include <errno.h>
|
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
#include <locale.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "src/exceptions/WrongFileFormatException.h"
|
|
|
|
|
|
#include "src/exceptions/FileIoException.h"
|
|
|
|
|
|
#include "src/utility/OsDetection.h"
|
|
|
|
|
|
|
|
|
#include "log4cplus/logger.h"
|
|
|
#include "log4cplus/logger.h"
|
|
|
#include "log4cplus/loggingmacros.h"
|
|
|
#include "log4cplus/loggingmacros.h"
|
|
@ -40,16 +42,15 @@ namespace parser { |
|
|
*/ |
|
|
*/ |
|
|
AtomicPropositionLabelingParser::AtomicPropositionLabelingParser(uint_fast64_t node_count, |
|
|
AtomicPropositionLabelingParser::AtomicPropositionLabelingParser(uint_fast64_t node_count, |
|
|
std::string const & filename) |
|
|
std::string const & filename) |
|
|
: labeling(nullptr) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
: labeling(nullptr) { |
|
|
/*
|
|
|
/*
|
|
|
* open file |
|
|
|
|
|
|
|
|
* Open file. |
|
|
*/ |
|
|
*/ |
|
|
MappedFile file(filename.c_str()); |
|
|
MappedFile file(filename.c_str()); |
|
|
char* buf = file.data; |
|
|
char* buf = file.data; |
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
|
* first run: obtain number of propositions |
|
|
|
|
|
|
|
|
* First run: obtain number of propositions. |
|
|
*/ |
|
|
*/ |
|
|
char separator[] = " \r\n\t"; |
|
|
char separator[] = " \r\n\t"; |
|
|
bool foundDecl = false, foundEnd = false; |
|
|
bool foundDecl = false, foundEnd = false; |
|
@ -57,7 +58,7 @@ AtomicPropositionLabelingParser::AtomicPropositionLabelingParser(uint_fast64_t n |
|
|
{ |
|
|
{ |
|
|
size_t cnt = 0; |
|
|
size_t cnt = 0; |
|
|
/*
|
|
|
/*
|
|
|
* iterate over tokens until we hit #END or end of file |
|
|
|
|
|
|
|
|
* Iterate over tokens until we hit #END or end of file. |
|
|
*/ |
|
|
*/ |
|
|
while(buf[0] != '\0') { |
|
|
while(buf[0] != '\0') { |
|
|
buf += cnt; |
|
|
buf += cnt; |
|
@ -71,22 +72,23 @@ AtomicPropositionLabelingParser::AtomicPropositionLabelingParser(uint_fast64_t n |
|
|
if (strncmp(buf, "#DECLARATION", cnt) == 0) { |
|
|
if (strncmp(buf, "#DECLARATION", cnt) == 0) { |
|
|
foundDecl = true; |
|
|
foundDecl = true; |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
|
|
|
else if (strncmp(buf, "#END", cnt) == 0) { |
|
|
|
|
|
|
|
|
} else if (strncmp(buf, "#END", cnt) == 0) { |
|
|
foundEnd = true; |
|
|
foundEnd = true; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
proposition_count++; |
|
|
proposition_count++; |
|
|
} else buf++; // next char is separator, one step forward
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
buf++; // next char is separator, one step forward
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
|
* If #DECLARATION or #END were not found, the file format is wrong |
|
|
* If #DECLARATION or #END were not found, the file format is wrong |
|
|
*/ |
|
|
*/ |
|
|
if (! (foundDecl && foundEnd)) { |
|
|
|
|
|
|
|
|
if (!(foundDecl && foundEnd)) { |
|
|
LOG4CPLUS_ERROR(logger, "Wrong file format in (" << filename << "). File header is corrupted."); |
|
|
LOG4CPLUS_ERROR(logger, "Wrong file format in (" << filename << "). File header is corrupted."); |
|
|
if (! foundDecl) LOG4CPLUS_ERROR(logger, "\tDid not find #DECLARATION token."); |
|
|
|
|
|
if (! foundEnd) LOG4CPLUS_ERROR(logger, "\tDid not find #END token."); |
|
|
|
|
|
|
|
|
if (!foundDecl) LOG4CPLUS_ERROR(logger, "\tDid not find #DECLARATION token."); |
|
|
|
|
|
if (!foundEnd) LOG4CPLUS_ERROR(logger, "\tDid not find #END token."); |
|
|
throw storm::exceptions::WrongFileFormatException(); |
|
|
throw storm::exceptions::WrongFileFormatException(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -129,7 +131,9 @@ AtomicPropositionLabelingParser::AtomicPropositionLabelingParser(uint_fast64_t n |
|
|
strncpy(proposition, buf, cnt); |
|
|
strncpy(proposition, buf, cnt); |
|
|
proposition[cnt] = '\0'; |
|
|
proposition[cnt] = '\0'; |
|
|
this->labeling->addAtomicProposition(proposition); |
|
|
this->labeling->addAtomicProposition(proposition); |
|
|
} else cnt = 1; // next char is separator, one step forward
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
cnt = 1; // next char is separator, one step forward
|
|
|
|
|
|
} |
|
|
} while (cnt > 0); |
|
|
} while (cnt > 0); |
|
|
/*
|
|
|
/*
|
|
|
* Right here, the buf pointer is still pointing to our last token, |
|
|
* Right here, the buf pointer is still pointing to our last token, |
|
@ -178,5 +182,5 @@ AtomicPropositionLabelingParser::AtomicPropositionLabelingParser(uint_fast64_t n |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} //namespace parser
|
|
|
|
|
|
} //namespace storm
|
|
|
|
|
|
|
|
|
} // namespace parser
|
|
|
|
|
|
} // namespace storm
|