diff --git a/include/plasp/pddl/Context.h b/include/plasp/pddl/Context.h index 2aefca7..52b182b 100644 --- a/include/plasp/pddl/Context.h +++ b/include/plasp/pddl/Context.h @@ -25,6 +25,13 @@ namespace pddl class Context { public: + Context(utils::Parser &parser) + : parser(parser) + { + } + + utils::Parser &parser; + expressions::PrimitiveTypes primitiveTypes; //std::unordered_map primitiveTypesHashMap; diff --git a/include/plasp/pddl/Description.h b/include/plasp/pddl/Description.h index 73c556b..8ec66f5 100644 --- a/include/plasp/pddl/Description.h +++ b/include/plasp/pddl/Description.h @@ -27,12 +27,14 @@ class Description const Domain &domain() const; private: - Description() = default; + Description(std::istream &istream); - void parseContent(utils::Parser &parser); - void parseSection(utils::Parser &parser); + void parseContent(); + void parseSection(); + utils::Parser m_parser; Context m_context; + std::unique_ptr m_domain; //std::unique_ptr m_problem; }; diff --git a/include/plasp/pddl/Domain.h b/include/plasp/pddl/Domain.h index dd48a19..f16c2aa 100644 --- a/include/plasp/pddl/Domain.h +++ b/include/plasp/pddl/Domain.h @@ -6,7 +6,6 @@ #include #include #include -#include namespace plasp { @@ -22,7 +21,7 @@ namespace pddl class Domain { public: - static Domain fromPDDL(utils::Parser &parser, Context &context); + static Domain fromPDDL(Context &context); public: const std::string &name() const; @@ -35,19 +34,19 @@ class Domain private: Domain(Context &context); - void parseSection(utils::Parser &parser); + void parseSection(); - void parseRequirementSection(utils::Parser &parser); + void parseRequirementSection(); bool hasRequirement(Requirement::Type requirementType) const; void computeDerivedRequirements(); - void parseTypeSection(utils::Parser &parser); + void parseTypeSection(); - void parseConstantSection(utils::Parser &parser); + void parseConstantSection(); - void parsePredicateSection(utils::Parser &parser); + void parsePredicateSection(); - void parseActionSection(utils::Parser &parser); + void parseActionSection(); void checkConsistency(); diff --git a/include/plasp/pddl/expressions/Constant.h b/include/plasp/pddl/expressions/Constant.h index d7f9658..60aa5d5 100644 --- a/include/plasp/pddl/expressions/Constant.h +++ b/include/plasp/pddl/expressions/Constant.h @@ -25,8 +25,7 @@ class Constant: public Expression static ConstantPointer parseDeclaration(utils::Parser &parser, Context &context); static void parseTypedDeclaration(utils::Parser &parser, Context &context); - template - static Constant *parseExisting(utils::Parser &parser, const Container &constants); + static Constant *parseExisting(utils::Parser &parser, Context &context); // TODO: method for lazy creation if not existing @@ -58,28 +57,6 @@ class Constant: public Expression //////////////////////////////////////////////////////////////////////////////////////////////////// -template -Constant *Constant::parseExisting(utils::Parser &parser, const Container &constants) -{ - parser.skipWhiteSpace(); - - const auto constantName = parser.parseIdentifier(isIdentifier); - // TODO: use hash map - const auto match = std::find_if(constants.cbegin(), constants.cend(), - [&](const auto &constant) - { - return constant->name() == constantName; - }); - const auto constantExists = (match != constants.cend()); - - if (!constantExists) - throw utils::ParserException(parser.row(), parser.column(), "Constant \"" + constantName + "\" used but never declared"); - - return match->get(); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// - } } } diff --git a/include/plasp/utils/ParserException.h b/include/plasp/utils/ParserException.h index 5a48593..bb6e0ef 100644 --- a/include/plasp/utils/ParserException.h +++ b/include/plasp/utils/ParserException.h @@ -4,6 +4,8 @@ #include #include +#include + namespace plasp { namespace utils @@ -18,18 +20,18 @@ namespace utils class ParserException: public std::exception { public: - explicit ParserException(size_t row, size_t column) - : ParserException(row, column, "Unspecified parser error") + explicit ParserException(const utils::Parser &parser) + : ParserException(parser, "Unspecified parser error") { } - explicit ParserException(size_t row, size_t column, const char *message) - : ParserException(row, column, static_cast(message)) + explicit ParserException(const utils::Parser &parser, const char *message) + : ParserException(parser, static_cast(message)) { } - explicit ParserException(size_t row, size_t column, const std::string &message) - : m_message{std::to_string(row) + ":" + std::to_string(column) + "\t" + message} + explicit ParserException(const utils::Parser &parser, const std::string &message) + : m_message{std::to_string(parser.row()) + ":" + std::to_string(parser.column()) + "\t" + message} { } diff --git a/src/plasp/pddl/Description.cpp b/src/plasp/pddl/Description.cpp index c0296b4..6dc5c93 100644 --- a/src/plasp/pddl/Description.cpp +++ b/src/plasp/pddl/Description.cpp @@ -18,20 +18,26 @@ namespace pddl // //////////////////////////////////////////////////////////////////////////////////////////////////// +Description::Description(std::istream &istream) +: m_parser(istream), + m_context(m_parser) +{ +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + Description Description::fromStream(std::istream &istream) { - Description description; - - utils::Parser parser(istream); + Description description(istream); while (true) { - parser.skipWhiteSpace(); + description.m_context.parser.skipWhiteSpace(); - if (parser.atEndOfFile()) + if (description.m_context.parser.atEndOfFile()) break; - description.parseContent(parser); + description.parseContent(); } return description; @@ -60,33 +66,33 @@ const Domain &Description::domain() const //////////////////////////////////////////////////////////////////////////////////////////////////// -void Description::parseContent(utils::Parser &parser) +void Description::parseContent() { std::cout << "Parsing file content" << std::endl; - parser.expect("("); - parser.expect("define"); - parseSection(parser); - parser.expect(")"); + m_context.parser.expect("("); + m_context.parser.expect("define"); + parseSection(); + m_context.parser.expect(")"); } //////////////////////////////////////////////////////////////////////////////////////////////////// -void Description::parseSection(utils::Parser &parser) +void Description::parseSection() { // Parse domain/problem identifier - parser.expect("("); + m_context.parser.expect("("); - const auto sectionIdentifier = parser.parse(); + const auto sectionIdentifier = m_context.parser.parse(); std::cout << "Parsing section " << sectionIdentifier << std::endl; if (sectionIdentifier == "domain") - m_domain = std::make_unique(Domain::fromPDDL(parser, m_context)); + m_domain = std::make_unique(Domain::fromPDDL(m_context)); //else if (sectionIdentifier == "problem") // m_problem = std::make_unique(Problem::fromPDDL(parser)); else - throw utils::ParserException(parser.row(), parser.column(), "Unknown PDDL section \"" + sectionIdentifier + "\""); + throw utils::ParserException(m_context.parser, "Unknown PDDL section \"" + sectionIdentifier + "\""); } //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/plasp/pddl/Domain.cpp b/src/plasp/pddl/Domain.cpp index 28f04b0..73f2a31 100644 --- a/src/plasp/pddl/Domain.cpp +++ b/src/plasp/pddl/Domain.cpp @@ -28,24 +28,24 @@ Domain::Domain(Context &context) //////////////////////////////////////////////////////////////////////////////////////////////////// -Domain Domain::fromPDDL(utils::Parser &parser, Context &context) +Domain Domain::fromPDDL(Context &context) { Domain domain(context); - domain.m_name = parser.parseIdentifier(isIdentifier); + domain.m_name = context.parser.parseIdentifier(isIdentifier); std::cout << "Parsing domain " << domain.m_name << std::endl; - parser.expect(")"); + context.parser.expect(")"); while (true) { - parser.skipWhiteSpace(); + context.parser.skipWhiteSpace(); - if (parser.currentCharacter() == ')') + if (context.parser.currentCharacter() == ')') break; - domain.parseSection(parser); + domain.parseSection(); } domain.computeDerivedRequirements(); @@ -99,12 +99,12 @@ const std::vector> &Domain::actions() const //////////////////////////////////////////////////////////////////////////////////////////////////// -void Domain::parseSection(utils::Parser &parser) +void Domain::parseSection() { - parser.expect("("); - parser.expect(":"); + m_context.parser.expect("("); + m_context.parser.expect(":"); - const auto sectionIdentifier = parser.parseIdentifier(isIdentifier); + const auto sectionIdentifier = m_context.parser.parseIdentifier(isIdentifier); const auto skipSection = [&]() @@ -115,8 +115,8 @@ void Domain::parseSection(utils::Parser &parser) while (true) { - const auto character = parser.currentCharacter(); - parser.advance(); + const auto character = m_context.parser.currentCharacter(); + m_context.parser.advance(); if (character == '(') openParentheses++; @@ -132,19 +132,19 @@ void Domain::parseSection(utils::Parser &parser) // TODO: check order of the sections if (sectionIdentifier == "requirements") - parseRequirementSection(parser); + parseRequirementSection(); else if (sectionIdentifier == "types") - parseTypeSection(parser); + parseTypeSection(); else if (sectionIdentifier == "constants") - parseConstantSection(parser); + parseConstantSection(); else if (sectionIdentifier == "predicates") - parsePredicateSection(parser); + parsePredicateSection(); else if (sectionIdentifier == "functions") skipSection(); else if (sectionIdentifier == "constraints") skipSection(); else if (sectionIdentifier == "action") - parseActionSection(parser); + parseActionSection(); else if (sectionIdentifier == "durative-action") skipSection(); else if (sectionIdentifier == "derived") @@ -153,24 +153,24 @@ void Domain::parseSection(utils::Parser &parser) //////////////////////////////////////////////////////////////////////////////////////////////////// -void Domain::parseRequirementSection(utils::Parser &parser) +void Domain::parseRequirementSection() { - parser.skipWhiteSpace(); + m_context.parser.skipWhiteSpace(); - while (parser.currentCharacter() != ')') + while (m_context.parser.currentCharacter() != ')') { - if (parser.currentCharacter() == ':') - parser.advance(); + if (m_context.parser.currentCharacter() == ':') + m_context.parser.advance(); - m_requirements.emplace_back(Requirement::parse(parser)); + m_requirements.emplace_back(Requirement::parse(m_context.parser)); - parser.skipWhiteSpace(); + m_context.parser.skipWhiteSpace(); } if (m_requirements.empty()) - throw utils::ParserException(parser.row(), parser.column(), "Requirements section does not contain any requirements"); + throw utils::ParserException(m_context.parser, "Requirements section does not contain any requirements"); - parser.expect(")"); + m_context.parser.expect(")"); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -232,67 +232,67 @@ void Domain::computeDerivedRequirements() //////////////////////////////////////////////////////////////////////////////////////////////////// -void Domain::parseTypeSection(utils::Parser &parser) +void Domain::parseTypeSection() { - parser.skipWhiteSpace(); + m_context.parser.skipWhiteSpace(); // Store types and their parent types - while (parser.currentCharacter() != ')') + while (m_context.parser.currentCharacter() != ')') { - if (parser.currentCharacter() == '(') - throw utils::ParserException(parser.row(), parser.column(), "Only primitive types are allowed in type section"); + if (m_context.parser.currentCharacter() == '(') + throw utils::ParserException(m_context.parser, "Only primitive types are allowed in type section"); - expressions::PrimitiveType::parseTypedDeclaration(parser, m_context); + expressions::PrimitiveType::parseTypedDeclaration(m_context.parser, m_context); - parser.skipWhiteSpace(); + m_context.parser.skipWhiteSpace(); } - parser.expect(")"); + m_context.parser.expect(")"); } //////////////////////////////////////////////////////////////////////////////////////////////////// -void Domain::parseConstantSection(utils::Parser &parser) +void Domain::parseConstantSection() { - parser.skipWhiteSpace(); + m_context.parser.skipWhiteSpace(); // Store constants - while (parser.currentCharacter() != ')') + while (m_context.parser.currentCharacter() != ')') { - expressions::Constant::parseTypedDeclaration(parser, m_context); + expressions::Constant::parseTypedDeclaration(m_context.parser, m_context); - parser.skipWhiteSpace(); + m_context.parser.skipWhiteSpace(); } - parser.expect(")"); + m_context.parser.expect(")"); } //////////////////////////////////////////////////////////////////////////////////////////////////// -void Domain::parsePredicateSection(utils::Parser &parser) +void Domain::parsePredicateSection() { - parser.skipWhiteSpace(); + m_context.parser.skipWhiteSpace(); // Store predicates and their arguments - while (parser.currentCharacter() != ')') + while (m_context.parser.currentCharacter() != ')') { - expressions::PredicateDeclaration::parse(parser, m_context); + expressions::PredicateDeclaration::parse(m_context.parser, m_context); - parser.skipWhiteSpace(); + m_context.parser.skipWhiteSpace(); } - parser.expect(")"); + m_context.parser.expect(")"); } //////////////////////////////////////////////////////////////////////////////////////////////////// -void Domain::parseActionSection(utils::Parser &parser) +void Domain::parseActionSection() { - parser.skipWhiteSpace(); + m_context.parser.skipWhiteSpace(); - Action::parseDeclaration(parser, m_context); + Action::parseDeclaration(m_context.parser, m_context); - parser.expect(")"); + m_context.parser.expect(")"); } //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/plasp/pddl/Expression.cpp b/src/plasp/pddl/Expression.cpp index 621fa28..39df92a 100644 --- a/src/plasp/pddl/Expression.cpp +++ b/src/plasp/pddl/Expression.cpp @@ -32,7 +32,7 @@ ExpressionPointer parsePredicate(utils::Parser &parser, Context &context, void throwUnsupported(const utils::Parser &parser, const std::string &expressionIdentifier) { - throw utils::ParserException(parser.row(), parser.column(), "Expression type \"" + expressionIdentifier + "\" currently unsupported"); + throw utils::ParserException(parser, "Expression type \"" + expressionIdentifier + "\" currently unsupported"); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -125,7 +125,7 @@ ExpressionPointer parseExpressionContent(const std::string &expressionIdentifier if (match != context.predicateDeclarations.cend()) expression = expressions::Predicate::parse(expressionIdentifier, parser, context, parameters); else - throw utils::ParserException(parser.row(), parser.column(), "Expression \"" + expressionIdentifier + "\" not allowed in this context"); + throw utils::ParserException(parser, "Expression \"" + expressionIdentifier + "\" not allowed in this context"); } return expression; @@ -188,7 +188,7 @@ ExpressionPointer parseEffectBodyExpressionContent(const std::string &expression if (match != context.predicateDeclarations.cend()) expression = expressions::Predicate::parse(expressionIdentifier, parser, context, parameters); else - throw utils::ParserException(parser.row(), parser.column(), "Expression \"" + expressionIdentifier + "\" not allowed in this context"); + throw utils::ParserException(parser, "Expression \"" + expressionIdentifier + "\" not allowed in this context"); } return expression; @@ -214,7 +214,7 @@ ExpressionPointer parsePredicate(utils::Parser &parser, Context &context, // If predicate exists, parse it if (match == context.predicateDeclarations.cend()) - throw utils::ParserException(parser.row(), parser.column(), "Unknown predicate \"" + predicateName + "\""); + throw utils::ParserException(parser, "Unknown predicate \"" + predicateName + "\""); expression = expressions::Predicate::parse(predicateName, parser, context, parameters); diff --git a/src/plasp/pddl/Requirement.cpp b/src/plasp/pddl/Requirement.cpp index 95e4616..686a2f3 100644 --- a/src/plasp/pddl/Requirement.cpp +++ b/src/plasp/pddl/Requirement.cpp @@ -86,7 +86,7 @@ Requirement Requirement::parse(utils::Parser &parser) const auto match = requirementTypesToPDDL.right.find(requirementName); if (match == requirementTypesToPDDL.right.end()) - throw utils::ParserException(parser.row(), parser.column(), "Unknown PDDL requirement \"" + requirementName + "\""); + throw utils::ParserException(parser, "Unknown PDDL requirement \"" + requirementName + "\""); return Requirement(match->second); } diff --git a/src/plasp/pddl/expressions/Constant.cpp b/src/plasp/pddl/expressions/Constant.cpp index 843bd28..69506a8 100644 --- a/src/plasp/pddl/expressions/Constant.cpp +++ b/src/plasp/pddl/expressions/Constant.cpp @@ -81,6 +81,27 @@ void Constant::parseTypedDeclaration(utils::Parser &parser, Context &context) //////////////////////////////////////////////////////////////////////////////////////////////////// +Constant *Constant::parseExisting(utils::Parser &parser, Context &context) +{ + parser.skipWhiteSpace(); + + const auto constantName = parser.parseIdentifier(isIdentifier); + // TODO: use hash map + const auto match = std::find_if(context.constants.cbegin(), context.constants.cend(), + [&](const auto &constant) + { + return constant->name() == constantName; + }); + const auto constantExists = (match != context.constants.cend()); + + if (!constantExists) + throw utils::ParserException(parser, "Constant \"" + constantName + "\" used but never declared"); + + return match->get(); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + void Constant::accept(plasp::pddl::ExpressionVisitor &expressionVisitor) const { expressionVisitor.visit(*this); diff --git a/src/plasp/pddl/expressions/Predicate.cpp b/src/plasp/pddl/expressions/Predicate.cpp index d3c4368..6103007 100644 --- a/src/plasp/pddl/expressions/Predicate.cpp +++ b/src/plasp/pddl/expressions/Predicate.cpp @@ -49,7 +49,7 @@ PredicatePointer Predicate::parse(std::string name, utils::Parser &parser, // Parse constants else { - const auto *constant = Constant::parseExisting(parser, context.constants); + const auto *constant = Constant::parseExisting(parser, context); auto constantReference = std::make_unique>(constant); predicate->m_arguments.emplace_back(std::move(constantReference)); } diff --git a/src/plasp/pddl/expressions/Variable.cpp b/src/plasp/pddl/expressions/Variable.cpp index e3bfd4e..81add30 100644 --- a/src/plasp/pddl/expressions/Variable.cpp +++ b/src/plasp/pddl/expressions/Variable.cpp @@ -116,7 +116,7 @@ const Variable *Variable::parseExisting(utils::Parser &parser, const Variables & }); if (match == variables.cend()) - throw utils::ParserException(parser.row(), parser.column(), "Variable \"" + variableName + "\" used but never declared"); + throw utils::ParserException(parser, "Variable \"" + variableName + "\" used but never declared"); return match->get(); } diff --git a/src/plasp/sas/Description.cpp b/src/plasp/sas/Description.cpp index ffb524f..eb98490 100644 --- a/src/plasp/sas/Description.cpp +++ b/src/plasp/sas/Description.cpp @@ -153,7 +153,7 @@ void Description::parseVersionSection(utils::Parser &parser) const const auto formatVersion = parser.parse(); if (formatVersion != 3) - throw utils::ParserException(parser.row(), parser.column(), "Unsupported SAS format version (" + std::to_string(formatVersion) + ")"); + throw utils::ParserException(parser, "Unsupported SAS format version (" + std::to_string(formatVersion) + ")"); parser.expect("end_version"); } diff --git a/src/plasp/sas/MutexGroup.cpp b/src/plasp/sas/MutexGroup.cpp index 8709f84..c2edf96 100644 --- a/src/plasp/sas/MutexGroup.cpp +++ b/src/plasp/sas/MutexGroup.cpp @@ -29,7 +29,7 @@ MutexGroup MutexGroup::fromSAS(utils::Parser &parser, const Variables &variables mutexGroup.m_facts.emplace_back(Fact::fromSAS(parser, variables)); if (mutexGroup.m_facts[j].value() == Value::None) - throw utils::ParserException(parser.row(), parser.column(), "Mutex groups must not contain values"); + throw utils::ParserException(parser, "Mutex groups must not contain values"); } parser.expect("end_mutex_group"); diff --git a/src/plasp/sas/Predicate.cpp b/src/plasp/sas/Predicate.cpp index db9aae8..023d276 100644 --- a/src/plasp/sas/Predicate.cpp +++ b/src/plasp/sas/Predicate.cpp @@ -46,7 +46,7 @@ Predicate Predicate::fromSAS(utils::Parser &parser) } catch (const std::exception &e) { - throw utils::ParserException(parser.row(), parser.column(), "Could not parse operator predicate"); + throw utils::ParserException(parser, "Could not parse operator predicate"); } return predicate; diff --git a/src/plasp/sas/Value.cpp b/src/plasp/sas/Value.cpp index 2c13e34..d399143 100644 --- a/src/plasp/sas/Value.cpp +++ b/src/plasp/sas/Value.cpp @@ -74,7 +74,7 @@ Value Value::fromSAS(utils::Parser &parser) else if (sasSign == "NegatedAtom") value.m_sign = Value::Sign::Negative; else - throw utils::ParserException(parser.row(), parser.column(), "Invalid value sign \"" + sasSign + "\""); + throw utils::ParserException(parser, "Invalid value sign \"" + sasSign + "\""); try { @@ -90,7 +90,7 @@ Value Value::fromSAS(utils::Parser &parser) } catch (const std::exception &e) { - throw utils::ParserException(parser.row(), parser.column(), std::string("Could not parse variable value (") + e.what() + ")"); + throw utils::ParserException(parser, std::string("Could not parse variable value (") + e.what() + ")"); } return value; @@ -106,7 +106,7 @@ const Value &Value::referenceFromSAS(utils::Parser &parser, const Variable &vari return Value::Any; if (valueID < 0 || static_cast(valueID) >= variable.values().size()) - throw utils::ParserException(parser.row(), parser.column(), "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]; } diff --git a/src/plasp/sas/Variable.cpp b/src/plasp/sas/Variable.cpp index 104f3f3..9a9594d 100644 --- a/src/plasp/sas/Variable.cpp +++ b/src/plasp/sas/Variable.cpp @@ -41,7 +41,7 @@ Variable Variable::fromSAS(utils::Parser &parser) // values are only allowed at the end if (j < numberOfValues - 1 && variable.m_values[j] == Value::None) - throw utils::ParserException(parser.row(), parser.column(), " value must be the last value of a variable"); + throw utils::ParserException(parser, " value must be the last value of a variable"); } parser.expect("end_variable"); @@ -63,7 +63,7 @@ const Variable &Variable::referenceFromSAS(utils::Parser &parser, const Variable const auto variableID = parser.parse(); if (variableID >= variables.size()) - throw utils::ParserException(parser.row(), parser.column(), "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]; } diff --git a/src/plasp/utils/Parser.cpp b/src/plasp/utils/Parser.cpp index 560b101..e350b74 100644 --- a/src/plasp/utils/Parser.cpp +++ b/src/plasp/utils/Parser.cpp @@ -71,10 +71,10 @@ bool Parser::atEndOfFile() const void Parser::checkStream() const { if (atEndOfFile()) - throw ParserException(m_row, m_column, "Reading past end of file"); + throw ParserException(*this, "Reading past end of file"); if (m_istream.fail()) - throw ParserException(m_row, m_column); + throw ParserException(*this); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -196,7 +196,7 @@ void Parser::expect(const std::string &expectedValue) const auto character = static_cast(this->currentCharacter()); if (character != expectedCharacter) - throw ParserException(m_row, m_column, "Unexpected string, expected \"" + expectedValue + "\" (expected character '" + expectedCharacter + "', got '" + character + "')"); + throw ParserException(*this, "Unexpected string, expected \"" + expectedValue + "\" (expected character '" + expectedCharacter + "', got '" + character + "')"); this->advance(); }); @@ -209,7 +209,7 @@ uint64_t Parser::parseIntegerBody() checkStream(); if (!std::isdigit(currentCharacter())) - throw ParserException(m_row, m_column, "Could not parse integer value"); + throw ParserException(*this, "Could not parse integer value"); uint64_t value = 0; @@ -251,7 +251,7 @@ uint64_t Parser::parse() skipWhiteSpace(); if (currentCharacter() == '-') - throw ParserException(m_row, m_column, "Expected unsigned integer, got signed one"); + throw ParserException(*this, "Expected unsigned integer, got signed one"); return parseIntegerBody(); } @@ -264,7 +264,7 @@ void Parser::expect(const int64_t &expectedValue) const auto value = parse(); if (value != expectedValue) - throw ParserException(m_row, m_column, "Unexpected value " + std::to_string(value) + ", expected " + std::to_string(expectedValue)); + throw ParserException(*this, "Unexpected value " + std::to_string(value) + ", expected " + std::to_string(expectedValue)); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -275,7 +275,7 @@ void Parser::expect(const uint64_t &expectedValue) const auto value = parse(); if (value != expectedValue) - throw ParserException(m_row, m_column, "Unexpected value " + std::to_string(value) + ", expected " + std::to_string(expectedValue)); + throw ParserException(*this, "Unexpected value " + std::to_string(value) + ", expected " + std::to_string(expectedValue)); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -387,7 +387,7 @@ bool Parser::parse() if (advanceIf('1')) return true; - throw ParserException(m_row, m_column, "Could not parse Boolean value"); + throw ParserException(*this, "Could not parse Boolean value"); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -398,7 +398,7 @@ void Parser::expect(const bool &expectedValue) const auto value = parse(); if (value != expectedValue) - throw ParserException(m_row, m_column, "Unexpected value " + std::to_string(value) + ", expected " + std::to_string(expectedValue)); + throw ParserException(*this, "Unexpected value " + std::to_string(value) + ", expected " + std::to_string(expectedValue)); } ////////////////////////////////////////////////////////////////////////////////////////////////////