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

Method parse_export

bootstrap/stage0/parser.cpp:4462–5429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4460}
4461
4462void Jakt::parser::Parser::parse_export(Jakt::parser::ParsedNamespace& parent) {
4463{
4464Jakt::lexer::Token __jakt_tmp10 = this->current();
4465if (__jakt_tmp10.__jakt_init_index() == 1 /* QuotedString */){
4466ByteString const filename = __jakt_tmp10.as.QuotedString.quote;
4467Jakt::utility::Span const filename_span = __jakt_tmp10.as.QuotedString.span;
4468this->index++;
4469Jakt::parser::ParsedExport result = Jakt::parser::ParsedExport(Jakt::parser::ParsedName(filename,filename_span),DynamicArray<JaktInternal::DynamicArray<Jakt::parser::ParsedName>>::create_with({}));
4470if (this->current().__jakt_init_index() == 9 /* LCurly */){
4471this->index++;
4472bool has_doublecolon = false;
4473JaktInternal::DynamicArray<Jakt::parser::ParsedName> current_ns = DynamicArray<Jakt::parser::ParsedName>::create_with({});
4474for (;;){
4475{auto&& __jakt_match_variant = this->current();
4476switch(__jakt_match_variant.__jakt_init_index()) {
4477case 55 /* Eol */:{
4478this->index++;
4479continue;
4480}
4481goto __jakt_label_23;case 10 /* RCurly */:{
4482this->index++;
4483break;
4484}
4485goto __jakt_label_23;case 3 /* Identifier */: {
4486auto&& __jakt_match_value = __jakt_match_variant.as.Identifier;ByteString const& name = __jakt_match_value.name;
4487Jakt::utility::Span const& span = __jakt_match_value.span;
4488{
4489if ((!current_ns.is_empty()) && (!has_doublecolon)){
4490this->error(ByteString::from_utf8_without_validation("Expected ',' between exported names"sv),span);
4491result.names.push(current_ns);
4492current_ns = DynamicArray<Jakt::parser::ParsedName>::create_with({});
4493}
4494current_ns.push(Jakt::parser::ParsedName(name,span));
4495has_doublecolon = false;
4496this->index++;
4497continue;
4498}
4499goto __jakt_label_23;};/*case end*/
4500case 6 /* ColonColon */: {
4501auto&& __jakt_match_value = __jakt_match_variant.as.ColonColon;Jakt::utility::Span const& span = __jakt_match_value.value;
4502{
4503if (current_ns.is_empty()){
4504this->error(ByteString::from_utf8_without_validation("Expected name before '::'"sv),span);
4505}
4506has_doublecolon = true;
4507this->index++;
4508continue;
4509}
4510goto __jakt_label_23;};/*case end*/
4511case 52 /* Comma */: {
4512auto&& __jakt_match_value = __jakt_match_variant.as.Comma;Jakt::utility::Span const& span = __jakt_match_value.value;
4513{
4514if (current_ns.is_empty() || has_doublecolon){
4515this->error(ByteString::from_utf8_without_validation("Expected name before ','"sv),span);
4516}
4517else {
4518result.names.push(current_ns);
4519current_ns = DynamicArray<Jakt::parser::ParsedName>::create_with({});

Callers 1

parse_namespaceMethod · 0.95

Calls 9

currentMethod · 0.95
errorMethod · 0.95
escape_toplevelMethod · 0.95
ParsedExportClass · 0.85
ParsedNameClass · 0.85
__jakt_init_indexMethod · 0.45
is_emptyMethod · 0.45
pushMethod · 0.45
spanMethod · 0.45

Tested by

no test coverage detected