mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 02:59:45 +00:00
LibCpp: Add support for parsing function types
This makes it work with types like `Function<T(U, V)>`.
This commit is contained in:
parent
b3cbe14569
commit
5f66874ea0
Notes:
sideshowbarker
2024-07-18 07:36:21 +09:00
Author: https://github.com/alimpfard
Commit: 5f66874ea0
Pull-request: https://github.com/SerenityOS/serenity/pull/9156
Reviewed-by: https://github.com/itamar8910 ✅
3 changed files with 66 additions and 0 deletions
|
@ -1255,7 +1255,19 @@ NonnullRefPtr<Type> Parser::parse_type(ASTNode& parent)
|
|||
type = ref;
|
||||
}
|
||||
|
||||
if (peek().type() == Token::Type::LeftParen) {
|
||||
consume();
|
||||
auto fn_type = create_ast_node<FunctionType>(parent, type->start(), position());
|
||||
fn_type->set_return_type(*type);
|
||||
type->set_parent(*fn_type);
|
||||
if (auto parameters = parse_parameter_list(*type); parameters.has_value())
|
||||
fn_type->set_parameters(parameters.release_value());
|
||||
consume(Token::Type::RightParen);
|
||||
type = fn_type;
|
||||
}
|
||||
|
||||
type->set_end(position());
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue