Browse Source

Refactored the parsing and lineFeeding handling.

Former-commit-id: 5f46c55c22
tempestpy_adaptions
PBerger 12 years ago
parent
commit
bf5de84ab9
  1. 31
      src/parser/AtomicPropositionLabelingParser.cpp
  2. 33
      src/parser/Parser.cpp
  3. 5
      src/parser/Parser.h
  4. 2
      src/storage/BitVector.h

31
src/parser/AtomicPropositionLabelingParser.cpp

@ -61,34 +61,7 @@ storm::models::AtomicPropositionsLabeling AtomicPropositionLabelingParser(uint_f
* First run: obtain number of propositions.
*/
char separator[5];// = " \r\n\t";
switch (lineEndings) {
case SupportedLineEndingsEnum::SlashN:
separator[0] = ' ';
separator[1] = '\n';
separator[2] = '\t';
separator[3] = '\0';
separator[4] = '\0';
break;
case SupportedLineEndingsEnum::SlashR:
separator[0] = ' ';
separator[1] = '\r';
separator[2] = '\t';
separator[3] = '\0';
separator[4] = '\0';
break;
case SupportedLineEndingsEnum::SlashRN:
separator[0] = ' ';
separator[1] = '\r';
separator[2] = '\n';
separator[3] = '\t';
separator[4] = '\0';
break;
default:
case SupportedLineEndingsEnum::Unsupported:
// This Line will never be reached as the Parser would have thrown already.
throw;
break;
}
storm::parser::getMatchingSeparatorString(separator, sizeof(separator), lineEndings);
bool foundDecl = false, foundEnd = false;
uint_fast32_t proposition_count = 0;
@ -214,7 +187,7 @@ storm::models::AtomicPropositionsLabeling AtomicPropositionLabelingParser(uint_f
buf += cnt;
}
}
buf = trimWhitespaces(buf);
buf = storm::parser::trimWhitespaces(buf);
}
}
return labeling;

33
src/parser/Parser.cpp

@ -161,6 +161,39 @@ void storm::parser::scanForModelHint(char* targetBuffer, uint_fast64_t targetBuf
}
}
/*!
* @brief Returns the matching Separator-String in the format of "BLANK\t\NEWLINESYMBOL(S)\0
*/
void storm::parser::getMatchingSeparatorString(char* targetBuffer, uint_fast64_t targetBufferSize, storm::parser::SupportedLineEndingsEnum lineEndings) {
if (targetBufferSize < 5) {
LOG4CPLUS_ERROR(logger, "storm::parser::getMatchingSeparatorString: The passed Target Buffer is too small.");
throw;
}
switch (lineEndings) {
case SupportedLineEndingsEnum::SlashN: {
char source[] = " \n\t";
strncpy(targetBuffer, targetBufferSize, source, sizeof(source));
break;
}
case SupportedLineEndingsEnum::SlashR: {
char source[] = " \r\t";
strncpy(targetBuffer, targetBufferSize, source, sizeof(source));
break;
}
case SupportedLineEndingsEnum::SlashRN: {
char source[] = " \r\n\t";
strncpy(targetBuffer, targetBufferSize, source, sizeof(source));
break;
}
default:
case SupportedLineEndingsEnum::Unsupported:
// This Line will never be reached as the Parser would have thrown already.
LOG4CPLUS_ERROR(logger, "storm::parser::getMatchingSeparatorString: The passed lineEndings were Unsupported. Check your input file.");
throw;
break;
}
}
/*!
* Will stat the given file, open it and map it to memory.
* If anything of this fails, an appropriate exception is raised

5
src/parser/Parser.h

@ -163,6 +163,11 @@ namespace parser {
*/
void scanForModelHint(char* targetBuffer, uint_fast64_t targetBufferSize, char const* buffer, storm::parser::SupportedLineEndingsEnum lineEndings);
/*!
* @brief Returns the matching Separator-String in the format of "BLANK\t\NEWLINESYMBOL(S)\0
*/
void getMatchingSeparatorString(char* targetBuffer, uint_fast64_t targetBufferSize, storm::parser::SupportedLineEndingsEnum lineEndings);
} // namespace parser
} // namespace storm

2
src/storage/BitVector.h

@ -143,7 +143,7 @@ public:
* Copy Constructor. Performs a deep copy of the given bit vector.
* @param bv A reference to the bit vector to be copied.
*/
BitVector(BitVector const& bv) : bucketCount(bv.bucketCount), bitCount(bv.bitCount), endIterator(*this, bitCount, bitCount, false), truncateMask((1ll << (bitCount & mod64mask)) - 1ll) {
BitVector(const BitVector & bv) : bucketCount(bv.bucketCount), bitCount(bv.bitCount), endIterator(*this, bitCount, bitCount, false), truncateMask((1ll << (bitCount & mod64mask)) - 1ll) {
LOG4CPLUS_DEBUG(logger, "Invoking copy constructor.");
bucketArray = new uint64_t[bucketCount];
std::copy(bv.bucketArray, bv.bucketArray + this->bucketCount, this->bucketArray);

Loading…
Cancel
Save