-module(chomp@lexer). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([simple/1, advanced/1, keep/1, drop/1, custom/1, map/2, then/2, into/2, ignore/1, token/2, symbol/3, keyword/3, string/2, identifier/4, try_identifier/4, variable/2, spaces_/1, spaces/1, whitespace/1, comment/2, run/2, run_advanced/3, float_with_separator/2, float/1, int_with_separator/2, int/1, number_with_separator/3, number/2]). -export_type([matcher/2, match/2, token/1, error/0, lexer/2, state/1]). -opaque matcher(FWC, FWD) :: {matcher, fun((FWD, binary(), binary()) -> match(FWC, FWD))}. -type match(FWE, FWF) :: {keep, FWE, FWF} | {skip, FWF} | {drop, FWF} | no_match. -type token(FWG) :: {token, chomp@span:span(), binary(), FWG}. -type error() :: {no_match_found, integer(), integer(), binary()}. -opaque lexer(FWH, FWI) :: {lexer, fun((FWI) -> list(matcher(FWH, FWI)))}. -type state(FWJ) :: {state, list(binary()), list(token(FWJ)), {integer(), integer(), binary()}, integer(), integer()}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 101). -spec simple(list(matcher(FWK, nil))) -> lexer(FWK, nil). simple(Matchers) -> {lexer, fun(_) -> Matchers end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 109). -spec advanced(fun((FWQ) -> list(matcher(FWR, FWQ)))) -> lexer(FWR, FWQ). advanced(Matchers) -> {lexer, fun(Mode) -> Matchers(Mode) end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 123). -spec keep(fun((binary(), binary()) -> {ok, FWX} | {error, nil})) -> matcher(FWX, any()). keep(F) -> {matcher, fun(Mode, Lexeme, Lookahead) -> _pipe = F(Lexeme, Lookahead), _pipe@1 = gleam@result:map( _pipe, fun(_capture) -> {keep, _capture, Mode} end ), gleam@result:unwrap(_pipe@1, no_match) end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 139). -spec drop(fun((binary(), binary()) -> boolean())) -> matcher(any(), any()). drop(F) -> {matcher, fun(Mode, Lexeme, Lookahead) -> case F(Lexeme, Lookahead) of true -> {drop, Mode}; false -> no_match end end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 154). -spec custom(fun((FXH, binary(), binary()) -> match(FXI, FXH))) -> matcher(FXI, FXH). custom(F) -> {matcher, F}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 161). -spec map(matcher(FXN, FXO), fun((FXN) -> FXR)) -> matcher(FXR, FXO). map(Matcher, F) -> {matcher, fun(Mode, Lexeme, Lookahead) -> case (erlang:element(2, Matcher))(Mode, Lexeme, Lookahead) of {keep, Value, Mode@1} -> {keep, F(Value), Mode@1}; {skip, Mode@2} -> {skip, Mode@2}; {drop, Mode@3} -> {drop, Mode@3}; no_match -> no_match end end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 177). -spec then(matcher(FXU, FXV), fun((FXU) -> match(FXY, FXV))) -> matcher(FXY, FXV). then(Matcher, F) -> {matcher, fun(Mode, Lexeme, Lookahead) -> case (erlang:element(2, Matcher))(Mode, Lexeme, Lookahead) of {keep, Value, _} -> F(Value); {skip, Mode@1} -> {skip, Mode@1}; {drop, Mode@2} -> {drop, Mode@2}; no_match -> no_match end end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 195). -spec into(matcher(FYD, FYE), fun((FYE) -> FYE)) -> matcher(FYD, FYE). into(Matcher, F) -> {matcher, fun(Mode, Lexeme, Lookahead) -> case (erlang:element(2, Matcher))(Mode, Lexeme, Lookahead) of {keep, Value, Mode@1} -> {keep, Value, F(Mode@1)}; {skip, Mode@2} -> {skip, Mode@2}; {drop, Mode@3} -> {drop, F(Mode@3)}; no_match -> no_match end end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 210). -spec ignore(matcher(any(), FYK)) -> matcher(any(), FYK). ignore(Matcher) -> {matcher, fun(Mode, Lexeme, Lookahead) -> case (erlang:element(2, Matcher))(Mode, Lexeme, Lookahead) of {keep, _, Mode@1} -> {drop, Mode@1}; {skip, Mode@2} -> {skip, Mode@2}; {drop, Mode@3} -> {drop, Mode@3}; no_match -> no_match end end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 225). -spec token(binary(), FYQ) -> matcher(FYQ, any()). token(Str, Value) -> {matcher, fun(Mode, Lexeme, _) -> case Lexeme =:= Str of true -> {keep, Value, Mode}; false -> no_match end end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 238). -spec symbol(binary(), binary(), FYU) -> matcher(FYU, any()). symbol(Str, Breaker, Value) -> _assert_subject = gleam@regex:from_string(Breaker), {ok, Break} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail, module => <<"chomp/lexer"/utf8>>, function => <<"symbol"/utf8>>, line => 239}) end, {matcher, fun(Mode, Lexeme, Lookahead) -> case (Lexeme =:= Str) andalso ((Lookahead =:= <<""/utf8>>) orelse gleam@regex:check( Break, Lookahead )) of true -> {keep, Value, Mode}; false -> no_match end end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 254). -spec keyword(binary(), binary(), FYY) -> matcher(FYY, any()). keyword(Str, Breaker, Value) -> _assert_subject = gleam@regex:from_string(Breaker), {ok, Break} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail, module => <<"chomp/lexer"/utf8>>, function => <<"keyword"/utf8>>, line => 255}) end, {matcher, fun(Mode, Lexeme, Lookahead) -> case (Lexeme =:= Str) andalso ((Lookahead =:= <<""/utf8>>) orelse gleam@regex:check( Break, Lookahead )) of true -> {keep, Value, Mode}; false -> no_match end end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 377). -spec string(binary(), fun((binary()) -> GAA)) -> matcher(GAA, any()). string(Char, To_value) -> _assert_subject = gleam@regex:from_string( <<<<<<<<<<<<"^"/utf8, Char/binary>>/binary, "([^"/utf8>>/binary, Char/binary>>/binary, "\\\\]|\\\\[\\s\\S])*"/utf8>>/binary, Char/binary>>/binary, "$"/utf8>> ), {ok, Is_string} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail, module => <<"chomp/lexer"/utf8>>, function => <<"string"/utf8>>, line => 378}) end, {matcher, fun(Mode, Lexeme, _) -> case gleam@regex:check(Is_string, Lexeme) of true -> _pipe = Lexeme, _pipe@1 = gleam@string:drop_left(_pipe, 1), _pipe@2 = gleam@string:drop_right(_pipe@1, 1), _pipe@3 = To_value(_pipe@2), {keep, _pipe@3, Mode}; false -> no_match end end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 397). -spec identifier( binary(), binary(), gleam@set:set(binary()), fun((binary()) -> GAF) ) -> matcher(GAF, any()). identifier(Start, Inner, Reserved, To_value) -> _assert_subject = gleam@regex:from_string( <<<<<<"^"/utf8, Start/binary>>/binary, Inner/binary>>/binary, "*$"/utf8>> ), {ok, Ident} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail, module => <<"chomp/lexer"/utf8>>, function => <<"identifier"/utf8>>, line => 403}) end, _assert_subject@1 = gleam@regex:from_string(Inner), {ok, Inner@1} = case _assert_subject@1 of {ok, _} -> _assert_subject@1; _assert_fail@1 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail@1, module => <<"chomp/lexer"/utf8>>, function => <<"identifier"/utf8>>, line => 404}) end, {matcher, fun(Mode, Lexeme, Lookahead) -> case {gleam@regex:check(Inner@1, Lookahead), gleam@regex:check(Ident, Lexeme)} of {true, true} -> {skip, Mode}; {false, true} -> case gleam@set:contains(Reserved, Lexeme) of true -> no_match; false -> {keep, To_value(Lexeme), Mode} end; {_, _} -> no_match end end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 421). -spec try_identifier( binary(), binary(), gleam@set:set(binary()), fun((binary()) -> GAK) ) -> {ok, matcher(GAK, any())} | {error, gleam@regex:compile_error()}. try_identifier(Start, Inner, Reserved, To_value) -> gleam@result:then( gleam@regex:from_string( <<<<<<"^"/utf8, Start/binary>>/binary, Inner/binary>>/binary, "*$"/utf8>> ), fun(Ident) -> gleam@result:map( gleam@regex:from_string(Inner), fun(Inner@1) -> {matcher, fun(Mode, Lexeme, Lookahead) -> case {gleam@regex:check(Inner@1, Lookahead), gleam@regex:check(Ident, Lexeme)} of {true, true} -> {skip, Mode}; {false, true} -> case gleam@set:contains(Reserved, Lexeme) of true -> no_match; false -> {keep, To_value(Lexeme), Mode} end; {_, _} -> no_match end end} end ) end ). -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 445). -spec variable(gleam@set:set(binary()), fun((binary()) -> GAR)) -> matcher(GAR, any()). variable(Reserved, To_value) -> identifier(<<"[a-z]"/utf8>>, <<"[a-zA-Z0-9_]"/utf8>>, Reserved, To_value). -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 460). -spec spaces_(fun((binary()) -> GAZ)) -> matcher(GAZ, any()). spaces_(To_value) -> _assert_subject = gleam@regex:from_string(<<"^[ \\t]+"/utf8>>), {ok, Spaces} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail, module => <<"chomp/lexer"/utf8>>, function => <<"spaces_"/utf8>>, line => 461}) end, {matcher, fun(Mode, Lexeme, _) -> case gleam@regex:check(Spaces, Lexeme) of true -> {keep, To_value(Lexeme), Mode}; false -> no_match end end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 454). -spec spaces(GAV) -> matcher(GAV, any()). spaces(Token) -> spaces_(fun(_) -> Token end). -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 473). -spec whitespace(GBD) -> matcher(GBD, any()). whitespace(Token) -> _assert_subject = gleam@regex:from_string(<<"^\\s+$"/utf8>>), {ok, Whitespace} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail, module => <<"chomp/lexer"/utf8>>, function => <<"whitespace"/utf8>>, line => 474}) end, {matcher, fun(Mode, Lexeme, _) -> case gleam@regex:check(Whitespace, Lexeme) of true -> {keep, Token, Mode}; false -> no_match end end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 485). -spec comment(binary(), fun((binary()) -> GBH)) -> matcher(GBH, any()). comment(Start, To_value) -> Drop_length = gleam@string:length(Start), {matcher, fun(Mode, Lexeme, Lookahead) -> case {gleam@string:starts_with(Lexeme, Start), Lookahead} of {true, <<"\n"/utf8>>} -> _pipe = Lexeme, _pipe@1 = gleam@string:drop_left(_pipe, Drop_length), _pipe@2 = To_value(_pipe@1), {keep, _pipe@2, Mode}; {true, <<""/utf8>>} -> _pipe = Lexeme, _pipe@1 = gleam@string:drop_left(_pipe, Drop_length), _pipe@2 = To_value(_pipe@1), {keep, _pipe@2, Mode}; {true, _} -> {skip, Mode}; {false, _} -> no_match end end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 632). -spec do_match(GCJ, binary(), binary(), list(matcher(GCK, GCJ))) -> match(GCK, GCJ). do_match(Mode, Str, Lookahead, Matchers) -> gleam@list:fold_until( Matchers, no_match, fun(_, Matcher) -> case (erlang:element(2, Matcher))(Mode, Str, Lookahead) of {keep, _, _} = Match -> {stop, Match}; {skip, _} = Match@1 -> {stop, Match@1}; {drop, _} = Match@2 -> {stop, Match@2}; no_match -> {continue, no_match} end end ). -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 650). -spec next_col(integer(), binary()) -> integer(). next_col(Col, Str) -> case Str of <<"\n"/utf8>> -> 1; _ -> Col + 1 end. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 657). -spec next_row(integer(), binary()) -> integer(). next_row(Row, Str) -> case Str of <<"\n"/utf8>> -> Row + 1; _ -> Row end. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 523). -spec do_run(lexer(GCA, GCB), GCB, state(GCA)) -> {ok, list(token(GCA))} | {error, error()}. do_run(Lexer, Mode, State) -> Matchers = (erlang:element(2, Lexer))(Mode), case {erlang:element(2, State), erlang:element(4, State)} of {[], {_, _, <<""/utf8>>}} -> {ok, lists:reverse(erlang:element(3, State))}; {[], {Start_row, Start_col, Lexeme}} -> case do_match(Mode, Lexeme, <<""/utf8>>, Matchers) of no_match -> {error, {no_match_found, Start_row, Start_col, Lexeme}}; {skip, _} -> {error, {no_match_found, Start_row, Start_col, Lexeme}}; {drop, _} -> {ok, lists:reverse(erlang:element(3, State))}; {keep, Value, _} -> Span = {span, Start_row, Start_col, erlang:element(5, State), erlang:element(6, State)}, Token = {token, Span, Lexeme, Value}, {ok, lists:reverse([Token | erlang:element(3, State)])} end; {[Lookahead | Rest], {Start_row@1, Start_col@1, Lexeme@1}} -> Row = next_row(erlang:element(5, State), Lookahead), Col = next_col(erlang:element(6, State), Lookahead), case do_match(Mode, Lexeme@1, Lookahead, Matchers) of {keep, Value@1, Mode@1} -> Span@1 = {span, Start_row@1, Start_col@1, erlang:element(5, State), erlang:element(6, State)}, Token@1 = {token, Span@1, Lexeme@1, Value@1}, do_run( Lexer, Mode@1, {state, Rest, [Token@1 | erlang:element(3, State)], {erlang:element(5, State), erlang:element(6, State), Lookahead}, Row, Col} ); {skip, Mode@2} -> do_run( Lexer, Mode@2, {state, Rest, erlang:element(3, State), {Start_row@1, Start_col@1, <>}, Row, Col} ); {drop, Mode@3} -> do_run( Lexer, Mode@3, {state, Rest, erlang:element(3, State), {erlang:element(5, State), erlang:element(6, State), Lookahead}, Row, Col} ); no_match -> do_run( Lexer, Mode, {state, Rest, erlang:element(3, State), {Start_row@1, Start_col@1, <>}, Row, Col} ) end end. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 504). -spec run(binary(), lexer(GBL, nil)) -> {ok, list(token(GBL))} | {error, error()}. run(Source, Lexer) -> _pipe = gleam@string:to_graphemes(Source), _pipe@1 = {state, _pipe, [], {1, 1, <<""/utf8>>}, 1, 1}, do_run(Lexer, nil, _pipe@1). -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 515). -spec run_advanced(binary(), GBS, lexer(GBT, GBS)) -> {ok, list(token(GBT))} | {error, error()}. run_advanced(Source, Mode, Lexer) -> do_run( Lexer, Mode, {state, gleam@string:to_graphemes(Source), [], {1, 1, <<""/utf8>>}, 1, 1} ). -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 302). -spec float_with_separator(binary(), fun((float()) -> FZO)) -> matcher(FZO, any()). float_with_separator(Separator, To_value) -> _assert_subject = gleam@regex:from_string( <<<<"[0-9"/utf8, Separator/binary>>/binary, "]"/utf8>> ), {ok, Digit} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail, module => <<"chomp/lexer"/utf8>>, function => <<"float_with_separator"/utf8>>, line => 306}) end, _assert_subject@1 = gleam@regex:from_string( <<<<"^[0-9"/utf8, Separator/binary>>/binary, "]+$"/utf8>> ), {ok, Integer} = case _assert_subject@1 of {ok, _} -> _assert_subject@1; _assert_fail@1 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail@1, module => <<"chomp/lexer"/utf8>>, function => <<"float_with_separator"/utf8>>, line => 307}) end, _assert_subject@2 = gleam@regex:from_string( <<<<<<<<"^[0-9"/utf8, Separator/binary>>/binary, "]+\\.[0-9"/utf8>>/binary, Separator/binary>>/binary, "]+$"/utf8>> ), {ok, Number} = case _assert_subject@2 of {ok, _} -> _assert_subject@2; _assert_fail@2 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail@2, module => <<"chomp/lexer"/utf8>>, function => <<"float_with_separator"/utf8>>, line => 308}) end, {matcher, fun(Mode, Lexeme, Lookahead) -> Is_int = not gleam@regex:check(Digit, Lookahead) andalso gleam@regex:check( Integer, Lexeme ), Is_float = not gleam@regex:check(Digit, Lookahead) andalso gleam@regex:check( Number, Lexeme ), case Lexeme of <<"."/utf8>> when Is_int -> no_match; _ when Is_float -> _assert_subject@3 = begin _pipe = Lexeme, _pipe@1 = gleam@string:replace( _pipe, Separator, <<""/utf8>> ), gleam@float:parse(_pipe@1) end, {ok, Num} = case _assert_subject@3 of {ok, _} -> _assert_subject@3; _assert_fail@3 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail@3, module => <<"chomp/lexer"/utf8>>, function => <<"float_with_separator"/utf8>>, line => 319}) end, {keep, To_value(Num), Mode}; _ -> no_match end end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 296). -spec float(fun((float()) -> FZK)) -> matcher(FZK, any()). float(To_value) -> float_with_separator(<<""/utf8>>, To_value). -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 273). -spec int_with_separator(binary(), fun((integer()) -> FZG)) -> matcher(FZG, any()). int_with_separator(Separator, To_value) -> _assert_subject = gleam@regex:from_string( <<<<"[0-9"/utf8, Separator/binary>>/binary, "]"/utf8>> ), {ok, Digit} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail, module => <<"chomp/lexer"/utf8>>, function => <<"int_with_separator"/utf8>>, line => 277}) end, _assert_subject@1 = gleam@regex:from_string( <<<<"^[0-9"/utf8, Separator/binary>>/binary, "]+$"/utf8>> ), {ok, Integer} = case _assert_subject@1 of {ok, _} -> _assert_subject@1; _assert_fail@1 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail@1, module => <<"chomp/lexer"/utf8>>, function => <<"int_with_separator"/utf8>>, line => 278}) end, {matcher, fun(Mode, Lexeme, Lookahead) -> case not gleam@regex:check(Digit, Lookahead) andalso gleam@regex:check( Integer, Lexeme ) of false -> no_match; true -> _assert_subject@2 = begin _pipe = Lexeme, _pipe@1 = gleam@string:replace( _pipe, Separator, <<""/utf8>> ), gleam@int:parse(_pipe@1) end, {ok, Num} = case _assert_subject@2 of {ok, _} -> _assert_subject@2; _assert_fail@2 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail@2, module => <<"chomp/lexer"/utf8>>, function => <<"int_with_separator"/utf8>>, line => 285}) end, {keep, To_value(Num), Mode} end end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 267). -spec int(fun((integer()) -> FZC)) -> matcher(FZC, any()). int(To_value) -> int_with_separator(<<""/utf8>>, To_value). -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 337). -spec number_with_separator( binary(), fun((integer()) -> FZW), fun((float()) -> FZW) ) -> matcher(FZW, any()). number_with_separator(Separator, From_int, From_float) -> _assert_subject = gleam@regex:from_string( <<<<"[0-9"/utf8, Separator/binary>>/binary, "]"/utf8>> ), {ok, Digit} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail, module => <<"chomp/lexer"/utf8>>, function => <<"number_with_separator"/utf8>>, line => 342}) end, _assert_subject@1 = gleam@regex:from_string( <<<<"^[0-9"/utf8, Separator/binary>>/binary, "]+$"/utf8>> ), {ok, Integer} = case _assert_subject@1 of {ok, _} -> _assert_subject@1; _assert_fail@1 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail@1, module => <<"chomp/lexer"/utf8>>, function => <<"number_with_separator"/utf8>>, line => 343}) end, _assert_subject@2 = gleam@regex:from_string( <<<<<<<<"^[0-9"/utf8, Separator/binary>>/binary, "]+\\.[0-9"/utf8>>/binary, Separator/binary>>/binary, "]+$"/utf8>> ), {ok, Number} = case _assert_subject@2 of {ok, _} -> _assert_subject@2; _assert_fail@2 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail@2, module => <<"chomp/lexer"/utf8>>, function => <<"number_with_separator"/utf8>>, line => 344}) end, {matcher, fun(Mode, Lexeme, Lookahead) -> Is_int = not gleam@regex:check(Digit, Lookahead) andalso gleam@regex:check( Integer, Lexeme ), Is_float = not gleam@regex:check(Digit, Lookahead) andalso gleam@regex:check( Number, Lexeme ), case {Lexeme, Lookahead} of {<<"."/utf8>>, _} when Is_int -> no_match; {_, <<"."/utf8>>} when Is_int -> no_match; {_, _} when Is_int -> _assert_subject@3 = begin _pipe = Lexeme, _pipe@1 = gleam@string:replace( _pipe, Separator, <<""/utf8>> ), gleam@int:parse(_pipe@1) end, {ok, Num} = case _assert_subject@3 of {ok, _} -> _assert_subject@3; _assert_fail@3 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail@3, module => <<"chomp/lexer"/utf8>>, function => <<"number_with_separator"/utf8>>, line => 356}) end, {keep, From_int(Num), Mode}; {_, _} when Is_float -> _assert_subject@4 = begin _pipe@2 = Lexeme, _pipe@3 = gleam@string:replace( _pipe@2, Separator, <<""/utf8>> ), gleam@float:parse(_pipe@3) end, {ok, Num@1} = case _assert_subject@4 of {ok, _} -> _assert_subject@4; _assert_fail@4 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, value => _assert_fail@4, module => <<"chomp/lexer"/utf8>>, function => <<"number_with_separator"/utf8>>, line => 364}) end, {keep, From_float(Num@1), Mode}; {_, _} -> no_match end end}. -file("/home/mystic/projects/gleam/chomp/src/chomp/lexer.gleam", 330). -spec number(fun((integer()) -> FZS), fun((float()) -> FZS)) -> matcher(FZS, any()). number(From_int, From_float) -> number_with_separator(<<""/utf8>>, From_int, From_float).