Skip to content

Sync to latest PEGTL commit and fix breaks #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PEGTL
Submodule PEGTL updated 309 files
2 changes: 1 addition & 1 deletion include/graphqlservice/GraphQLService.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ GRAPHQLSERVICE_EXPORT void addErrorMessage(std::string&& message, response::Valu
struct schema_location
{
size_t line = 0;
size_t byte_in_line = 0;
size_t column = 1;
};

GRAPHQLSERVICE_EXPORT void addErrorLocation(const schema_location& location, response::Value& error);
Expand Down
44 changes: 22 additions & 22 deletions src/GraphQLService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void addErrorLocation(const schema_location& location, response::Value& error)

errorLocation.reserve(2);
errorLocation.emplace_back(std::string { strLine }, response::Value(static_cast<response::IntType>(location.line)));
errorLocation.emplace_back(std::string { strColumn }, response::Value(static_cast<response::IntType>(location.byte_in_line + 1)));
errorLocation.emplace_back(std::string { strColumn }, response::Value(static_cast<response::IntType>(location.column)));

response::Value errorLocations(response::Type::List);

Expand Down Expand Up @@ -254,7 +254,7 @@ void ValueVisitor::visitVariable(const peg::ast_node& variable)

error << "Unknown variable name: " << name;

throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line } } } };
throw schema_exception { { schema_error{ error.str(), { position.line, position.column } } } };
}

_value = response::Value(itr->second);
Expand Down Expand Up @@ -510,7 +510,7 @@ schema_location ResolverParams::getLocation() const
{
auto position = field.begin();

return { position.line, position.byte_in_line };
return { position.line, position.column };
}

uint8_t Base64::verifyFromBase64(char ch)
Expand Down Expand Up @@ -737,7 +737,7 @@ std::future<response::Value> ModifiedResult<response::IntType>::convert(FieldRes

error << "Field may not have sub-fields name: " << params.fieldName;

throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line }, { params.errorPath } } } };
throw schema_exception { { schema_error{ error.str(), { position.line, position.column }, { params.errorPath } } } };
}

return resolve(std::move(result), std::move(params),
Expand All @@ -758,7 +758,7 @@ std::future<response::Value> ModifiedResult<response::FloatType>::convert(FieldR

error << "Field may not have sub-fields name: " << params.fieldName;

throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line }, { params.errorPath } } } };
throw schema_exception { { schema_error{ error.str(), { position.line, position.column }, { params.errorPath } } } };
}

return resolve(std::move(result), std::move(params),
Expand All @@ -779,7 +779,7 @@ std::future<response::Value> ModifiedResult<response::StringType>::convert(Field

error << "Field may not have sub-fields name: " << params.fieldName;

throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line }, { params.errorPath } } } };
throw schema_exception { { schema_error{ error.str(), { position.line, position.column }, { params.errorPath } } } };
}

return resolve(std::move(result), std::move(params),
Expand All @@ -800,7 +800,7 @@ std::future<response::Value> ModifiedResult<response::BooleanType>::convert(Fiel

error << "Field may not have sub-fields name: " << params.fieldName;

throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line }, { params.errorPath } } } };
throw schema_exception { { schema_error{ error.str(), { position.line, position.column }, { params.errorPath } } } };
}

return resolve(std::move(result), std::move(params),
Expand All @@ -821,7 +821,7 @@ std::future<response::Value> ModifiedResult<response::Value>::convert(FieldResul

error << "Field may not have sub-fields name: " << params.fieldName;

throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line }, { params.errorPath } } } };
throw schema_exception { { schema_error{ error.str(), { position.line, position.column }, { params.errorPath } } } };
}

return resolve(std::move(result), std::move(params),
Expand All @@ -842,7 +842,7 @@ std::future<response::Value> ModifiedResult<response::IdType>::convert(FieldResu

error << "Field may not have sub-fields name: " << params.fieldName;

throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line }, { params.errorPath } } } };
throw schema_exception { { schema_error{ error.str(), { position.line, position.column }, { params.errorPath } } } };
}

return resolve(std::move(result), std::move(params),
Expand All @@ -863,7 +863,7 @@ std::future<response::Value> ModifiedResult<Object>::convert(FieldResult<std::sh

error << "Field must have sub-fields name: " << params.fieldName;

throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line }, { params.errorPath } } } };
throw schema_exception { { schema_error{ error.str(), { position.line, position.column }, { params.errorPath } } } };
}

return std::async(params.launch,
Expand Down Expand Up @@ -1013,7 +1013,7 @@ void SelectionVisitor::visitField(const peg::ast_node& field)
promise.set_exception(std::make_exception_ptr(
schema_exception { { schema_error{
error.str(),
{ position.line, position.byte_in_line },
{ position.line, position.column },
{ _path }
} } }));

Expand Down Expand Up @@ -1095,7 +1095,7 @@ void SelectionVisitor::visitField(const peg::ast_node& field)
{
if (message.location.line == 0)
{
message.location = { position.line, position.byte_in_line };
message.location = { position.line, position.column };
}

if (message.path.empty())
Expand Down Expand Up @@ -1123,7 +1123,7 @@ void SelectionVisitor::visitField(const peg::ast_node& field)
promise.set_exception(std::make_exception_ptr(
schema_exception { { schema_error{
message.str(),
{ position.line, position.byte_in_line },
{ position.line, position.column },
std::move(selectionSetParams.errorPath)
} } }));

Expand All @@ -1146,7 +1146,7 @@ void SelectionVisitor::visitFragmentSpread(const peg::ast_node& fragmentSpread)

error << "Unknown fragment name: " << name;

throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line }, { _path } } } };
throw schema_exception { { schema_error{ error.str(), { position.line, position.column }, { _path } } } };
}

bool skip = (_typeNames.count(itr->second.getType()) == 0);
Expand Down Expand Up @@ -1676,7 +1676,7 @@ void SubscriptionDefinitionVisitor::visitField(const peg::ast_node& field)

error << "Extra subscription root field name: " << name;

throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line } } } };
throw schema_exception { { schema_error{ error.str(), { position.line, position.column } } } };
}

DirectiveVisitor directiveVisitor(_params.variables);
Expand Down Expand Up @@ -1723,7 +1723,7 @@ void SubscriptionDefinitionVisitor::visitFragmentSpread(const peg::ast_node& fra

error << "Unknown fragment name: " << name;

throw schema_exception { { schema_error{ error.str(), { position.line, position.byte_in_line } } } };
throw schema_exception { { schema_error{ error.str(), { position.line, position.column } } } };
}

bool skip = !_subscriptionObject->matchesType(itr->second.getType());
Expand Down Expand Up @@ -1852,7 +1852,7 @@ std::pair<std::string, const peg::ast_node*> Request::findOperationDefinition(co
message << "Duplicate named operations name: " << name;
}

errors.push_back({ message.str(), { position.line, position.byte_in_line } });
errors.push_back({ message.str(), { position.line, position.column } });
}

hasAnonymous = hasAnonymous || name.empty();
Expand All @@ -1873,7 +1873,7 @@ std::pair<std::string, const peg::ast_node*> Request::findOperationDefinition(co
message << "Unexpected named operation name: " << name;
}

errors.push_back({ message.str(), { position.line, position.byte_in_line } });
errors.push_back({ message.str(), { position.line, position.column } });
}

auto itr = _operations.find(operationType);
Expand All @@ -1889,7 +1889,7 @@ std::pair<std::string, const peg::ast_node*> Request::findOperationDefinition(co
message << " name: " << name;
}

errors.push_back({ message.str(), { position.line, position.byte_in_line } });
errors.push_back({ message.str(), { position.line, position.column } });
}

if (!errors.empty())
Expand Down Expand Up @@ -1955,7 +1955,7 @@ std::future<response::Value> Request::resolveValidated(std::launch launch, const

message << "Unexpected type definition";

throw schema_exception { { schema_error{ message.str(), { position.line, position.byte_in_line } } } };
throw schema_exception { { schema_error{ message.str(), { position.line, position.column } } } };
}
}

Expand Down Expand Up @@ -1995,7 +1995,7 @@ std::future<response::Value> Request::resolveValidated(std::launch launch, const
message << " name: " << operationName;
}

throw schema_exception { { schema_error{ message.str(), { position.line, position.byte_in_line } } } };
throw schema_exception { { schema_error{ message.str(), { position.line, position.column } } } };
}

// http://spec.graphql.org/June2018/#sec-Normal-and-Serial-Execution
Expand Down Expand Up @@ -2069,7 +2069,7 @@ SubscriptionKey Request::subscribe(SubscriptionParams&& params, SubscriptionCall
message << " name: " << params.operationName;
}

