Made all error and warning messages lowercase consistently.
This commit is contained in:
parent
2984da773d
commit
6fec1cc409
@ -19,7 +19,7 @@ class ConsistencyException: public std::exception
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ConsistencyException()
|
explicit ConsistencyException()
|
||||||
: ConsistencyException("Unspecified consistency error")
|
: ConsistencyException("unspecified consistency error")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ class ConsistencyException: public std::exception
|
|||||||
const char *what() const throw()
|
const char *what() const throw()
|
||||||
{
|
{
|
||||||
if (m_message.empty())
|
if (m_message.empty())
|
||||||
return "Unspecified consistency error";
|
return "unspecified consistency error";
|
||||||
|
|
||||||
return m_message.c_str();
|
return m_message.c_str();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ class ParserException: public std::exception
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ParserException(const utils::Parser &parser)
|
explicit ParserException(const utils::Parser &parser)
|
||||||
: ParserException(parser, "Unspecified parser error")
|
: ParserException(parser, "unspecified parser error")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ void Description::parse()
|
|||||||
findSections();
|
findSections();
|
||||||
|
|
||||||
if (m_domainPosition == -1)
|
if (m_domainPosition == -1)
|
||||||
throw ConsistencyException("No PDDL domain specified");
|
throw ConsistencyException("no PDDL domain specified");
|
||||||
|
|
||||||
parser.seek(m_domainPosition);
|
parser.seek(m_domainPosition);
|
||||||
m_domain->parse();
|
m_domain->parse();
|
||||||
@ -188,7 +188,7 @@ void Description::findSections()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto sectionIdentifier = parser.parse<std::string>();
|
const auto sectionIdentifier = parser.parse<std::string>();
|
||||||
throw utils::ParserException(parser, "Unknown PDDL section “" + sectionIdentifier + "”");
|
throw utils::ParserException(parser, "unknown PDDL section “" + sectionIdentifier + "”");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_context.parser.skipWhiteSpace();
|
m_context.parser.skipWhiteSpace();
|
||||||
|
@ -53,7 +53,7 @@ void Domain::findSections()
|
|||||||
if (unique && sectionPosition != -1)
|
if (unique && sectionPosition != -1)
|
||||||
{
|
{
|
||||||
parser.seek(value);
|
parser.seek(value);
|
||||||
throw utils::ParserException(parser, "Only one “:" + sectionName + "” section allowed");
|
throw utils::ParserException(parser, "only one “:" + sectionName + "” section allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
sectionPosition = value;
|
sectionPosition = value;
|
||||||
@ -94,7 +94,7 @@ void Domain::findSections()
|
|||||||
|
|
||||||
const auto sectionIdentifier = parser.parseIdentifier(isIdentifier);
|
const auto sectionIdentifier = parser.parseIdentifier(isIdentifier);
|
||||||
|
|
||||||
m_context.logger.logWarning(parser, "Section type “" + sectionIdentifier + "” currently unsupported");
|
m_context.logger.logWarning(parser, "section type “" + sectionIdentifier + "” currently unsupported");
|
||||||
|
|
||||||
parser.seek(sectionIdentifierPosition);
|
parser.seek(sectionIdentifierPosition);
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ void Domain::findSections()
|
|||||||
const auto sectionIdentifier = parser.parseIdentifier(isIdentifier);
|
const auto sectionIdentifier = parser.parseIdentifier(isIdentifier);
|
||||||
|
|
||||||
parser.seek(position);
|
parser.seek(position);
|
||||||
throw utils::ParserException(m_context.parser, "Unknown domain section “" + sectionIdentifier + "”");
|
throw utils::ParserException(m_context.parser, "unknown domain section “" + sectionIdentifier + "”");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip section for now and parse it later
|
// Skip section for now and parse it later
|
||||||
@ -279,7 +279,7 @@ void Domain::checkRequirement(Requirement::Type requirementType) const
|
|||||||
if (hasRequirement(requirementType))
|
if (hasRequirement(requirementType))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
throw ConsistencyException("Requirement “" + Requirement(requirementType).toPDDL() + "” used but never declared");
|
throw ConsistencyException("requirement “" + Requirement(requirementType).toPDDL() + "” used but never declared");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -340,7 +340,7 @@ void Domain::parseTypeSection()
|
|||||||
while (parser.currentCharacter() != ')')
|
while (parser.currentCharacter() != ')')
|
||||||
{
|
{
|
||||||
if (parser.currentCharacter() == '(')
|
if (parser.currentCharacter() == '(')
|
||||||
throw utils::ParserException(parser, "Only primitive types are allowed in type section");
|
throw utils::ParserException(parser, "only primitive types are allowed in type section");
|
||||||
|
|
||||||
expressions::PrimitiveType::parseTypedDeclaration(m_context, *this);
|
expressions::PrimitiveType::parseTypedDeclaration(m_context, *this);
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ ExpressionPointer parseExpression(Context &context, ExpressionContext &expressio
|
|||||||
const auto expressionIdentifier = parser.parseIdentifier(isIdentifier);
|
const auto expressionIdentifier = parser.parseIdentifier(isIdentifier);
|
||||||
|
|
||||||
parser.seek(position);
|
parser.seek(position);
|
||||||
throw utils::ParserException(context.parser, "Expression type “" + expressionIdentifier + "” unknown or not allowed in this context");
|
throw utils::ParserException(context.parser, "expression type “" + expressionIdentifier + "” unknown or not allowed in this context");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -186,7 +186,7 @@ ExpressionPointer parseEffectBodyExpression(Context &context, ExpressionContext
|
|||||||
const auto expressionIdentifier = parser.parseIdentifier(isIdentifier);
|
const auto expressionIdentifier = parser.parseIdentifier(isIdentifier);
|
||||||
|
|
||||||
parser.seek(position);
|
parser.seek(position);
|
||||||
throw utils::ParserException(context.parser, "Expression type “" + expressionIdentifier + "” unknown or not allowed in this context");
|
throw utils::ParserException(context.parser, "expression type “" + expressionIdentifier + "” unknown or not allowed in this context");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -198,7 +198,7 @@ ExpressionPointer parsePredicate(Context &context, ExpressionContext &expression
|
|||||||
if ((expression = expressions::Predicate::parse(context, expressionContext)))
|
if ((expression = expressions::Predicate::parse(context, expressionContext)))
|
||||||
return expression;
|
return expression;
|
||||||
|
|
||||||
throw utils::ParserException(context.parser, "Expected predicate");
|
throw utils::ParserException(context.parser, "expected predicate");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -59,7 +59,7 @@ std::unique_ptr<InitialState> InitialState::parseDeclaration(Context &context,
|
|||||||
const auto expressionIdentifier = parser.parseIdentifier(isIdentifier);
|
const auto expressionIdentifier = parser.parseIdentifier(isIdentifier);
|
||||||
|
|
||||||
parser.seek(position);
|
parser.seek(position);
|
||||||
throw utils::ParserException(parser, "Expression type “" + expressionIdentifier + "” unknown or not allowed in this context");
|
throw utils::ParserException(parser, "expression type “" + expressionIdentifier + "” unknown or not allowed in this context");
|
||||||
};
|
};
|
||||||
|
|
||||||
parser.skipWhiteSpace();
|
parser.skipWhiteSpace();
|
||||||
|
@ -53,7 +53,7 @@ void Problem::findSections()
|
|||||||
if (unique && sectionPosition != -1)
|
if (unique && sectionPosition != -1)
|
||||||
{
|
{
|
||||||
parser.seek(value);
|
parser.seek(value);
|
||||||
throw utils::ParserException(parser, "Only one “:" + sectionName + "” section allowed");
|
throw utils::ParserException(parser, "only one “:" + sectionName + "” section allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
sectionPosition = value;
|
sectionPosition = value;
|
||||||
@ -89,7 +89,7 @@ void Problem::findSections()
|
|||||||
|
|
||||||
const auto sectionIdentifier = parser.parseIdentifier(isIdentifier);
|
const auto sectionIdentifier = parser.parseIdentifier(isIdentifier);
|
||||||
|
|
||||||
m_context.logger.logWarning(parser, "Section type “" + sectionIdentifier + "” currently unsupported");
|
m_context.logger.logWarning(parser, "section type “" + sectionIdentifier + "” currently unsupported");
|
||||||
|
|
||||||
parser.seek(sectionIdentifierPosition);
|
parser.seek(sectionIdentifierPosition);
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ void Problem::findSections()
|
|||||||
const auto sectionIdentifier = parser.parseIdentifier(isIdentifier);
|
const auto sectionIdentifier = parser.parseIdentifier(isIdentifier);
|
||||||
|
|
||||||
parser.seek(position);
|
parser.seek(position);
|
||||||
throw utils::ParserException(m_context.parser, "Unknown problem section “" + sectionIdentifier + "”");
|
throw utils::ParserException(m_context.parser, "unknown problem section “" + sectionIdentifier + "”");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip section for now and parse it later
|
// Skip section for now and parse it later
|
||||||
@ -117,7 +117,7 @@ void Problem::parse()
|
|||||||
auto &parser = m_context.parser;
|
auto &parser = m_context.parser;
|
||||||
|
|
||||||
if (m_domainPosition == -1)
|
if (m_domainPosition == -1)
|
||||||
throw ConsistencyException("Problem description does not specify the corresponding domain");
|
throw ConsistencyException("problem description does not specify the corresponding domain");
|
||||||
|
|
||||||
parser.seek(m_domainPosition);
|
parser.seek(m_domainPosition);
|
||||||
parseDomainSection();
|
parseDomainSection();
|
||||||
@ -135,13 +135,13 @@ void Problem::parse()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_initialStatePosition == -1)
|
if (m_initialStatePosition == -1)
|
||||||
throw ConsistencyException("Problem description does not specify an initial state");
|
throw ConsistencyException("problem description does not specify an initial state");
|
||||||
|
|
||||||
parser.seek(m_initialStatePosition);
|
parser.seek(m_initialStatePosition);
|
||||||
parseInitialStateSection();
|
parseInitialStateSection();
|
||||||
|
|
||||||
if (m_goalPosition == -1)
|
if (m_goalPosition == -1)
|
||||||
throw ConsistencyException("Problem description does not specify a goal");
|
throw ConsistencyException("problem description does not specify a goal");
|
||||||
|
|
||||||
parser.seek(m_goalPosition);
|
parser.seek(m_goalPosition);
|
||||||
parseGoalSection();
|
parseGoalSection();
|
||||||
@ -204,7 +204,7 @@ void Problem::parseDomainSection()
|
|||||||
const auto domainName = parser.parseIdentifier(isIdentifier);
|
const auto domainName = parser.parseIdentifier(isIdentifier);
|
||||||
|
|
||||||
if (m_domain.name() != domainName)
|
if (m_domain.name() != domainName)
|
||||||
throw utils::ParserException(parser, "Domains do not match (“" + m_domain.name() + "” and “" + domainName + "”)");
|
throw utils::ParserException(parser, "domains do not match (“" + m_domain.name() + "” and “" + domainName + "”)");
|
||||||
|
|
||||||
parser.expect<std::string>(")");
|
parser.expect<std::string>(")");
|
||||||
}
|
}
|
||||||
@ -261,7 +261,7 @@ void Problem::checkRequirement(Requirement::Type requirementType) const
|
|||||||
if (hasRequirement(requirementType))
|
if (hasRequirement(requirementType))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
throw ConsistencyException("Requirement “" + Requirement(requirementType).toPDDL() + "” used but never declared");
|
throw ConsistencyException("requirement “" + Requirement(requirementType).toPDDL() + "” used but never declared");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -89,12 +89,12 @@ Requirement Requirement::parse(Context &context)
|
|||||||
const auto match = requirementTypesToPDDL.right.find(requirementName);
|
const auto match = requirementTypesToPDDL.right.find(requirementName);
|
||||||
|
|
||||||
if (match == requirementTypesToPDDL.right.end())
|
if (match == requirementTypesToPDDL.right.end())
|
||||||
throw utils::ParserException(context.parser, "Unknown PDDL requirement “" + requirementName + "”");
|
throw utils::ParserException(context.parser, "unknown PDDL requirement “" + requirementName + "”");
|
||||||
|
|
||||||
const auto requirementType = match->second;
|
const auto requirementType = match->second;
|
||||||
|
|
||||||
if (requirementType == Requirement::Type::GoalUtilities)
|
if (requirementType == Requirement::Type::GoalUtilities)
|
||||||
context.logger.logWarning(context.parser, "Requirement “goal-utilities” is not part of the PDDL 3.1 specification");
|
context.logger.logWarning(context.parser, "requirement “goal-utilities” is not part of the PDDL 3.1 specification");
|
||||||
|
|
||||||
return Requirement(match->second);
|
return Requirement(match->second);
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ void TranslatorASP::translateActions() const
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (precondition.expressionType() != Expression::Type::And)
|
if (precondition.expressionType() != Expression::Type::And)
|
||||||
throw utils::TranslatorException("Only “and” expressions and (negated) predicates supported as action preconditions currently");
|
throw utils::TranslatorException("only “and” expressions and (negated) predicates supported as action preconditions currently");
|
||||||
|
|
||||||
const auto &andExpression = dynamic_cast<const expressions::And &>(precondition);
|
const auto &andExpression = dynamic_cast<const expressions::And &>(precondition);
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ void TranslatorASP::translateActions() const
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (effect.expressionType() != Expression::Type::And)
|
if (effect.expressionType() != Expression::Type::And)
|
||||||
throw utils::TranslatorException("Only “and” expressions and (negated) predicates supported as action effects currently");
|
throw utils::TranslatorException("only “and” expressions and (negated) predicates supported as action effects currently");
|
||||||
|
|
||||||
const auto &andExpression = dynamic_cast<const expressions::And &>(effect);
|
const auto &andExpression = dynamic_cast<const expressions::And &>(effect);
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ void TranslatorASP::translateVariablesBody(const expressions::Variables &variabl
|
|||||||
if (variable.type() != nullptr)
|
if (variable.type() != nullptr)
|
||||||
{
|
{
|
||||||
if (variable.type()->expressionType() != Expression::Type::PrimitiveType)
|
if (variable.type()->expressionType() != Expression::Type::PrimitiveType)
|
||||||
throw utils::TranslatorException("Only primitive types supported currently");
|
throw utils::TranslatorException("only primitive types supported currently");
|
||||||
|
|
||||||
const auto &type = *dynamic_cast<const expressions::PrimitiveType *>(variable.type());
|
const auto &type = *dynamic_cast<const expressions::PrimitiveType *>(variable.type());
|
||||||
|
|
||||||
@ -387,7 +387,7 @@ void TranslatorASP::translateLiteral(const Expression &literal) const
|
|||||||
printKeyword("false");
|
printKeyword("false");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw utils::TranslatorException("Only primitive predicates and their negations supported as literals currently");
|
throw utils::TranslatorException("only primitive predicates and their negations supported as literals currently");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -426,7 +426,7 @@ void TranslatorASP::translatePredicate(const expressions::Predicate &predicate)
|
|||||||
printVariable(utils::escapeASPVariable(variable.name()));
|
printVariable(utils::escapeASPVariable(variable.name()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw utils::TranslatorException("Only variables and constants supported in predicates currently");
|
throw utils::TranslatorException("only variables and constants supported in predicates currently");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_outputStream << "))";
|
m_outputStream << "))";
|
||||||
@ -484,10 +484,10 @@ void TranslatorASP::translateInitialState() const
|
|||||||
const auto ¬Expression = dynamic_cast<const expressions::Not &>(*fact);
|
const auto ¬Expression = dynamic_cast<const expressions::Not &>(*fact);
|
||||||
|
|
||||||
if (notExpression.argument()->expressionType() != Expression::Type::Predicate)
|
if (notExpression.argument()->expressionType() != Expression::Type::Predicate)
|
||||||
throw utils::TranslatorException("Only negations of simple predicates supported in initial state currently");
|
throw utils::TranslatorException("only negations of simple predicates supported in initial state currently");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw utils::TranslatorException("Only predicates and their negations supported in initial state currently");
|
throw utils::TranslatorException("only predicates and their negations supported in initial state currently");
|
||||||
|
|
||||||
m_outputStream << ").";
|
m_outputStream << ").";
|
||||||
});
|
});
|
||||||
@ -533,7 +533,7 @@ void TranslatorASP::translateGoal() const
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw utils::TranslatorException("Only single predicates, their negations, and conjunctions are currently supported in the goal");
|
throw utils::TranslatorException("only single predicates, their negations, and conjunctions are currently supported in the goal");
|
||||||
|
|
||||||
m_outputStream << std::endl;
|
m_outputStream << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ void Constant::parseTypedDeclarations(Context &context, Domain &domain)
|
|||||||
domain.checkRequirement(Requirement::Type::Typing);
|
domain.checkRequirement(Requirement::Type::Typing);
|
||||||
// If no types are given, check that typing is not a requirement
|
// If no types are given, check that typing is not a requirement
|
||||||
else if (domain.hasRequirement(Requirement::Type::Typing))
|
else if (domain.hasRequirement(Requirement::Type::Typing))
|
||||||
throw utils::ParserException(parser, "Constant has undeclared type");
|
throw utils::ParserException(parser, "constant has undeclared type");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -140,7 +140,7 @@ void Constant::parseTypedDeclarations(Context &context, Problem &problem)
|
|||||||
problem.checkRequirement(Requirement::Type::Typing);
|
problem.checkRequirement(Requirement::Type::Typing);
|
||||||
// If no types are given, check that typing is not a requirement
|
// If no types are given, check that typing is not a requirement
|
||||||
else if (problem.hasRequirement(Requirement::Type::Typing))
|
else if (problem.hasRequirement(Requirement::Type::Typing))
|
||||||
throw utils::ParserException(context.parser, "Constant has undeclared type");
|
throw utils::ParserException(context.parser, "constant has undeclared type");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -156,7 +156,7 @@ Constant *Constant::parseAndFind(Context &context, const Domain &domain)
|
|||||||
if (constant != nullptr)
|
if (constant != nullptr)
|
||||||
return constant;
|
return constant;
|
||||||
|
|
||||||
throw utils::ParserException(context.parser, "Constant “" + constantName + "” used but never declared");
|
throw utils::ParserException(context.parser, "constant “" + constantName + "” used but never declared");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -177,7 +177,7 @@ Constant *Constant::parseAndFind(Context &context, const Problem &problem)
|
|||||||
if (constant)
|
if (constant)
|
||||||
return constant;
|
return constant;
|
||||||
|
|
||||||
throw utils::ParserException(context.parser, "Constant “" + constantName + "” used but never declared");
|
throw utils::ParserException(context.parser, "constant “" + constantName + "” used but never declared");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -127,7 +127,7 @@ PredicatePointer Predicate::parse(Context &context, const Problem &problem)
|
|||||||
while (context.parser.currentCharacter() != ')')
|
while (context.parser.currentCharacter() != ')')
|
||||||
{
|
{
|
||||||
if (context.parser.currentCharacter() == '?')
|
if (context.parser.currentCharacter() == '?')
|
||||||
throw utils::ParserException(context.parser, "Variables not allowed in this context");
|
throw utils::ParserException(context.parser, "variables not allowed in this context");
|
||||||
|
|
||||||
// Parse objects and constants
|
// Parse objects and constants
|
||||||
const auto *constant = Constant::parseAndFind(context, problem);
|
const auto *constant = Constant::parseAndFind(context, problem);
|
||||||
|
@ -109,7 +109,7 @@ PrimitiveType *PrimitiveType::parseAndFind(Context &context, Domain &domain)
|
|||||||
const auto typeName = context.parser.parseIdentifier(isIdentifier);
|
const auto typeName = context.parser.parseIdentifier(isIdentifier);
|
||||||
|
|
||||||
if (typeName.empty())
|
if (typeName.empty())
|
||||||
throw utils::ParserException(context.parser, "No type supplied");
|
throw utils::ParserException(context.parser, "no type supplied");
|
||||||
|
|
||||||
const auto match = std::find_if(types.cbegin(), types.cend(),
|
const auto match = std::find_if(types.cbegin(), types.cend(),
|
||||||
[&](const auto &primitiveType)
|
[&](const auto &primitiveType)
|
||||||
@ -122,11 +122,11 @@ PrimitiveType *PrimitiveType::parseAndFind(Context &context, Domain &domain)
|
|||||||
// Only "object" is allowed as an implicit type
|
// Only "object" is allowed as an implicit type
|
||||||
if (typeName == "object" || typeName == "objects")
|
if (typeName == "object" || typeName == "objects")
|
||||||
{
|
{
|
||||||
context.logger.logWarning(context.parser, "Primitive type “" + typeName + "” should be declared");
|
context.logger.logWarning(context.parser, "primitive type “" + typeName + "” should be declared");
|
||||||
types.emplace_back(std::make_unique<expressions::PrimitiveType>(typeName));
|
types.emplace_back(std::make_unique<expressions::PrimitiveType>(typeName));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw utils::ParserException(context.parser, "Type “" + typeName + "” used but never declared");
|
throw utils::ParserException(context.parser, "type “" + typeName + "” used but never declared");
|
||||||
|
|
||||||
return types.back().get();
|
return types.back().get();
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ UnsupportedPointer Unsupported::parse(Context &context)
|
|||||||
|
|
||||||
expression->m_type = parser.parseIdentifier(isIdentifier);
|
expression->m_type = parser.parseIdentifier(isIdentifier);
|
||||||
|
|
||||||
context.logger.logWarning(context.parser, "Expression type “" + expression->m_type + "” currently unsupported in this context");
|
context.logger.logWarning(context.parser, "expression type “" + expression->m_type + "” currently unsupported in this context");
|
||||||
|
|
||||||
skipSection(parser);
|
skipSection(parser);
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ void Variable::parseDeclaration(Context &context, Variables ¶meters)
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (match != parameters.cend())
|
if (match != parameters.cend())
|
||||||
throw utils::ParserException(context.parser, "Variable “" + variable->m_name + "” already declared in this scope");
|
throw utils::ParserException(context.parser, "variable “" + variable->m_name + "” already declared in this scope");
|
||||||
|
|
||||||
// Flag variable for potentially upcoming type declaration
|
// Flag variable for potentially upcoming type declaration
|
||||||
variable->setDirty();
|
variable->setDirty();
|
||||||
@ -132,7 +132,7 @@ void Variable::parseTypedDeclarations(Context &context, ExpressionContext &expre
|
|||||||
expressionContext.checkRequirement(Requirement::Type::Typing);
|
expressionContext.checkRequirement(Requirement::Type::Typing);
|
||||||
// If no types are given, check that typing is not a requirement
|
// If no types are given, check that typing is not a requirement
|
||||||
else if (expressionContext.hasRequirement(Requirement::Type::Typing))
|
else if (expressionContext.hasRequirement(Requirement::Type::Typing))
|
||||||
throw utils::ParserException(parser, "Variable has undeclared type");
|
throw utils::ParserException(parser, "variable has undeclared type");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -154,7 +154,7 @@ const Variable *Variable::parseAndFind(Context &context, const ExpressionContext
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (match == variables.cend())
|
if (match == variables.cend())
|
||||||
throw utils::ParserException(context.parser, "Parameter “" + variableName + "” used but never declared");
|
throw utils::ParserException(context.parser, "parameter “" + variableName + "” used but never declared");
|
||||||
|
|
||||||
return match->get();
|
return match->get();
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ void Description::parseContent(utils::Parser &parser)
|
|||||||
parser.skipWhiteSpace();
|
parser.skipWhiteSpace();
|
||||||
|
|
||||||
if (!parser.atEndOfStream())
|
if (!parser.atEndOfStream())
|
||||||
throw utils::ParserException(parser, "Expected end of SAS description (perhaps, input contains two SAS descriptions?)");
|
throw utils::ParserException(parser, "expected end of SAS description (perhaps, input contains two SAS descriptions?)");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -181,7 +181,7 @@ void Description::parseVersionSection(utils::Parser &parser) const
|
|||||||
const auto formatVersion = parser.parse<size_t>();
|
const auto formatVersion = parser.parse<size_t>();
|
||||||
|
|
||||||
if (formatVersion != 3)
|
if (formatVersion != 3)
|
||||||
throw utils::ParserException(parser, "Unsupported SAS format version (" + std::to_string(formatVersion) + ")");
|
throw utils::ParserException(parser, "unsupported SAS format version (" + std::to_string(formatVersion) + ")");
|
||||||
|
|
||||||
parser.expect<std::string>("end_version");
|
parser.expect<std::string>("end_version");
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ MutexGroup MutexGroup::fromSAS(utils::Parser &parser, const Variables &variables
|
|||||||
mutexGroup.m_facts.emplace_back(Fact::fromSAS(parser, variables));
|
mutexGroup.m_facts.emplace_back(Fact::fromSAS(parser, variables));
|
||||||
|
|
||||||
if (mutexGroup.m_facts[j].value() == Value::None)
|
if (mutexGroup.m_facts[j].value() == Value::None)
|
||||||
throw utils::ParserException(parser, "Mutex groups must not contain <none of those> values");
|
throw utils::ParserException(parser, "mutex groups must not contain <none of those> values");
|
||||||
}
|
}
|
||||||
|
|
||||||
parser.expect<std::string>("end_mutex_group");
|
parser.expect<std::string>("end_mutex_group");
|
||||||
|
@ -46,7 +46,7 @@ Predicate Predicate::fromSAS(utils::Parser &parser)
|
|||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
throw utils::ParserException(parser, "Could not parse operator predicate");
|
throw utils::ParserException(parser, "could not parse operator predicate");
|
||||||
}
|
}
|
||||||
|
|
||||||
return predicate;
|
return predicate;
|
||||||
|
@ -74,7 +74,7 @@ Value Value::fromSAS(utils::Parser &parser)
|
|||||||
else if (sasSign == "NegatedAtom")
|
else if (sasSign == "NegatedAtom")
|
||||||
value.m_sign = Value::Sign::Negative;
|
value.m_sign = Value::Sign::Negative;
|
||||||
else
|
else
|
||||||
throw utils::ParserException(parser, "Invalid value sign “" + sasSign + "”");
|
throw utils::ParserException(parser, "invalid value sign “" + sasSign + "”");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -90,7 +90,7 @@ Value Value::fromSAS(utils::Parser &parser)
|
|||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
throw utils::ParserException(parser, std::string("Could not parse variable value (") + e.what() + ")");
|
throw utils::ParserException(parser, std::string("could not parse variable value (") + e.what() + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
@ -106,7 +106,7 @@ const Value &Value::referenceFromSAS(utils::Parser &parser, const Variable &vari
|
|||||||
return Value::Any;
|
return Value::Any;
|
||||||
|
|
||||||
if (valueID < 0 || static_cast<size_t>(valueID) >= variable.values().size())
|
if (valueID < 0 || static_cast<size_t>(valueID) >= variable.values().size())
|
||||||
throw utils::ParserException(parser, "Value index out of range (variable " + variable.name() + ", index " + std::to_string(valueID) + ")");
|
throw utils::ParserException(parser, "value index out of range (variable " + variable.name() + ", index " + std::to_string(valueID) + ")");
|
||||||
|
|
||||||
return variable.values()[valueID];
|
return variable.values()[valueID];
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ const Variable &Variable::referenceFromSAS(utils::Parser &parser, const Variable
|
|||||||
const auto variableID = parser.parse<size_t>();
|
const auto variableID = parser.parse<size_t>();
|
||||||
|
|
||||||
if (variableID >= variables.size())
|
if (variableID >= variables.size())
|
||||||
throw utils::ParserException(parser, "Variable index out of range (index " + std::to_string(variableID) + ")");
|
throw utils::ParserException(parser, "variable index out of range (index " + std::to_string(variableID) + ")");
|
||||||
|
|
||||||
return variables[variableID];
|
return variables[variableID];
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ bool Parser::atEndOfStream() const
|
|||||||
void Parser::checkStream() const
|
void Parser::checkStream() const
|
||||||
{
|
{
|
||||||
if (atEndOfStream())
|
if (atEndOfStream())
|
||||||
throw ParserException(*this, "Reading past end of file");
|
throw ParserException(*this, "reading past end of file");
|
||||||
|
|
||||||
if (m_stream.fail())
|
if (m_stream.fail())
|
||||||
throw ParserException(*this);
|
throw ParserException(*this);
|
||||||
@ -310,7 +310,7 @@ 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, "Expected “" + expectedValue + "”");
|
throw ParserException(*this, "expected “" + expectedValue + "”");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -344,7 +344,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("Expected “") + expectedValue + "”");
|
throw ParserException(*this, std::string("expected “") + expectedValue + "”");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -354,7 +354,7 @@ uint64_t Parser::parseIntegerBody()
|
|||||||
checkStream();
|
checkStream();
|
||||||
|
|
||||||
if (!std::isdigit(currentCharacter()))
|
if (!std::isdigit(currentCharacter()))
|
||||||
throw ParserException(*this, "Could not parse integer value");
|
throw ParserException(*this, "could not parse integer value");
|
||||||
|
|
||||||
uint64_t value = 0;
|
uint64_t value = 0;
|
||||||
|
|
||||||
@ -396,7 +396,7 @@ uint64_t Parser::parse<uint64_t>()
|
|||||||
skipWhiteSpace();
|
skipWhiteSpace();
|
||||||
|
|
||||||
if (currentCharacter() == '-')
|
if (currentCharacter() == '-')
|
||||||
throw ParserException(*this, "Expected unsigned integer, got signed one");
|
throw ParserException(*this, "expected unsigned integer, got signed one");
|
||||||
|
|
||||||
return parseIntegerBody();
|
return parseIntegerBody();
|
||||||
}
|
}
|
||||||
@ -439,7 +439,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, "Expected “" + std::to_string(expectedValue) + "”");
|
throw ParserException(*this, "expected “" + std::to_string(expectedValue) + "”");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -448,7 +448,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, "Expected “" + std::to_string(expectedValue) + "”");
|
throw ParserException(*this, "expected “" + std::to_string(expectedValue) + "”");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -512,7 +512,7 @@ bool Parser::parse<bool>()
|
|||||||
if (probe('1'))
|
if (probe('1'))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
throw ParserException(*this, "Could not parse Boolean value");
|
throw ParserException(*this, "could not parse Boolean value");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -523,7 +523,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, "Expected “" + std::to_string(expectedValue) + "”");
|
throw ParserException(*this, "expected “" + std::to_string(expectedValue) + "”");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
Reference in New Issue
Block a user