-module(parsers@toml@parser). -compile(no_auto_import). -export([parser/0, parse/1]). -export_type([explicitness/0, either/2]). -type explicitness() :: explicit | implicit. -type either(MXP, MXQ) :: {left, MXP} | {right, MXQ}. -spec is_whitespace() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), binary())} | {error, parser_gleam@parse_result:parse_error(binary())}). is_whitespace() -> parser_gleam@string:one_of([<<" "/utf8>>, <<"\t"/utf8>>]). -spec end_of_line() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), nil)} | {error, parser_gleam@parse_result:parse_error(binary())}). end_of_line() -> _pipe = parser_gleam@string:one_of([<<"\n"/utf8>>, <<"\r\n"/utf8>>]), parser_gleam@parser:map(_pipe, fun(_) -> nil end). -spec is_non_zero_digit(binary()) -> boolean(). is_non_zero_digit(C) -> _pipe = <<"123456789"/utf8>>, gleam@string:contains(_pipe, C). -spec comment() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), nil)} | {error, parser_gleam@parse_result:parse_error(binary())}). comment() -> _pipe = parser_gleam@char:char(<<"#"/utf8>>), parser_gleam@parser:chain( _pipe, fun(_) -> _pipe@2 = parser_gleam@parser:many_till( parser_gleam@parser:item(), parser_gleam@parser:alt( end_of_line(), fun() -> _pipe@1 = parser_gleam@parser:look_ahead( parser_gleam@parser:eof() ), parser_gleam@parser:map(_pipe@1, fun(_) -> nil end) end ) ), parser_gleam@parser:map(_pipe@2, fun(_) -> nil end) end ). -spec blank_not_eol() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), nil)} | {error, parser_gleam@parse_result:parse_error(binary())}). blank_not_eol() -> _pipe = parser_gleam@parser:many1(is_whitespace()), _pipe@1 = parser_gleam@parser:map(_pipe, fun(_) -> nil end), parser_gleam@parser:alt(_pipe@1, fun comment/0). -spec blank() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), nil)} | {error, parser_gleam@parse_result:parse_error(binary())}). blank() -> _pipe = blank_not_eol(), parser_gleam@parser:alt(_pipe, fun end_of_line/0). -spec skip_blanks() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), nil)} | {error, parser_gleam@parse_result:parse_error(binary())}). skip_blanks() -> _pipe = parser_gleam@parser:many(blank()), parser_gleam@parser:map(_pipe, fun(_) -> nil end). -spec key_char() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), binary())} | {error, parser_gleam@parse_result:parse_error(binary())}). key_char() -> _pipe = parser_gleam@char:alphanum(), _pipe@1 = parser_gleam@parser:alt( _pipe, fun() -> parser_gleam@char:char(<<"_"/utf8>>) end ), parser_gleam@parser:alt( _pipe@1, fun() -> parser_gleam@char:char(<<"-"/utf8>>) end ). -spec assignment_list_str(list(binary()), parsers@toml@model:node_()) -> {binary(), parsers@toml@model:node_()}. assignment_list_str(Ks, V) -> case Ks of [K] -> {K, V}; [K@1 | Ks@1] -> {K@1, {v_table, [assignment_list_str(Ks@1, V)]}} end. -spec whitespace_surounded() -> fun((fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), NCI)} | {error, parser_gleam@parse_result:parse_error(binary())})) -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), NCI)} | {error, parser_gleam@parse_result:parse_error(binary())})). whitespace_surounded() -> parser_gleam@parser:between( parser_gleam@parser:many(is_whitespace()), parser_gleam@parser:many(is_whitespace()) ). -spec assignment() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), {binary(), parsers@toml@model:node_()})} | {error, parser_gleam@parse_result:parse_error(binary())}). assignment() -> _pipe@5 = parser_gleam@parser:sep_by1( parser_gleam@char:char(<<"."/utf8>>), begin _pipe = parser_gleam@parser:many1(key_char()), _pipe@2 = parser_gleam@parser:map( _pipe, fun(It) -> _pipe@1 = It, join_nel(_pipe@1) end ), _pipe@3 = parser_gleam@parser:alt(_pipe@2, fun() -> basic_str() end), _pipe@4 = parser_gleam@parser:alt( _pipe@3, fun() -> literal_str() end ), (whitespace_surounded())(_pipe@4) end ), _pipe@6 = parser_gleam@parser:map( _pipe@5, fun fp_gl@non_empty_list:to_list/1 ), parser_gleam@parser:chain( _pipe@6, fun(Ks) -> _pipe@7 = parser_gleam@parser:many(is_whitespace()), _pipe@9 = parser_gleam@parser:chain( _pipe@7, fun(_) -> _pipe@8 = parser_gleam@char:char(<<"="/utf8>>), parser_gleam@parser:chain( _pipe@8, fun(_) -> skip_blanks() end ) end ), parser_gleam@parser:chain( _pipe@9, fun(_) -> _pipe@10 = value(), parser_gleam@parser:map( _pipe@10, fun(V) -> assignment_list_str(Ks, V) end ) end ) end ). -spec deep_merge_table(list({binary(), parsers@toml@model:node_()})) -> list({binary(), parsers@toml@model:node_()}). deep_merge_table(It) -> _pipe = It, _pipe@2 = gleam@list:fold( _pipe, [], fun(P, C) -> {K, V} = C, case gleam@list:key_find(P, K) of {ok, Old_v} -> {v_table, Old_rows@1} = case Old_v of {v_table, Old_rows} -> {v_table, Old_rows}; _try -> erlang:error(#{gleam_error => assert, message => <<"Assertion pattern match failed"/utf8>>, value => _try, module => <<"parsers/toml/parser"/utf8>>, function => <<"deep_merge_table"/utf8>>, line => 207}) end, {v_table, New_rows@1} = case V of {v_table, New_rows} -> {v_table, New_rows}; _try@1 -> erlang:error(#{gleam_error => assert, message => <<"Assertion pattern match failed"/utf8>>, value => _try@1, module => <<"parsers/toml/parser"/utf8>>, function => <<"deep_merge_table"/utf8>>, line => 208}) end, New_value = {v_table, deep_merge_table( gleam@list:append(Old_rows@1, New_rows@1) )}, _pipe@1 = P, gleam@list:key_set(_pipe@1, K, New_value); {error, _@1} -> [C | P] end end ), gleam@list:reverse(_pipe@2). -spec inline_table_end() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), binary())} | {error, parser_gleam@parse_result:parse_error(binary())}). inline_table_end() -> _pipe = skip_blanks(), _pipe@2 = parser_gleam@parser:chain( _pipe, fun(_) -> _pipe@1 = parser_gleam@char:char(<<"}"/utf8>>), parser_gleam@parser:chain(_pipe@1, fun(_) -> skip_blanks() end) end ), parser_gleam@parser:map(_pipe@2, fun(_) -> <<""/utf8>> end). -spec inline_table() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), parsers@toml@model:node_())} | {error, parser_gleam@parse_result:parse_error(binary())}). inline_table() -> Skip_spaces = parser_gleam@parser:many(is_whitespace()), Comma = begin _pipe = Skip_spaces, parser_gleam@parser:chain( _pipe, fun(_) -> _pipe@1 = parser_gleam@char:char(<<","/utf8>>), parser_gleam@parser:chain(_pipe@1, fun(_) -> Skip_spaces end) end ) end, Separated_values = parser_gleam@parser:sep_by( Comma, begin _pipe@2 = Skip_spaces, _pipe@3 = parser_gleam@parser:chain( _pipe@2, fun(_) -> assignment() end ), parser_gleam@parser:chain_first(_pipe@3, fun(_) -> Skip_spaces end) end ), _pipe@4 = Skip_spaces, _pipe@5 = parser_gleam@parser:chain(_pipe@4, fun(_) -> Separated_values end), _pipe@6 = parser_gleam@parser:chain_first( _pipe@5, fun(_) -> Skip_spaces end ), _pipe@7 = (parser_gleam@parser:between( parser_gleam@char:char(<<"{"/utf8>>), inline_table_end() ))(_pipe@6), _pipe@8 = parser_gleam@parser:map(_pipe@7, fun deep_merge_table/1), parser_gleam@parser:map(_pipe@8, fun(A) -> {v_table, A} end). -spec table() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), list({binary(), parsers@toml@model:node_()}))} | {error, parser_gleam@parse_result:parse_error(binary())}). table() -> _pipe@1 = parser_gleam@parser:many( begin _pipe = assignment(), parser_gleam@parser:chain_first(_pipe, fun(_) -> skip_blanks() end) end ), _pipe@3 = parser_gleam@parser:alt( _pipe@1, fun() -> _pipe@2 = skip_blanks(), parser_gleam@parser:map(_pipe@2, fun(_) -> [] end) end ), parser_gleam@parser:map(_pipe@3, fun deep_merge_table/1). -spec named_section() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), {list(binary()), parsers@toml@model:node_()})} | {error, parser_gleam@parse_result:parse_error(binary())}). named_section() -> Left = begin _pipe = table_header(), parser_gleam@parser:map(_pipe, fun(A) -> {left, A} end) end, Right = begin _pipe@1 = table_array_header(), parser_gleam@parser:map(_pipe@1, fun(A) -> {right, A} end) end, _pipe@2 = Left, _pipe@3 = parser_gleam@parser:alt(_pipe@2, fun() -> Right end), parser_gleam@parser:chain( _pipe@3, fun(Either_hdr) -> _pipe@4 = skip_blanks(), parser_gleam@parser:chain( _pipe@4, fun(_) -> _pipe@5 = table(), parser_gleam@parser:chain( _pipe@5, fun(Tbl) -> _pipe@6 = skip_blanks(), parser_gleam@parser:map( _pipe@6, fun(_) -> case Either_hdr of {left, Ns} -> {Ns, {v_table, Tbl}}; {right, Ns@1} -> {Ns@1, {vt_array, [Tbl]}} end end ) end ) end ) end ). -spec table_header() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), list(binary()))} | {error, parser_gleam@parse_result:parse_error(binary())}). table_header() -> _pipe = header_value(), (parser_gleam@parser:between( parser_gleam@char:char(<<"["/utf8>>), parser_gleam@char:char(<<"]"/utf8>>) ))(_pipe). -spec table_array_header() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), list(binary()))} | {error, parser_gleam@parse_result:parse_error(binary())}). table_array_header() -> _pipe = header_value(), (parser_gleam@parser:between( parser_gleam@string:string(<<"[["/utf8>>), parser_gleam@string:string(<<"]]"/utf8>>) ))(_pipe). -spec header_value() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), list(binary()))} | {error, parser_gleam@parse_result:parse_error(binary())}). header_value() -> _pipe@5 = parser_gleam@parser:sep_by1( parser_gleam@char:char(<<"."/utf8>>), begin _pipe = parser_gleam@parser:many1(key_char()), _pipe@3 = parser_gleam@parser:map( _pipe, fun(It) -> _pipe@1 = It, _pipe@2 = fp_gl@non_empty_list:to_list(_pipe@1), gleam@string:join(_pipe@2, <<""/utf8>>) end ), _pipe@4 = parser_gleam@parser:alt(_pipe@3, fun any_str_s/0), (parser_gleam@parser:between(skip_blanks(), skip_blanks()))(_pipe@4) end ), parser_gleam@parser:map(_pipe@5, fun fp_gl@non_empty_list:to_list/1). -spec value() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), parsers@toml@model:node_())} | {error, parser_gleam@parse_result:parse_error(binary())}). value() -> _pipe = array(), _pipe@1 = parser_gleam@parser:alt(_pipe, fun() -> boolean() end), _pipe@2 = parser_gleam@parser:alt(_pipe@1, fun() -> any_str() end), _pipe@3 = parser_gleam@parser:alt(_pipe@2, fun() -> datetime() end), _pipe@4 = parser_gleam@parser:alt(_pipe@3, fun() -> float() end), _pipe@5 = parser_gleam@parser:alt(_pipe@4, fun() -> integer() end), parser_gleam@parser:alt(_pipe@5, fun() -> inline_table() end). -spec array_end() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), binary())} | {error, parser_gleam@parse_result:parse_error(binary())}). array_end() -> _pipe = skip_blanks(), _pipe@2 = parser_gleam@parser:chain( _pipe, fun(_) -> _pipe@1 = parser_gleam@char:char(<<"]"/utf8>>), parser_gleam@parser:chain(_pipe@1, fun(_) -> skip_blanks() end) end ), parser_gleam@parser:map(_pipe@2, fun(_) -> <<""/utf8>> end). -spec array_of( fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), parsers@toml@model:node_())} | {error, parser_gleam@parse_result:parse_error(binary())}) ) -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), parsers@toml@model:node_())} | {error, parser_gleam@parse_result:parse_error(binary())}). array_of(Par) -> Comma = begin _pipe = skip_blanks(), _pipe@1 = parser_gleam@parser:chain( _pipe, fun(_) -> parser_gleam@char:char(<<","/utf8>>) end ), parser_gleam@parser:chain(_pipe@1, fun(_) -> skip_blanks() end) end, Separated_values = parser_gleam@parser:sep_by(Comma, Par), _pipe@2 = skip_blanks(), _pipe@3 = parser_gleam@parser:chain(_pipe@2, fun(_) -> Separated_values end), _pipe@4 = parser_gleam@parser:chain_first( _pipe@3, fun(_) -> parser_gleam@parser:optional(Comma) end ), _pipe@5 = parser_gleam@parser:chain_first( _pipe@4, fun(_) -> parser_gleam@parser:many(is_whitespace()) end ), _pipe@6 = (parser_gleam@parser:between( parser_gleam@char:char(<<"["/utf8>>), array_end() ))(_pipe@5), parser_gleam@parser:map(_pipe@6, fun(A) -> {v_array, A} end). -spec array() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), parsers@toml@model:node_())} | {error, parser_gleam@parse_result:parse_error(binary())}). array() -> _pipe = boolean(), _pipe@1 = parser_gleam@parser:alt(_pipe, fun() -> array() end), _pipe@2 = parser_gleam@parser:alt(_pipe@1, fun() -> any_str() end), _pipe@3 = parser_gleam@parser:alt(_pipe@2, fun() -> datetime() end), _pipe@4 = parser_gleam@parser:alt(_pipe@3, fun() -> float() end), _pipe@5 = parser_gleam@parser:alt(_pipe@4, fun() -> integer() end), _pipe@6 = parser_gleam@parser:alt(_pipe@5, fun() -> inline_table() end), array_of(_pipe@6). -spec boolean() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), parsers@toml@model:node_())} | {error, parser_gleam@parse_result:parse_error(binary())}). boolean() -> _pipe = parser_gleam@string:string(<<"true"/utf8>>), _pipe@1 = parser_gleam@parser:map(_pipe, fun(_) -> {v_boolean, true} end), parser_gleam@parser:alt( _pipe@1, fun() -> _pipe@2 = parser_gleam@string:string(<<"false"/utf8>>), parser_gleam@parser:map(_pipe@2, fun(_) -> {v_boolean, false} end) end ). -spec any_str() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), parsers@toml@model:node_())} | {error, parser_gleam@parse_result:parse_error(binary())}). any_str() -> _pipe = any_str_s(), parser_gleam@parser:map(_pipe, fun(A) -> {v_string, A} end). -spec any_str_s() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), binary())} | {error, parser_gleam@parse_result:parse_error(binary())}). any_str_s() -> _pipe = multi_basic_str(), _pipe@1 = parser_gleam@parser:alt(_pipe, fun basic_str/0), _pipe@2 = parser_gleam@parser:alt(_pipe@1, fun multi_literal_str/0), parser_gleam@parser:alt(_pipe@2, fun literal_str/0). -spec basic_str() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), binary())} | {error, parser_gleam@parse_result:parse_error(binary())}). basic_str() -> Str_char = begin _pipe = esc_seq(), parser_gleam@parser:alt( _pipe, fun() -> parser_gleam@parser:sat( fun(It) -> (It /= <<"\""/utf8>>) andalso (It /= <<"\\"/utf8>>) end ) end ) end, D_quote = parser_gleam@char:char(<<"\""/utf8>>), _pipe@1 = parser_gleam@parser:many(Str_char), _pipe@2 = (parser_gleam@parser:between(D_quote, D_quote))(_pipe@1), parser_gleam@parser:map( _pipe@2, fun(St) -> _pipe@3 = St, gleam@string:join(_pipe@3, <<""/utf8>>) end ). -spec multi_basic_str() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), binary())} | {error, parser_gleam@parse_result:parse_error(binary())}). multi_basic_str() -> Esc_white_space = parser_gleam@parser:many( begin _pipe = parser_gleam@char:char(<<"\\"/utf8>>), parser_gleam@parser:chain( _pipe, fun(_) -> _pipe@1 = parser_gleam@parser:many( parser_gleam@string:one_of( [<<" "/utf8>>, <<"\t"/utf8>>] ) ), parser_gleam@parser:chain( _pipe@1, fun(_) -> _pipe@2 = end_of_line(), parser_gleam@parser:chain( _pipe@2, fun(_) -> parser_gleam@parser:many( parser_gleam@string:one_of( [<<" "/utf8>>, <<"\t"/utf8>>, <<"\n"/utf8>>, <<"\r\n"/utf8>>] ) ) end ) end ) end ) end ), Str_char = begin _pipe@3 = esc_seq(), _pipe@4 = parser_gleam@parser:alt( _pipe@3, fun() -> parser_gleam@char:not_one_of(<<"\\"/utf8>>) end ), parser_gleam@parser:chain_first(_pipe@4, fun(_) -> Esc_white_space end) end, D_quote_3 = parser_gleam@string:string(<<"\"\"\""/utf8>>), Open_d_quote_3 = begin _pipe@5 = D_quote_3, _pipe@6 = parser_gleam@parser:chain_first( _pipe@5, fun(_) -> end_of_line() end ), parser_gleam@parser:alt(_pipe@6, fun() -> D_quote_3 end) end, _pipe@7 = Open_d_quote_3, parser_gleam@parser:chain( _pipe@7, fun(_) -> _pipe@8 = Esc_white_space, parser_gleam@parser:chain( _pipe@8, fun(_) -> _pipe@18 = parser_gleam@parser:many_till( Str_char, begin _pipe@9 = D_quote_3, _pipe@10 = parser_gleam@parser:chain_first( _pipe@9, fun(_) -> parser_gleam@parser:many(blank_not_eol()) end ), parser_gleam@parser:chain( _pipe@10, fun(_) -> _pipe@11 = end_of_line(), _pipe@12 = parser_gleam@parser:alt( _pipe@11, fun() -> parser_gleam@parser:eof() end ), _pipe@14 = parser_gleam@parser:alt( _pipe@12, fun() -> _pipe@13 = parser_gleam@parser:look_ahead( parser_gleam@char:char( <<"}"/utf8>> ) ), parser_gleam@parser:map( _pipe@13, fun(_) -> nil end ) end ), _pipe@16 = parser_gleam@parser:alt( _pipe@14, fun() -> _pipe@15 = parser_gleam@parser:look_ahead( parser_gleam@char:char( <<","/utf8>> ) ), parser_gleam@parser:map( _pipe@15, fun(_) -> nil end ) end ), parser_gleam@parser:alt( _pipe@16, fun() -> _pipe@17 = parser_gleam@parser:look_ahead( parser_gleam@char:char( <<"]"/utf8>> ) ), parser_gleam@parser:map( _pipe@17, fun(_) -> nil end ) end ) end ) end ), parser_gleam@parser:map( _pipe@18, fun(It) -> _pipe@19 = It, gleam@string:join(_pipe@19, <<""/utf8>>) end ) end ) end ). -spec literal_str() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), binary())} | {error, parser_gleam@parse_result:parse_error(binary())}). literal_str() -> S_quote = parser_gleam@char:char(<<"'"/utf8>>), _pipe = parser_gleam@parser:many( parser_gleam@parser:sat(fun(It) -> It /= <<"'"/utf8>> end) ), _pipe@1 = (parser_gleam@parser:between(S_quote, S_quote))(_pipe), parser_gleam@parser:map( _pipe@1, fun(St) -> _pipe@2 = St, gleam@string:join(_pipe@2, <<""/utf8>>) end ). -spec multi_literal_str() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), binary())} | {error, parser_gleam@parse_result:parse_error(binary())}). multi_literal_str() -> S_quote_3 = parser_gleam@string:string(<<"'''"/utf8>>), Open_s_quote_3 = begin _pipe = S_quote_3, _pipe@1 = parser_gleam@parser:chain_first( _pipe, fun(_) -> end_of_line() end ), parser_gleam@parser:alt(_pipe@1, fun() -> S_quote_3 end) end, _pipe@2 = Open_s_quote_3, parser_gleam@parser:chain( _pipe@2, fun(_) -> _pipe@12 = parser_gleam@parser:many_till( parser_gleam@parser:item(), begin _pipe@3 = S_quote_3, _pipe@4 = parser_gleam@parser:chain_first( _pipe@3, fun(_) -> parser_gleam@parser:many(blank_not_eol()) end ), parser_gleam@parser:chain( _pipe@4, fun(_) -> _pipe@5 = end_of_line(), _pipe@6 = parser_gleam@parser:alt( _pipe@5, fun() -> parser_gleam@parser:eof() end ), _pipe@8 = parser_gleam@parser:alt( _pipe@6, fun() -> _pipe@7 = parser_gleam@parser:look_ahead( parser_gleam@char:char(<<"}"/utf8>>) ), parser_gleam@parser:map( _pipe@7, fun(_) -> nil end ) end ), _pipe@10 = parser_gleam@parser:alt( _pipe@8, fun() -> _pipe@9 = parser_gleam@parser:look_ahead( parser_gleam@char:char(<<","/utf8>>) ), parser_gleam@parser:map( _pipe@9, fun(_) -> nil end ) end ), parser_gleam@parser:alt( _pipe@10, fun() -> _pipe@11 = parser_gleam@parser:look_ahead( parser_gleam@char:char(<<"]"/utf8>>) ), parser_gleam@parser:map( _pipe@11, fun(_) -> nil end ) end ) end ) end ), parser_gleam@parser:map( _pipe@12, fun(St) -> _pipe@13 = St, gleam@string:join(_pipe@13, <<""/utf8>>) end ) end ). -spec datetime() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), parsers@toml@model:node_())} | {error, parser_gleam@parse_result:parse_error(binary())}). datetime() -> _pipe = parsers@rfc_3339:parser(), parser_gleam@parser:map(_pipe, fun(A) -> {v_datetime, A} end). -spec signed() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), binary())} | {error, parser_gleam@parse_result:parse_error(binary())}). signed() -> _pipe = parser_gleam@string:string(<<"-"/utf8>>), _pipe@1 = parser_gleam@parser:alt( _pipe, fun() -> parser_gleam@char:char(<<"+"/utf8>>) end ), parser_gleam@parser:alt( _pipe@1, fun() -> parser_gleam@parser:'of'(<<""/utf8>>) end ). -spec integer_base_10_str() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), binary())} | {error, parser_gleam@parse_result:parse_error(binary())}). integer_base_10_str() -> _pipe = signed(), parser_gleam@parser:chain( _pipe, fun(Sign) -> _pipe@1 = parser_gleam@char:digit(), parser_gleam@parser:chain( _pipe@1, fun(D) -> _pipe@3 = parser_gleam@parser:many( begin _pipe@2 = parser_gleam@parser:optional( parser_gleam@char:char(<<"_"/utf8>>) ), parser_gleam@parser:chain( _pipe@2, fun(_) -> parser_gleam@char:digit() end ) end ), parser_gleam@parser:map( _pipe@3, fun(Ds) -> _pipe@4 = [Sign, D | Ds], gleam@string:join(_pipe@4, <<""/utf8>>) end ) end ) end ). -spec integer_base_10_str_no_leading_zero() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), binary())} | {error, parser_gleam@parse_result:parse_error(binary())}). integer_base_10_str_no_leading_zero() -> _pipe = signed(), parser_gleam@parser:chain( _pipe, fun(Sign) -> _pipe@1 = parser_gleam@parser:sat(fun is_non_zero_digit/1), _pipe@5 = parser_gleam@parser:chain( _pipe@1, fun(D) -> _pipe@3 = parser_gleam@parser:many( begin _pipe@2 = parser_gleam@parser:optional( parser_gleam@char:char(<<"_"/utf8>>) ), parser_gleam@parser:chain( _pipe@2, fun(_) -> parser_gleam@char:digit() end ) end ), parser_gleam@parser:map( _pipe@3, fun(Ds) -> _pipe@4 = [Sign, D | Ds], gleam@string:join(_pipe@4, <<""/utf8>>) end ) end ), parser_gleam@parser:alt( _pipe@5, fun() -> parser_gleam@char:char(<<"0"/utf8>>) end ) end ). -spec signed_positiveness() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), parsers@toml@model:positiveness())} | {error, parser_gleam@parse_result:parse_error(binary())}). signed_positiveness() -> _pipe = parser_gleam@string:string(<<"-"/utf8>>), _pipe@1 = parser_gleam@parser:map(_pipe, fun(_) -> v_negative end), _pipe@3 = parser_gleam@parser:alt( _pipe@1, fun() -> _pipe@2 = parser_gleam@char:char(<<"+"/utf8>>), parser_gleam@parser:map(_pipe@2, fun(_) -> v_positive end) end ), parser_gleam@parser:alt( _pipe@3, fun() -> _pipe@4 = parser_gleam@parser:'of'(<<""/utf8>>), parser_gleam@parser:map(_pipe@4, fun(_) -> v_none end) end ). -spec float() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), parsers@toml@model:node_())} | {error, parser_gleam@parse_result:parse_error(binary())}). float() -> _pipe = integer_base_10_str_no_leading_zero(), _pipe@1 = parser_gleam@parser:chain_first( _pipe, fun(_) -> parser_gleam@parser:look_ahead( parser_gleam@char:one_of(<<".eE"/utf8>>) ) end ), _pipe@10 = parser_gleam@parser:chain( _pipe@1, fun(N) -> _pipe@2 = parser_gleam@char:char(<<"."/utf8>>), _pipe@3 = parser_gleam@parser:chain( _pipe@2, fun(_) -> integer_base_10_str() end ), _pipe@4 = parser_gleam@parser:alt( _pipe@3, fun() -> parser_gleam@parser:'of'(<<"0"/utf8>>) end ), parser_gleam@parser:chain( _pipe@4, fun(D) -> _pipe@5 = parser_gleam@char:one_of(<<"eE"/utf8>>), _pipe@6 = parser_gleam@parser:chain( _pipe@5, fun(_) -> integer_base_10_str() end ), _pipe@7 = parser_gleam@parser:alt( _pipe@6, fun() -> parser_gleam@parser:'of'(<<"0"/utf8>>) end ), parser_gleam@parser:chain( _pipe@7, fun(E) -> case begin _pipe@8 = [N, <<"."/utf8>>, D, <<"e"/utf8>>, E], _pipe@9 = gleam@string:join( _pipe@8, <<""/utf8>> ), gleam@float:parse(_pipe@9) end of {ok, F} -> parser_gleam@parser:'of'( {v_float, {float_numeric, F}} ); {error, _@1} -> parser_gleam@parser:fail() end end ) end ) end ), _pipe@13 = parser_gleam@parser:alt( _pipe@10, fun() -> _pipe@11 = signed_positiveness(), parser_gleam@parser:chain( _pipe@11, fun(Sign) -> _pipe@12 = parser_gleam@string:string(<<"nan"/utf8>>), parser_gleam@parser:map( _pipe@12, fun(_) -> {v_float, {na_n, Sign}} end ) end ) end ), parser_gleam@parser:alt( _pipe@13, fun() -> _pipe@14 = signed_positiveness(), parser_gleam@parser:chain( _pipe@14, fun(Sign@1) -> _pipe@15 = parser_gleam@string:string(<<"inf"/utf8>>), parser_gleam@parser:map( _pipe@15, fun(_) -> {v_float, {inf, Sign@1}} end ) end ) end ). -spec integer_base_10() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), parsers@toml@model:node_())} | {error, parser_gleam@parse_result:parse_error(binary())}). integer_base_10() -> _pipe = integer_base_10_str_no_leading_zero(), parser_gleam@parser:chain( _pipe, fun(It) -> Int_parsed = begin _pipe@1 = It, gleam@int:parse(_pipe@1) end, case Int_parsed of {ok, It@1} -> parser_gleam@parser:'of'({v_integer, It@1}); {error, _@1} -> parser_gleam@parser:fail() end end ). -spec flatten_result_list(list({ok, MZG} | {error, any()})) -> list(MZG). flatten_result_list(It) -> _pipe = It, gleam@list:fold_right(_pipe, [], fun(P, C) -> case C of {error, _@1} -> P; {ok, C@1} -> [C@1 | P] end end). -spec integer_base_2() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), parsers@toml@model:node_())} | {error, parser_gleam@parse_result:parse_error(binary())}). integer_base_2() -> Bin_digit = parser_gleam@string:one_of([<<"0"/utf8>>, <<"1"/utf8>>]), _pipe = parser_gleam@string:string(<<"0b"/utf8>>), parser_gleam@parser:chain( _pipe, fun(_) -> _pipe@1 = Bin_digit, _pipe@4 = parser_gleam@parser:chain( _pipe@1, fun(D) -> _pipe@3 = parser_gleam@parser:many( begin _pipe@2 = parser_gleam@parser:optional( parser_gleam@char:char(<<"_"/utf8>>) ), parser_gleam@parser:chain( _pipe@2, fun(_) -> Bin_digit end ) end ), parser_gleam@parser:map(_pipe@3, fun(Ds) -> [D | Ds] end) end ), parser_gleam@parser:chain( _pipe@4, fun(It) -> Int_parsed = begin _pipe@5 = It, _pipe@6 = gleam@list:map(_pipe@5, fun gleam@int:parse/1), _pipe@7 = flatten_result_list(_pipe@6), gleam@int:undigits(_pipe@7, 2) end, case Int_parsed of {ok, It@1} -> parser_gleam@parser:'of'({v_integer, It@1}); {error, _@1} -> parser_gleam@parser:fail() end end ) end ). -spec integer_base_8() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), parsers@toml@model:node_())} | {error, parser_gleam@parse_result:parse_error(binary())}). integer_base_8() -> Oct_digit = parser_gleam@string:one_of( [<<"0"/utf8>>, <<"1"/utf8>>, <<"2"/utf8>>, <<"3"/utf8>>, <<"4"/utf8>>, <<"5"/utf8>>, <<"6"/utf8>>, <<"7"/utf8>>] ), _pipe = parser_gleam@string:string(<<"0o"/utf8>>), parser_gleam@parser:chain( _pipe, fun(_) -> _pipe@1 = Oct_digit, _pipe@4 = parser_gleam@parser:chain( _pipe@1, fun(D) -> _pipe@3 = parser_gleam@parser:many( begin _pipe@2 = parser_gleam@parser:optional( parser_gleam@char:char(<<"_"/utf8>>) ), parser_gleam@parser:chain( _pipe@2, fun(_) -> Oct_digit end ) end ), parser_gleam@parser:map(_pipe@3, fun(Ds) -> [D | Ds] end) end ), parser_gleam@parser:chain( _pipe@4, fun(It) -> Int_parsed = begin _pipe@5 = It, _pipe@6 = gleam@list:map(_pipe@5, fun gleam@int:parse/1), _pipe@7 = flatten_result_list(_pipe@6), gleam@int:undigits(_pipe@7, 8) end, case Int_parsed of {ok, It@1} -> parser_gleam@parser:'of'({v_integer, It@1}); {error, _@1} -> parser_gleam@parser:fail() end end ) end ). -spec parse_int_16(binary()) -> {ok, integer()} | {error, nil}. parse_int_16(It) -> case It of <<"0"/utf8>> -> {ok, 0}; <<"1"/utf8>> -> {ok, 1}; <<"2"/utf8>> -> {ok, 2}; <<"3"/utf8>> -> {ok, 3}; <<"4"/utf8>> -> {ok, 4}; <<"5"/utf8>> -> {ok, 5}; <<"6"/utf8>> -> {ok, 6}; <<"7"/utf8>> -> {ok, 7}; <<"8"/utf8>> -> {ok, 8}; <<"9"/utf8>> -> {ok, 9}; <<"A"/utf8>> -> {ok, 10}; <<"B"/utf8>> -> {ok, 11}; <<"C"/utf8>> -> {ok, 12}; <<"D"/utf8>> -> {ok, 13}; <<"E"/utf8>> -> {ok, 14}; <<"F"/utf8>> -> {ok, 15}; <<"a"/utf8>> -> {ok, 10}; <<"b"/utf8>> -> {ok, 11}; <<"c"/utf8>> -> {ok, 12}; <<"d"/utf8>> -> {ok, 13}; <<"e"/utf8>> -> {ok, 14}; <<"f"/utf8>> -> {ok, 15}; _@1 -> {error, nil} end. -spec integer_base_16() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), parsers@toml@model:node_())} | {error, parser_gleam@parse_result:parse_error(binary())}). integer_base_16() -> Oct_digit = parser_gleam@string:one_of( [<<"0"/utf8>>, <<"1"/utf8>>, <<"2"/utf8>>, <<"3"/utf8>>, <<"4"/utf8>>, <<"5"/utf8>>, <<"6"/utf8>>, <<"7"/utf8>>, <<"8"/utf8>>, <<"9"/utf8>>, <<"A"/utf8>>, <<"B"/utf8>>, <<"C"/utf8>>, <<"D"/utf8>>, <<"E"/utf8>>, <<"F"/utf8>>, <<"a"/utf8>>, <<"b"/utf8>>, <<"c"/utf8>>, <<"d"/utf8>>, <<"e"/utf8>>, <<"f"/utf8>>] ), _pipe = parser_gleam@string:string(<<"0x"/utf8>>), parser_gleam@parser:chain( _pipe, fun(_) -> _pipe@1 = Oct_digit, _pipe@4 = parser_gleam@parser:chain( _pipe@1, fun(D) -> _pipe@3 = parser_gleam@parser:many( begin _pipe@2 = parser_gleam@parser:optional( parser_gleam@char:char(<<"_"/utf8>>) ), parser_gleam@parser:chain( _pipe@2, fun(_) -> Oct_digit end ) end ), parser_gleam@parser:map(_pipe@3, fun(Ds) -> [D | Ds] end) end ), parser_gleam@parser:chain( _pipe@4, fun(It) -> Int_parsed = begin _pipe@5 = It, _pipe@6 = gleam@list:map(_pipe@5, fun parse_int_16/1), _pipe@7 = flatten_result_list(_pipe@6), gleam@int:undigits(_pipe@7, 16) end, case Int_parsed of {ok, It@1} -> parser_gleam@parser:'of'({v_integer, It@1}); {error, _@1} -> parser_gleam@parser:fail() end end ) end ). -spec integer() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), parsers@toml@model:node_())} | {error, parser_gleam@parse_result:parse_error(binary())}). integer() -> _pipe = integer_base_2(), _pipe@1 = parser_gleam@parser:alt(_pipe, fun() -> integer_base_8() end), _pipe@2 = parser_gleam@parser:alt(_pipe@1, fun() -> integer_base_16() end), parser_gleam@parser:alt(_pipe@2, fun() -> integer_base_10() end). -spec is_hex(binary()) -> boolean(). is_hex(C) -> _pipe = parse_int_16(C), gleam@result:is_ok(_pipe). -spec to_unicode_char(list(integer())) -> binary(). to_unicode_char(Lst) -> {ok, Value@1} = case begin _pipe = Lst, gleam@int:undigits(_pipe, 16) end of {ok, Value} -> {ok, Value}; _try -> erlang:error(#{gleam_error => assert, message => <<"Assertion pattern match failed"/utf8>>, value => _try, module => <<"parsers/toml/parser"/utf8>>, function => <<"to_unicode_char"/utf8>>, line => 781}) end, true = case Value@1 =< 1114111 of true -> true; _try@1 -> erlang:error(#{gleam_error => assert, message => <<"Assertion pattern match failed"/utf8>>, value => _try@1, module => <<"parsers/toml/parser"/utf8>>, function => <<"to_unicode_char"/utf8>>, line => 785}) end, parser_gleam_ffi:to_unicode_str(Value@1). -spec unixcode_hex_8() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), binary())} | {error, parser_gleam@parse_result:parse_error(binary())}). unixcode_hex_8() -> _pipe = parser_gleam@parser:sat(fun is_hex/1), parser_gleam@parser:chain( _pipe, fun(D1) -> _pipe@1 = parser_gleam@parser:sat(fun is_hex/1), parser_gleam@parser:chain( _pipe@1, fun(D2) -> _pipe@2 = parser_gleam@parser:sat(fun is_hex/1), parser_gleam@parser:chain( _pipe@2, fun(D3) -> _pipe@3 = parser_gleam@parser:sat(fun is_hex/1), parser_gleam@parser:chain( _pipe@3, fun(D4) -> _pipe@4 = parser_gleam@parser:sat( fun is_hex/1 ), parser_gleam@parser:chain( _pipe@4, fun(D5) -> _pipe@5 = parser_gleam@parser:sat( fun is_hex/1 ), parser_gleam@parser:chain( _pipe@5, fun(D6) -> _pipe@6 = parser_gleam@parser:sat( fun is_hex/1 ), parser_gleam@parser:chain( _pipe@6, fun(D7) -> _pipe@7 = parser_gleam@parser:sat( fun is_hex/1 ), parser_gleam@parser:chain( _pipe@7, fun(D8) -> Value = begin _pipe@8 = [D1, D2, D3, D4, D5, D6, D7, D8], _pipe@9 = gleam@list:map( _pipe@8, fun parse_int_16/1 ), flatten_result_list( _pipe@9 ) end, parser_gleam@parser:'of'( to_unicode_char( Value ) ) end ) end ) end ) end ) end ) end ) end ) end ). -spec unixcode_hex_4() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), binary())} | {error, parser_gleam@parse_result:parse_error(binary())}). unixcode_hex_4() -> _pipe = parser_gleam@parser:sat(fun is_hex/1), parser_gleam@parser:chain( _pipe, fun(D1) -> _pipe@1 = parser_gleam@parser:sat(fun is_hex/1), parser_gleam@parser:chain( _pipe@1, fun(D2) -> _pipe@2 = parser_gleam@parser:sat(fun is_hex/1), parser_gleam@parser:chain( _pipe@2, fun(D3) -> _pipe@3 = parser_gleam@parser:sat(fun is_hex/1), parser_gleam@parser:chain( _pipe@3, fun(D4) -> Value = begin _pipe@4 = [D1, D2, D3, D4], _pipe@5 = gleam@list:map( _pipe@4, fun parse_int_16/1 ), flatten_result_list(_pipe@5) end, parser_gleam@parser:'of'( to_unicode_char(Value) ) end ) end ) end ) end ). -spec esc_seq() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), binary())} | {error, parser_gleam@parse_result:parse_error(binary())}). esc_seq() -> _pipe = parser_gleam@char:char(<<"\\"/utf8>>), parser_gleam@parser:chain( _pipe, fun(_) -> _pipe@1 = parser_gleam@char:char(<<"\""/utf8>>), _pipe@2 = parser_gleam@parser:alt( _pipe@1, fun() -> parser_gleam@char:char(<<"\\"/utf8>>) end ), _pipe@3 = parser_gleam@parser:alt( _pipe@2, fun() -> parser_gleam@char:char(<<"/"/utf8>>) end ), _pipe@5 = parser_gleam@parser:alt( _pipe@3, fun() -> _pipe@4 = parser_gleam@char:char(<<"b"/utf8>>), parser_gleam@parser:map( _pipe@4, fun(_) -> to_unicode_char([0, 0, 0, 8]) end ) end ), _pipe@7 = parser_gleam@parser:alt( _pipe@5, fun() -> _pipe@6 = parser_gleam@char:char(<<"t"/utf8>>), parser_gleam@parser:map( _pipe@6, fun(_) -> <<"\t"/utf8>> end ) end ), _pipe@9 = parser_gleam@parser:alt( _pipe@7, fun() -> _pipe@8 = parser_gleam@char:char(<<"n"/utf8>>), parser_gleam@parser:map( _pipe@8, fun(_) -> <<"\n"/utf8>> end ) end ), _pipe@11 = parser_gleam@parser:alt( _pipe@9, fun() -> _pipe@10 = parser_gleam@char:char(<<"f"/utf8>>), parser_gleam@parser:map( _pipe@10, fun(_) -> <<"\f"/utf8>> end ) end ), _pipe@13 = parser_gleam@parser:alt( _pipe@11, fun() -> _pipe@12 = parser_gleam@char:char(<<"r"/utf8>>), parser_gleam@parser:map( _pipe@12, fun(_) -> <<"\r"/utf8>> end ) end ), _pipe@15 = parser_gleam@parser:alt( _pipe@13, fun() -> _pipe@14 = parser_gleam@char:char(<<"u"/utf8>>), parser_gleam@parser:chain( _pipe@14, fun(_) -> unixcode_hex_4() end ) end ), parser_gleam@parser:alt( _pipe@15, fun() -> _pipe@16 = parser_gleam@char:char(<<"U"/utf8>>), parser_gleam@parser:chain( _pipe@16, fun(_) -> unixcode_hex_8() end ) end ) end ). -spec table_to_set(list({binary(), parsers@toml@model:node_()})) -> gleam@set:set(binary()). table_to_set(It) -> _pipe = It, _pipe@1 = gleam@list:map( _pipe, fun(I) -> {K, _@1} = I, K end ), gleam@set:from_list(_pipe@1). -spec merge( list({binary(), parsers@toml@model:node_()}), list({binary(), parsers@toml@model:node_()}) ) -> either(list(binary()), list({binary(), parsers@toml@model:node_()})). merge(Existing, New) -> case begin _pipe = table_to_set(Existing), _pipe@1 = gleam@set:intersection(_pipe, table_to_set(New)), gleam@set:to_list(_pipe@1) end of [] -> {right, gleam@list:append(Existing, New)}; Ds -> {left, Ds} end. -spec list_init(list(list({binary(), parsers@toml@model:node_()}))) -> list(list({binary(), parsers@toml@model:node_()})). list_init(It) -> {ok, Init@1} = case begin _pipe = It, _pipe@1 = gleam@list:reverse(_pipe), gleam@list:rest(_pipe@1) end of {ok, Init} -> {ok, Init}; _try -> erlang:error(#{gleam_error => assert, message => <<"Assertion pattern match failed"/utf8>>, value => _try, module => <<"parsers/toml/parser"/utf8>>, function => <<"list_init"/utf8>>, line => 906}) end, _pipe@2 = Init@1, gleam@list:reverse(_pipe@2). -spec insert_named_section( list({binary(), parsers@toml@model:node_()}), {list(binary()), parsers@toml@model:node_()} ) -> list({binary(), parsers@toml@model:node_()}). insert_named_section(Top_table, Named_sections) -> case Named_sections of {[], _@1} -> erlang:error(#{gleam_error => todo, message => <<"This has not yet been implemented"/utf8>>, module => <<"parsers/toml/parser"/utf8>>, function => <<"insert_named_section"/utf8>>, line => 917}); {[Name], Node} -> case begin _pipe = Top_table, gleam@list:key_find(_pipe, Name) end of {error, _@2} -> _pipe@1 = Top_table, gleam@list:key_set(_pipe@1, Name, Node); {ok, {v_table, T}} -> case Node of {v_table, Nt} -> case merge(T, Nt) of {left, Ds} -> erlang:error(#{gleam_error => todo, message => <<"This has not yet been implemented"/utf8>>, module => <<"parsers/toml/parser"/utf8>>, function => <<"insert_named_section"/utf8>>, line => 931}); {right, R} -> _pipe@2 = Top_table, gleam@list:key_set( _pipe@2, Name, {v_table, R} ) end; _@3 -> erlang:error(#{gleam_error => todo, message => <<"This has not yet been implemented"/utf8>>, module => <<"parsers/toml/parser"/utf8>>, function => <<"insert_named_section"/utf8>>, line => 936}) end; {ok, {vt_array, A}} -> case Node of {vt_array, Na} -> _pipe@3 = Top_table, gleam@list:key_set( _pipe@3, Name, {vt_array, gleam@list:append(A, Na)} ); _@4 -> erlang:error(#{gleam_error => todo, message => <<"This has not yet been implemented"/utf8>>, module => <<"parsers/toml/parser"/utf8>>, function => <<"insert_named_section"/utf8>>, line => 943}) end; {ok, _@5} -> erlang:error(#{gleam_error => todo, message => <<"This has not yet been implemented"/utf8>>, module => <<"parsers/toml/parser"/utf8>>, function => <<"insert_named_section"/utf8>>, line => 945}) end; {[Name@1 | Ns], Node@1} -> case begin _pipe@4 = Top_table, gleam@list:key_find(_pipe@4, Name@1) end of {error, _@6} -> Tbl = insert_named_section([], {Ns, Node@1}), _pipe@5 = Top_table, gleam@list:key_set(_pipe@5, Name@1, {v_table, Tbl}); {ok, {v_table, T@1}} -> Tbl@1 = insert_named_section(T@1, {Ns, Node@1}), _pipe@6 = Top_table, gleam@list:key_set(_pipe@6, Name@1, {v_table, Tbl@1}); {ok, {vt_array, A@1}} -> {ok, Last@1} = case gleam@list:last(A@1) of {ok, Last} -> {ok, Last}; _try -> erlang:error(#{gleam_error => assert, message => <<"Assertion pattern match failed"/utf8>>, value => _try, module => <<"parsers/toml/parser"/utf8>>, function => <<"insert_named_section"/utf8>>, line => 965}) end, Tbl@2 = insert_named_section(Last@1, {Ns, Node@1}), _pipe@7 = Top_table, gleam@list:key_set( _pipe@7, Name@1, {vt_array, gleam@list:append(list_init(A@1), [Tbl@2])} ); {ok, _@7} -> erlang:error(#{gleam_error => todo, message => <<"This has not yet been implemented"/utf8>>, module => <<"parsers/toml/parser"/utf8>>, function => <<"insert_named_section"/utf8>>, line => 970}) end end. -spec load_into_top_table( list({binary(), parsers@toml@model:node_()}), list({list(binary()), parsers@toml@model:node_()}) ) -> list({binary(), parsers@toml@model:node_()}). load_into_top_table(Top_table, Named_sections) -> _pipe = Named_sections, gleam@list:fold( _pipe, Top_table, fun(P, C) -> insert_named_section(P, C) end ). -spec parser() -> fun((parser_gleam@stream:stream(binary())) -> {ok, parser_gleam@parse_result:parse_success(binary(), list({binary(), parsers@toml@model:node_()}))} | {error, parser_gleam@parse_result:parse_error(binary())}). parser() -> _pipe = skip_blanks(), parser_gleam@parser:chain( _pipe, fun(_) -> _pipe@1 = table(), parser_gleam@parser:chain( _pipe@1, fun(Top_table) -> _pipe@2 = parser_gleam@parser:many(named_section()), parser_gleam@parser:chain( _pipe@2, fun(Named_sections) -> _pipe@3 = parser_gleam@parser:eof(), parser_gleam@parser:map( _pipe@3, fun(_) -> load_into_top_table( Top_table, Named_sections ) end ) end ) end ) end ). -spec parse(binary()) -> {ok, list({binary(), parsers@toml@model:node_()})} | {error, binary()}. parse(It) -> case begin _pipe = parser(), _pipe@1 = parser_gleam@parser:chain_first( _pipe, fun(_) -> parser_gleam@parser:eof() end ), (parser_gleam@string:run(It))(_pipe@1) end of {ok, S} -> {ok, erlang:element(2, S)}; {error, E} -> {error, gleam@string:concat( [<<"Failed to parse. Expected: "/utf8>>, begin _pipe@2 = erlang:element(3, E), gleam@string:join(_pipe@2, <<", "/utf8>>) end] )} end. -spec join_nel(fp_gl@non_empty_list:non_empty_list(binary())) -> binary(). join_nel(Nel) -> _pipe = Nel, _pipe@1 = fp_gl@non_empty_list:to_list(_pipe), gleam@string:join(_pipe@1, <<""/utf8>>).