throw schema_exception { { schema_error{ message.str(), { position.line, position.byte_in_line } } } };
throw schema_exception { { schema_error{ message.str(), { position.line, position.column } } } };
}

auto itr = _operations.find(std::string { strSubscription });
Expand Down
6 changes: 3 additions & 3 deletions src/GraphQLTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct ast_selector<escaped_unicode>
}
}

throw parse_error("invalid escaped unicode code point", { n->begin(), n->end() });
throw parse_error("invalid escaped unicode code point", n->begin());
}
};

Expand Down Expand Up @@ -141,7 +141,7 @@ struct ast_selector<escaped_char>
}
}

throw parse_error("invalid escaped character sequence", { n->begin(), n->end() });
throw parse_error("invalid escaped character sequence", n->begin());
}
};

Expand Down Expand Up @@ -574,7 +574,7 @@ struct ast_control
static const std::string error_message;

template <typename Input, typename... State>
static void raise(const Input& in, State&&...)
[[noreturn]] static void raise(const Input& in, State&&...)
{
throw parse_error(error_message, in);
}
Expand Down
20 changes: 10 additions & 10 deletions src/SchemaGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ void Generator::validateSchema()
if (itrPosition != _typePositions.cend())
{
error << " line: " << itrPosition->second.line
<< " column: " << (itrPosition->second.byte_in_line + 1);
<< " column: " << itrPosition->second.column;
}

throw std::runtime_error(error.str());
Expand Down Expand Up @@ -513,7 +513,7 @@ void Generator::validateSchema()
if (itrPosition != _typePositions.cend())
{
error << " line: " << itrPosition->second.line
<< " column: " << (itrPosition->second.byte_in_line + 1);
<< " column: " << itrPosition->second.column;
}

throw std::runtime_error(error.str());
Expand Down Expand Up @@ -558,7 +558,7 @@ void Generator::fixupOutputFieldList(OutputFieldList& fields, const std::optiona
if (entry.position)
{
error << " line: " << entry.position->line
<< " column: " << (entry.position->byte_in_line + 1);
<< " column: " << entry.position->column;
}

throw std::runtime_error(error.str());
Expand Down Expand Up @@ -595,7 +595,7 @@ void Generator::fixupOutputFieldList(OutputFieldList& fields, const std::optiona
if (entry.position)
{
error << " line: " << entry.position->line
<< " column: " << (entry.position->byte_in_line + 1);
<< " column: " << entry.position->column;
}

throw std::runtime_error(error.str());
Expand Down Expand Up @@ -626,7 +626,7 @@ void Generator::fixupInputFieldList(InputFieldList& fields)
if (entry.position)
{
error << " line: " << entry.position->line
<< " column: " << (entry.position->byte_in_line + 1);
<< " column: " << entry.position->column;
}

throw std::runtime_error(error.str());
Expand Down Expand Up @@ -655,7 +655,7 @@ void Generator::fixupInputFieldList(InputFieldList& fields)
if (entry.position)
{
error << " line: " << entry.position->line
<< " column: " << (entry.position->byte_in_line + 1);
<< " column: " << entry.position->column;
}

throw std::runtime_error(error.str());
Expand Down Expand Up @@ -1298,7 +1298,7 @@ InputFieldList Generator::getInputFields(const std::vector<std::unique_ptr<peg::
field.defaultValue = defaultValue.getValue();
field.defaultValueString = child->children.back()->string_view();

defaultValueLocation = { position.line, position.byte_in_line };
defaultValueLocation = { position.line, position.column };
}
else if (child->is_type<peg::description>())
{
Expand All @@ -1318,7 +1318,7 @@ InputFieldList Generator::getInputFields(const std::vector<std::unique_ptr<peg::

error << "Expected Non-Null default value for field name: " << field.name
<< " line: " << defaultValueLocation.line
<< " column: " << (defaultValueLocation.byte_in_line + 1);
<< " column: " << defaultValueLocation.column;

throw std::runtime_error(error.str());
}
Expand Down Expand Up @@ -3608,10 +3608,10 @@ int main(int argc, char** argv)
std::cerr << "Invalid GraphQL: " << pe.what()
<< std::endl;

for (const auto& position : pe.positions)
for (const auto& position : pe.positions())
{
std::cerr << "\tline: " << position.line
<< " column: " << (position.byte_in_line + 1)
<< " column: " << position.column
<< std::endl;
}

Expand Down
Loading