Made section identifier parsing case-insensitive.
This commit is contained in:
parent
7e60631840
commit
2870bc6434
@ -40,6 +40,18 @@ inline std::string unescapeASP(const std::string &string)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline std::string toLowerCase(const std::string &string)
|
||||
{
|
||||
std::string result;
|
||||
result.resize(string.size());
|
||||
|
||||
std::transform(string.begin(), string.end(), result.begin(), ::tolower);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <plasp/pddl/expressions/PredicateDeclaration.h>
|
||||
#include <plasp/pddl/expressions/PrimitiveType.h>
|
||||
#include <plasp/pddl/expressions/Variable.h>
|
||||
#include <plasp/utils/IO.h>
|
||||
#include <plasp/utils/ParserException.h>
|
||||
|
||||
namespace plasp
|
||||
@ -104,7 +105,7 @@ void Domain::parseSection()
|
||||
m_context.parser.expect<std::string>("(");
|
||||
m_context.parser.expect<std::string>(":");
|
||||
|
||||
const auto sectionIdentifier = m_context.parser.parseIdentifier(isIdentifier);
|
||||
const auto sectionIdentifier = utils::toLowerCase(m_context.parser.parseIdentifier(isIdentifier));
|
||||
|
||||
const auto skipSection =
|
||||
[&]()
|
||||
@ -149,6 +150,8 @@ void Domain::parseSection()
|
||||
skipSection();
|
||||
else if (sectionIdentifier == "derived")
|
||||
skipSection();
|
||||
else
|
||||
throw utils::ParserException(m_context.parser, "Unknown domain section \"" + sectionIdentifier + "\"");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <plasp/pddl/expressions/Predicate.h>
|
||||
#include <plasp/pddl/expressions/PredicateDeclaration.h>
|
||||
#include <plasp/pddl/expressions/Reference.h>
|
||||
#include <plasp/utils/IO.h>
|
||||
#include <plasp/utils/ParserException.h>
|
||||
|
||||
namespace plasp
|
||||
@ -42,7 +43,7 @@ ExpressionPointer parsePreconditionExpression(Context &context,
|
||||
{
|
||||
context.parser.expect<std::string>("(");
|
||||
|
||||
const auto expressionIdentifier = context.parser.parseIdentifier(isIdentifier);
|
||||
const auto expressionIdentifier = utils::toLowerCase(context.parser.parseIdentifier(isIdentifier));
|
||||
|
||||
ExpressionPointer expression;
|
||||
|
||||
@ -70,7 +71,7 @@ ExpressionPointer parseExpression(Context &context, const expressions::Variables
|
||||
{
|
||||
context.parser.expect<std::string>("(");
|
||||
|
||||
const auto expressionIdentifier = context.parser.parseIdentifier(isIdentifier);
|
||||
const auto expressionIdentifier = utils::toLowerCase(context.parser.parseIdentifier(isIdentifier));
|
||||
|
||||
auto expression = parseExpressionContent(expressionIdentifier, context, parameters);
|
||||
|
||||
@ -137,7 +138,7 @@ ExpressionPointer parseEffectExpression(Context &context, const expressions::Var
|
||||
{
|
||||
context.parser.expect<std::string>("(");
|
||||
|
||||
const auto expressionIdentifier = context.parser.parseIdentifier(isIdentifier);
|
||||
const auto expressionIdentifier = utils::toLowerCase(context.parser.parseIdentifier(isIdentifier));
|
||||
|
||||
ExpressionPointer expression;
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <boost/bimap.hpp>
|
||||
|
||||
#include <plasp/pddl/Identifier.h>
|
||||
#include <plasp/utils/IO.h>
|
||||
#include <plasp/utils/ParserException.h>
|
||||
|
||||
namespace plasp
|
||||
@ -81,7 +82,7 @@ Requirement::Requirement(Requirement::Type type)
|
||||
|
||||
Requirement Requirement::parse(Context &context)
|
||||
{
|
||||
const auto requirementName = context.parser.parseIdentifier(isIdentifier);
|
||||
const auto requirementName = utils::toLowerCase(context.parser.parseIdentifier(isIdentifier));
|
||||
|
||||
const auto match = requirementTypesToPDDL.right.find(requirementName);
|
||||
|
||||
|
Reference in New Issue
Block a user