Fixed issue with invalid suffixes on section names.
This commit is contained in:
parent
d629f50661
commit
26d7e216a6
@ -67,6 +67,8 @@ class Parser
|
|||||||
template<typename Type>
|
template<typename Type>
|
||||||
bool probe(const Type &expectedValue);
|
bool probe(const Type &expectedValue);
|
||||||
|
|
||||||
|
bool probeIdentifier(const std::string &identifier);
|
||||||
|
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
void expect(const Type &expectedValue);
|
void expect(const Type &expectedValue);
|
||||||
|
|
||||||
|
@ -75,23 +75,23 @@ void Domain::findSections()
|
|||||||
const auto sectionIdentifierPosition = parser.position();
|
const auto sectionIdentifierPosition = parser.position();
|
||||||
|
|
||||||
// Save the parser position of the individual sections for later parsing
|
// Save the parser position of the individual sections for later parsing
|
||||||
if (parser.probe<std::string>("requirements"))
|
if (parser.probeIdentifier("requirements"))
|
||||||
setSectionPosition("requirements", m_requirementsPosition, position, true);
|
setSectionPosition("requirements", m_requirementsPosition, position, true);
|
||||||
else if (parser.probe<std::string>("types"))
|
else if (parser.probeIdentifier("types"))
|
||||||
setSectionPosition("types", m_typesPosition, position, true);
|
setSectionPosition("types", m_typesPosition, position, true);
|
||||||
else if (parser.probe<std::string>("constants"))
|
else if (parser.probeIdentifier("constants"))
|
||||||
setSectionPosition("constants", m_constantsPosition, position, true);
|
setSectionPosition("constants", m_constantsPosition, position, true);
|
||||||
else if (parser.probe<std::string>("predicates"))
|
else if (parser.probeIdentifier("predicates"))
|
||||||
setSectionPosition("predicates", m_predicatesPosition, position, true);
|
setSectionPosition("predicates", m_predicatesPosition, position, true);
|
||||||
else if (parser.probe<std::string>("action"))
|
else if (parser.probeIdentifier("action"))
|
||||||
{
|
{
|
||||||
m_actionPositions.emplace_back(-1);
|
m_actionPositions.emplace_back(-1);
|
||||||
setSectionPosition("action", m_actionPositions.back(), position);
|
setSectionPosition("action", m_actionPositions.back(), position);
|
||||||
}
|
}
|
||||||
else if (parser.probe<std::string>("functions")
|
else if (parser.probeIdentifier("functions")
|
||||||
|| parser.probe<std::string>("constraints")
|
|| parser.probeIdentifier("constraints")
|
||||||
|| parser.probe<std::string>("durative-action")
|
|| parser.probeIdentifier("durative-action")
|
||||||
|| parser.probe<std::string>("derived"))
|
|| parser.probeIdentifier("derived"))
|
||||||
{
|
{
|
||||||
parser.seek(sectionIdentifierPosition);
|
parser.seek(sectionIdentifierPosition);
|
||||||
|
|
||||||
|
@ -71,18 +71,18 @@ void Problem::findSections()
|
|||||||
const auto sectionIdentifierPosition = parser.position();
|
const auto sectionIdentifierPosition = parser.position();
|
||||||
|
|
||||||
// TODO: check order of the sections
|
// TODO: check order of the sections
|
||||||
if (parser.probe<std::string>("domain"))
|
if (parser.probeIdentifier("domain"))
|
||||||
setSectionPosition("domain", m_domainPosition, position, true);
|
setSectionPosition("domain", m_domainPosition, position, true);
|
||||||
else if (parser.probe<std::string>("requirements"))
|
else if (parser.probeIdentifier("requirements"))
|
||||||
setSectionPosition("requirements", m_requirementsPosition, position, true);
|
setSectionPosition("requirements", m_requirementsPosition, position, true);
|
||||||
else if (parser.probe<std::string>("objects"))
|
else if (parser.probeIdentifier("objects"))
|
||||||
setSectionPosition("objects", m_objectsPosition, position, true);
|
setSectionPosition("objects", m_objectsPosition, position, true);
|
||||||
else if (parser.probe<std::string>("init"))
|
else if (parser.probeIdentifier("init"))
|
||||||
setSectionPosition("init", m_initialStatePosition, position, true);
|
setSectionPosition("init", m_initialStatePosition, position, true);
|
||||||
else if (parser.probe<std::string>("goal")
|
else if (parser.probeIdentifier("goal")
|
||||||
|| parser.probe<std::string>("constraints")
|
|| parser.probeIdentifier("constraints")
|
||||||
|| parser.probe<std::string>("metric")
|
|| parser.probeIdentifier("metric")
|
||||||
|| parser.probe<std::string>("length"))
|
|| parser.probeIdentifier("length"))
|
||||||
{
|
{
|
||||||
parser.seek(sectionIdentifierPosition);
|
parser.seek(sectionIdentifierPosition);
|
||||||
|
|
||||||
|
@ -284,11 +284,18 @@ bool Parser::probe<std::string>(const std::string &expectedValue)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
bool Parser::probeIdentifier(const std::string &expectedValue)
|
||||||
|
{
|
||||||
|
return probe<std::string>(expectedValue) && std::iswspace(currentCharacter());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
void Parser::expect<std::string>(const std::string &expectedValue)
|
void Parser::expect<std::string>(const std::string &expectedValue)
|
||||||
{
|
{
|
||||||
if (!probe<std::string>(expectedValue))
|
if (!probe<std::string>(expectedValue))
|
||||||
throw ParserException(*this, "Unexpected value, expected \"" + expectedValue + "\"");
|
throw ParserException(*this, "Expected \"" + expectedValue + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -322,7 +329,7 @@ template<>
|
|||||||
void Parser::expect<char>(const char &expectedValue)
|
void Parser::expect<char>(const char &expectedValue)
|
||||||
{
|
{
|
||||||
if (!probe<char>(expectedValue))
|
if (!probe<char>(expectedValue))
|
||||||
throw ParserException(*this, std::string("Unexpected value, expected \"") + expectedValue + "\"");
|
throw ParserException(*this, std::string("Expected \"") + expectedValue + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -417,7 +424,7 @@ template<>
|
|||||||
void Parser::expect<int64_t>(const int64_t &expectedValue)
|
void Parser::expect<int64_t>(const int64_t &expectedValue)
|
||||||
{
|
{
|
||||||
if (!probe<int64_t>(expectedValue))
|
if (!probe<int64_t>(expectedValue))
|
||||||
throw ParserException(*this, "Unexpected value, expected \"" + std::to_string(expectedValue) + "\"");
|
throw ParserException(*this, "Expected \"" + std::to_string(expectedValue) + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -426,7 +433,7 @@ template<>
|
|||||||
void Parser::expect<uint64_t>(const uint64_t &expectedValue)
|
void Parser::expect<uint64_t>(const uint64_t &expectedValue)
|
||||||
{
|
{
|
||||||
if (!probe<uint64_t>(expectedValue))
|
if (!probe<uint64_t>(expectedValue))
|
||||||
throw ParserException(*this, "Unexpected value, expected \"" + std::to_string(expectedValue) + "\"");
|
throw ParserException(*this, "Expected \"" + std::to_string(expectedValue) + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -501,7 +508,7 @@ void Parser::expect<bool>(const bool &expectedValue)
|
|||||||
const auto value = parse<bool>();
|
const auto value = parse<bool>();
|
||||||
|
|
||||||
if (value != expectedValue)
|
if (value != expectedValue)
|
||||||
throw ParserException(*this, "Unexpected value " + std::to_string(value) + ", expected " + std::to_string(expectedValue));
|
throw ParserException(*this, "Expected \"" + std::to_string(expectedValue) + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
Reference in New Issue
Block a user