| 8422 | } |
| 8423 | |
| 8424 | NonnullRefPtr<typename Jakt::parser::ParsedExpression> Jakt::parser::Parser::parse_lambda() { |
| 8425 | { |
| 8426 | Jakt::utility::Span const start = this->current().span(); |
| 8427 | this->index++; |
| 8428 | JaktInternal::DynamicArray<Jakt::parser::ParsedCapture> const captures = this->parse_captures(); |
| 8429 | Jakt::parser::ParsedFunctionParameters const fn_parameters = this->parse_function_parameters(false); |
| 8430 | bool const can_throw = this->current().__jakt_init_index() == 102 /* Throws */; |
| 8431 | if (can_throw){ |
| 8432 | this->index++; |
| 8433 | } |
| 8434 | if (fn_parameters.has_varargs){ |
| 8435 | this->error(ByteString::from_utf8_without_validation("Anonymous functions cannot have varargs"sv),this->current().span()); |
| 8436 | } |
| 8437 | NonnullRefPtr<typename Jakt::parser::ParsedType> return_type = [&]() -> NonnullRefPtr<typename Jakt::parser::ParsedType> { auto&& __jakt_match_variant = this->current(); |
| 8438 | switch(__jakt_match_variant.__jakt_init_index()) { |
| 8439 | case 58 /* Arrow */:{ |
| 8440 | this->index++; |
| 8441 | return this->parse_typename(); |
| 8442 | } |
| 8443 | VERIFY_NOT_REACHED(); |
| 8444 | default:return Jakt::parser::ParsedType::Empty(JaktInternal::OptionalNone());}/*switch end*/ |
| 8445 | |
| 8446 | }(); |
| 8447 | bool is_fat_arrow = false; |
| 8448 | Jakt::parser::ParsedBlock const block = [&]() -> Jakt::parser::ParsedBlock { auto&& __jakt_match_variant = this->current(); |
| 8449 | switch(__jakt_match_variant.__jakt_init_index()) { |
| 8450 | case 57 /* FatArrow */:{ |
| 8451 | is_fat_arrow = true; |
| 8452 | this->index++; |
| 8453 | NonnullRefPtr<typename Jakt::parser::ParsedExpression> const expr = this->parse_expression(true,false); |
| 8454 | Jakt::utility::Span const span = expr->span(); |
| 8455 | return Jakt::parser::ParsedBlock(DynamicArray<NonnullRefPtr<typename Jakt::parser::ParsedStatement>>::create_with({Jakt::parser::ParsedStatement::Return(expr,span)})); |
| 8456 | } |
| 8457 | VERIFY_NOT_REACHED(); |
| 8458 | default:return this->parse_block();}/*switch end*/ |
| 8459 | |
| 8460 | }(); |
| 8461 | return Jakt::parser::ParsedExpression::Function(captures,fn_parameters.parameters,can_throw,is_fat_arrow,return_type,block,Jakt::parser::merge_spans(start,this->current().span())); |
| 8462 | } |
| 8463 | } |
| 8464 | |
| 8465 | NonnullRefPtr<typename Jakt::parser::ParsedExpression> Jakt::parser::Parser::parse_asterisk() { |
| 8466 | { |
no test coverage detected