Fixed parsing issue with unexpected whitespaces in SAS files.

This commit is contained in:
Patrick Lühne 2016-08-30 13:01:22 +02:00
parent 9447912fbf
commit 76f8df13fc
6 changed files with 33 additions and 7 deletions

View File

@ -5,6 +5,7 @@
Bug Fixes:
* fixes incorrect output format of conditional effects with SAS
* fixes parsing issue with unexpected whitespaces in SAS files
## 3.0.2 (2016-08-18)

View File

@ -27,6 +27,11 @@ class PDDLParserPolicy
return std::iswspace(c);
}
static bool isBlankCharacter(char c)
{
return std::isblank(c);
}
static bool isIdentifierCharacter(char c)
{
return c != '?'

View File

@ -72,6 +72,7 @@ class Parser: public Stream, public ParserPolicy
std::string parseLine();
void skipWhiteSpace();
void skipBlankSpace();
void skipLine();
private:
@ -124,6 +125,17 @@ void Parser<ParserPolicy>::skipWhiteSpace()
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
void Parser<ParserPolicy>::skipBlankSpace()
{
check();
while (!atEnd() && ParserPolicy::isBlankCharacter(currentCharacter()))
advance();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
template<class ParserPolicy>
void Parser<ParserPolicy>::skipLine()
{

View File

@ -27,6 +27,11 @@ class CaseSensitiveParserPolicy
return std::iswspace(c);
}
static bool isBlankCharacter(char c)
{
return std::isblank(c);
}
static bool isIdentifierCharacter(char c)
{
return std::isgraph(c);
@ -48,6 +53,11 @@ class CaseInsensitiveParserPolicy
return std::iswspace(c);
}
static bool isBlankCharacter(char c)
{
return std::isblank(c);
}
static bool isIdentifierCharacter(char c)
{
return std::isgraph(c);

View File

@ -30,14 +30,10 @@ Predicate Predicate::fromSAS(utils::Parser<> &parser)
while (true)
{
// Parse arguments until reaching newline
// TODO: reimplement
/*parser.skipWhiteSpace(
[&](const auto character)
{
return character != '\n' && std::isspace(character);
});*/
// Skip whitespace but not newlines
parser.skipBlankSpace();
// TODO: check \r handling
if (parser.currentCharacter() == '\n')
break;

View File

@ -111,6 +111,8 @@ TEST_F(SASParserTests, ParseValidSASFile)
{
FAIL() << e.what();
}
// TODO: add whitespace test
}
////////////////////////////////////////////////////////////////////////////////////////////////////