mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
IPCCompiler: Give a useful error if parameter is unnamed
Previously, parsing would continue if a parameter wasn't given a name and malformed code would be generated, leading to hard to diagnose compiler errors.
This commit is contained in:
parent
076904a59b
commit
8324a82409
Notes:
sideshowbarker
2024-07-17 00:37:23 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/8324a82409 Pull-request: https://github.com/SerenityOS/serenity/pull/23871 Issue: https://github.com/SerenityOS/serenity/issues/23744
1 changed files with 10 additions and 6 deletions
|
@ -140,8 +140,8 @@ Vector<Endpoint> parse(ByteBuffer const& file_contents)
|
|||
return parameter_type;
|
||||
};
|
||||
|
||||
auto parse_parameter = [&](Vector<Parameter>& storage) {
|
||||
for (;;) {
|
||||
auto parse_parameter = [&](Vector<Parameter>& storage, StringView message_name) {
|
||||
for (auto parameter_index = 1;; ++parameter_index) {
|
||||
Parameter parameter;
|
||||
if (lexer.is_eof()) {
|
||||
warnln("EOF when parsing parameter");
|
||||
|
@ -165,6 +165,10 @@ Vector<Endpoint> parse(ByteBuffer const& file_contents)
|
|||
}
|
||||
}
|
||||
parameter.type = parse_parameter_type();
|
||||
if (parameter.type.ends_with(',') || parameter.type.ends_with(')')) {
|
||||
warnln("Parameter {} of method: {} must be named", parameter_index, message_name);
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
VERIFY(!lexer.is_eof());
|
||||
consume_whitespace();
|
||||
parameter.name = lexer.consume_until([](char ch) { return isspace(ch) || ch == ',' || ch == ')'; });
|
||||
|
@ -177,10 +181,10 @@ Vector<Endpoint> parse(ByteBuffer const& file_contents)
|
|||
}
|
||||
};
|
||||
|
||||
auto parse_parameters = [&](Vector<Parameter>& storage) {
|
||||
auto parse_parameters = [&](Vector<Parameter>& storage, StringView message_name) {
|
||||
for (;;) {
|
||||
consume_whitespace();
|
||||
parse_parameter(storage);
|
||||
parse_parameter(storage, message_name);
|
||||
consume_whitespace();
|
||||
if (lexer.consume_specific(','))
|
||||
continue;
|
||||
|
@ -195,7 +199,7 @@ Vector<Endpoint> parse(ByteBuffer const& file_contents)
|
|||
message.name = lexer.consume_until([](char ch) { return isspace(ch) || ch == '('; });
|
||||
consume_whitespace();
|
||||
assert_specific('(');
|
||||
parse_parameters(message.inputs);
|
||||
parse_parameters(message.inputs, message.name);
|
||||
assert_specific(')');
|
||||
consume_whitespace();
|
||||
assert_specific('=');
|
||||
|
@ -212,7 +216,7 @@ Vector<Endpoint> parse(ByteBuffer const& file_contents)
|
|||
|
||||
if (message.is_synchronous) {
|
||||
assert_specific('(');
|
||||
parse_parameters(message.outputs);
|
||||
parse_parameters(message.outputs, message.name);
|
||||
assert_specific(')');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue