mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
LibIDL: Begin parsing IDL namespaces
For example, the CSS namespace is defined via IDL, but we currently have a manual implementation.
This commit is contained in:
parent
406a7ea577
commit
61ecdbca54
3 changed files with 33 additions and 1 deletions
|
@ -599,6 +599,33 @@ void Parser::parse_interface(Interface& interface)
|
|||
consume_whitespace();
|
||||
}
|
||||
|
||||
void Parser::parse_namespace(Interface& interface)
|
||||
{
|
||||
consume_whitespace();
|
||||
|
||||
interface.name = lexer.consume_until([](auto ch) { return is_ascii_space(ch); });
|
||||
interface.is_namespace = true;
|
||||
|
||||
consume_whitespace();
|
||||
assert_specific('{');
|
||||
|
||||
for (;;) {
|
||||
consume_whitespace();
|
||||
|
||||
if (lexer.consume_specific('}')) {
|
||||
consume_whitespace();
|
||||
assert_specific(';');
|
||||
break;
|
||||
}
|
||||
|
||||
HashMap<DeprecatedString, DeprecatedString> extended_attributes;
|
||||
parse_function(extended_attributes, interface);
|
||||
}
|
||||
|
||||
interface.namespace_class = DeprecatedString::formatted("{}Namespace", interface.name);
|
||||
consume_whitespace();
|
||||
}
|
||||
|
||||
void Parser::parse_enumeration(Interface& interface)
|
||||
{
|
||||
assert_string("enum"sv);
|
||||
|
@ -802,7 +829,7 @@ void Parser::parse_non_interface_entities(bool allow_interface, Interface& inter
|
|||
parse_interface_mixin(interface);
|
||||
} else if (lexer.next_is("callback")) {
|
||||
parse_callback_function(extended_attributes, interface);
|
||||
} else if ((allow_interface && !lexer.next_is("interface")) || !allow_interface) {
|
||||
} else if ((allow_interface && !lexer.next_is("interface") && !lexer.next_is("namespace")) || !allow_interface) {
|
||||
auto current_offset = lexer.tell();
|
||||
auto name = lexer.consume_until([](auto ch) { return is_ascii_space(ch); });
|
||||
consume_whitespace();
|
||||
|
@ -920,6 +947,8 @@ Interface& Parser::parse()
|
|||
|
||||
if (lexer.consume_specific("interface"))
|
||||
parse_interface(interface);
|
||||
else if (lexer.consume_specific("namespace"))
|
||||
parse_namespace(interface);
|
||||
|
||||
parse_non_interface_entities(false, interface);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue