MCPcopy Create free account
hub / github.com/SerenityOS/jakt / parse_captures

Method parse_captures

bootstrap/stage0/parser.cpp:8336–8422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8334}
8335
8336JaktInternal::DynamicArray<Jakt::parser::ParsedCapture> Jakt::parser::Parser::parse_captures() {
8337{
8338JaktInternal::DynamicArray<Jakt::parser::ParsedCapture> captures = DynamicArray<Jakt::parser::ParsedCapture>::create_with({});
8339if (this->current().__jakt_init_index() == 11 /* LSquare */){
8340this->index++;
8341while (!this->eof()){
8342{auto&& __jakt_match_variant = this->current();
8343switch(__jakt_match_variant.__jakt_init_index()) {
8344case 12 /* RSquare */:{
8345this->index++;
8346break;
8347}
8348goto __jakt_label_51;case 37 /* Ampersand */:{
8349this->index++;
8350{auto&& __jakt_match_variant = this->current();
8351switch(__jakt_match_variant.__jakt_init_index()) {
8352case 87 /* Mut */:{
8353this->index++;
8354Jakt::lexer::Token __jakt_tmp32 = this->current();
8355if (__jakt_tmp32.__jakt_init_index() == 3 /* Identifier */){
8356ByteString const name = __jakt_tmp32.as.Identifier.name;
8357captures.push(Jakt::parser::ParsedCapture::ByMutableReference(name,this->current().span()));
8358this->index++;
8359}
8360else {
8361this->error(__jakt_format(StringView::from_string_literal("Expected identifier, got '{}'"sv),this->current()),this->current().span());
8362this->index++;
8363}
8364
8365}
8366goto __jakt_label_52;case 3 /* Identifier */: {
8367auto&& __jakt_match_value = __jakt_match_variant.as.Identifier;ByteString const& name = __jakt_match_value.name;
8368{
8369captures.push(Jakt::parser::ParsedCapture::ByReference(name,this->current().span()));
8370this->index++;
8371}
8372goto __jakt_label_52;};/*case end*/
8373default:{
8374this->error(__jakt_format(StringView::from_string_literal("Expected identifier or mut, got '{}'"sv),this->current()),this->current().span());
8375this->index++;
8376}
8377goto __jakt_label_52;}/*switch end*/
8378break;}goto __jakt_label_52; __jakt_label_52:;;
8379}
8380goto __jakt_label_51;case 77 /* Comptime */:{
8381this->index++;
8382Jakt::lexer::Token __jakt_tmp33 = this->current();
8383if (__jakt_tmp33.__jakt_init_index() == 3 /* Identifier */){
8384ByteString const name = __jakt_tmp33.as.Identifier.name;
8385captures.push(Jakt::parser::ParsedCapture::ByComptimeDependency(name,this->current().span()));
8386this->index++;
8387}
8388else {
8389this->error(__jakt_format(StringView::from_string_literal("Expected identifier, got '{}'"sv),this->current()),this->current().span());
8390this->index++;
8391}
8392
8393}

Callers 1

parse_lambdaMethod · 0.95

Calls 7

currentMethod · 0.95
eofMethod · 0.95
errorMethod · 0.95
__jakt_formatFunction · 0.50
__jakt_init_indexMethod · 0.45
pushMethod · 0.45
spanMethod · 0.45

Tested by

no test coverage detected