diff --git a/include/plasp/utils/IO.h b/include/plasp/utils/IO.h index d2d022e..f16ddd5 100644 --- a/include/plasp/utils/IO.h +++ b/include/plasp/utils/IO.h @@ -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; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + } } diff --git a/src/plasp/pddl/Domain.cpp b/src/plasp/pddl/Domain.cpp index 4c0002e..77dfd5a 100644 --- a/src/plasp/pddl/Domain.cpp +++ b/src/plasp/pddl/Domain.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include namespace plasp @@ -104,7 +105,7 @@ void Domain::parseSection() m_context.parser.expect("("); m_context.parser.expect(":"); - 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 + "\""); } //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/plasp/pddl/Expression.cpp b/src/plasp/pddl/Expression.cpp index eb4cba6..987ccd0 100644 --- a/src/plasp/pddl/Expression.cpp +++ b/src/plasp/pddl/Expression.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include namespace plasp @@ -42,7 +43,7 @@ ExpressionPointer parsePreconditionExpression(Context &context, { context.parser.expect("("); - 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("("); - 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("("); - const auto expressionIdentifier = context.parser.parseIdentifier(isIdentifier); + const auto expressionIdentifier = utils::toLowerCase(context.parser.parseIdentifier(isIdentifier)); ExpressionPointer expression; diff --git a/src/plasp/pddl/Requirement.cpp b/src/plasp/pddl/Requirement.cpp index e4f0ed0..834fc86 100644 --- a/src/plasp/pddl/Requirement.cpp +++ b/src/plasp/pddl/Requirement.cpp @@ -5,6 +5,7 @@ #include #include +#include #include 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);