|
|
@ -7,20 +7,22 @@ |
|
|
|
|
|
|
|
#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 <cstdio>
|
|
|
|
#include <cstring>
|
|
|
|
#include <string>
|
|
|
|
#include <clocale>
|
|
|
|
#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/loggingmacros.h"
|
|
|
@ -40,16 +42,15 @@ namespace parser { |
|
|
|
*/ |
|
|
|
AtomicPropositionLabelingParser::AtomicPropositionLabelingParser(uint_fast64_t node_count, |
|
|
|
std::string const & filename) |
|
|
|
: labeling(nullptr) |
|
|
|
{ |
|
|
|
: labeling(nullptr) { |
|
|
|
/*
|
|
|
|
* open file |
|
|
|
* Open file. |
|
|
|
*/ |
|
|
|
MappedFile file(filename.c_str()); |
|
|
|
char* buf = file.data; |
|
|
|
|
|
|
|
/*
|
|
|
|
* first run: obtain number of propositions |
|
|
|
* First run: obtain number of propositions. |
|
|
|
*/ |
|
|
|
char separator[] = " \r\n\t"; |
|
|
|
bool foundDecl = false, foundEnd = false; |
|
|
@ -57,7 +58,7 @@ AtomicPropositionLabelingParser::AtomicPropositionLabelingParser(uint_fast64_t n |
|
|
|
{ |
|
|
|
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') { |
|
|
|
buf += cnt; |
|
|
@ -71,22 +72,23 @@ AtomicPropositionLabelingParser::AtomicPropositionLabelingParser(uint_fast64_t n |
|
|
|
if (strncmp(buf, "#DECLARATION", cnt) == 0) { |
|
|
|
foundDecl = true; |
|
|
|
continue; |
|
|
|
} |
|
|
|
else if (strncmp(buf, "#END", cnt) == 0) { |
|
|
|
} else if (strncmp(buf, "#END", cnt) == 0) { |
|
|
|
foundEnd = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
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 (! (foundDecl && foundEnd)) { |
|
|
|
if (!(foundDecl && foundEnd)) { |
|
|
|
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(); |
|
|
|
} |
|
|
|
} |
|
|
@ -129,7 +131,9 @@ AtomicPropositionLabelingParser::AtomicPropositionLabelingParser(uint_fast64_t n |
|
|
|
strncpy(proposition, buf, cnt); |
|
|
|
proposition[cnt] = '\0'; |
|
|
|
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); |
|
|
|
/*
|
|
|
|
* 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
|