mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibIDL: Allow trailing comma in enumerations
IDL enumerations are one of the rare list types in the IDL spec that allow for a trailing comma: https://www.w3.org/Bugs/Public/show_bug.cgi?id=17508
This commit is contained in:
parent
286511c4cf
commit
47597d0fb8
Notes:
github-actions[bot]
2024-11-01 11:28:57 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/47597d0fb83 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2097
1 changed files with 5 additions and 7 deletions
|
@ -3,6 +3,7 @@
|
||||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||||
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
||||||
* Copyright (c) 2022, Ali Mohammad Pur <mpfard@serenityos.org>
|
* Copyright (c) 2022, Ali Mohammad Pur <mpfard@serenityos.org>
|
||||||
|
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -738,6 +739,7 @@ void Parser::parse_namespace(Interface& interface)
|
||||||
consume_whitespace();
|
consume_whitespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://webidl.spec.whatwg.org/#prod-Enum
|
||||||
void Parser::parse_enumeration(HashMap<ByteString, ByteString> extended_attributes, Interface& interface)
|
void Parser::parse_enumeration(HashMap<ByteString, ByteString> extended_attributes, Interface& interface)
|
||||||
{
|
{
|
||||||
assert_string("enum"sv);
|
assert_string("enum"sv);
|
||||||
|
@ -751,15 +753,10 @@ void Parser::parse_enumeration(HashMap<ByteString, ByteString> extended_attribut
|
||||||
|
|
||||||
assert_specific('{');
|
assert_specific('{');
|
||||||
|
|
||||||
bool first = true;
|
|
||||||
for (; !lexer.is_eof();) {
|
for (; !lexer.is_eof();) {
|
||||||
consume_whitespace();
|
consume_whitespace();
|
||||||
if (lexer.next_is('}'))
|
if (lexer.next_is('}'))
|
||||||
break;
|
break;
|
||||||
if (!first) {
|
|
||||||
assert_specific(',');
|
|
||||||
consume_whitespace();
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_specific('"');
|
assert_specific('"');
|
||||||
auto string = lexer.consume_until('"');
|
auto string = lexer.consume_until('"');
|
||||||
|
@ -771,10 +768,11 @@ void Parser::parse_enumeration(HashMap<ByteString, ByteString> extended_attribut
|
||||||
else
|
else
|
||||||
enumeration.values.set(string);
|
enumeration.values.set(string);
|
||||||
|
|
||||||
if (first)
|
if (enumeration.first_member.is_empty())
|
||||||
enumeration.first_member = move(string);
|
enumeration.first_member = move(string);
|
||||||
|
|
||||||
first = false;
|
if (!lexer.next_is('}'))
|
||||||
|
assert_specific(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
consume_whitespace();
|
consume_whitespace();
|
||||||
|
|
Loading…
Reference in a new issue