-module(pearl). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/pearl.gleam"). -export([stringify_error/1, sigil_delimiters/1, token_to_source/1, to_source/1, new/1, ignore_comments/1, ignore_whitespace/1, tokenise/1, highlight_tokens/1, highlight_ansi/1, highlight_html/1]). -export_type([lexer/0, splitters/0, error/0, token/0, sigil_delimiter/0, lex_number_mode/0, delimited_position/0, highlight_token/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. -opaque lexer() :: {lexer, binary(), boolean(), boolean(), list(error()), splitters()}. -type splitters() :: {splitters, splitter:splitter(), splitter:splitter(), splitter:splitter(), splitter:splitter(), splitter:splitter(), splitter:splitter(), splitter:splitter()}. -type error() :: {unknown_character, binary()} | unterminated_string_literal | unterminated_quoted_atom | {invalid_radix, binary()} | numeric_separator_not_allowed | expected_exponent | number_cannot_end_after_radix | unterminated_character | unterminated_escape_sequence | expected_sigil_delimiter | expected_whitespace_after_triple_quote | {invalid_triple_quoted_string_indentation, binary(), binary()}. -type token() :: {whitespace, binary()} | {comment, binary()} | {doc_comment, binary()} | {module_comment, binary()} | end_of_file | {character, binary()} | {integer, binary()} | {float, binary()} | {atom, binary(), boolean()} | {string, binary()} | {triple_quoted_string, gleam@option:option(binary()), integer(), binary(), list(binary()), binary()} | {sigil, binary(), sigil_delimiter(), binary()} | {variable, binary()} | 'after' | 'begin' | 'case' | 'catch' | 'cond' | 'else' | 'end' | 'fun' | 'if' | 'let' | 'maybe' | 'of' | 'receive' | 'try' | 'when' | left_paren | right_paren | left_brace | right_brace | left_square | right_square | comma | semicolon | colon | dot | minus_greater | double_less | double_greater | hash | double_colon | double_dot | triple_dot | double_pipe | equal_greater | colon_equal | less_minus | less_equal | pipe | double_equal | slash_equal | equal_less | less | greater_equal | greater | equal_colon_equal | equal_slash_equal | plus | minus | star | slash | 'bnot' | 'div' | 'rem' | 'band' | 'bor' | 'bxor' | 'bsl' | 'bsr' | 'not' | 'and' | 'or' | 'xor' | 'andalso' | 'orelse' | double_plus | double_minus | question_equal | question | bang | equal | {unknown, binary()} | {unterminated_string, binary()} | {unterminated_sigil, binary(), sigil_delimiter(), binary()} | {unterminated_atom, binary()} | {invalid_triple_quoted_string, binary()}. -type sigil_delimiter() :: sigil_none | sigil_paren | sigil_square | sigil_brace | sigil_angle | sigil_slash | sigil_pipe | sigil_single_quote | sigil_double_quote | sigil_backtick | sigil_hash. -type lex_number_mode() :: initial | {radix, integer()} | decimal | exponent. -type delimited_position() :: after_decimal | after_number | after_separator | after_exponent | after_radix. -type highlight_token() :: {highlight_whitespace, binary()} | {highlight_keyword, binary()} | {highlight_variable, binary()} | {highlight_string, binary()} | {highlight_atom, binary()} | {highlight_number, binary()} | {highlight_module, binary()} | {highlight_function, binary()} | {highlight_operator, binary()} | {highlight_comment, binary()} | {highlight_punctuation, binary()} | {highlight_other, binary()}. -file("src/pearl.gleam", 49). -spec stringify_error(error()) -> binary(). stringify_error(Error) -> case Error of unterminated_quoted_atom -> <<"Unterminated quoted atom"/utf8>>; unterminated_string_literal -> <<"Unterminated string literal"/utf8>>; expected_exponent -> <<"Expected an exponent"/utf8>>; expected_sigil_delimiter -> <<"Expected a valid sigil delimiter after `~`"/utf8>>; expected_whitespace_after_triple_quote -> <<"Expected whitespace after a triple quote"/utf8>>; {invalid_radix, Radix} -> <<"Invalid numeric radix: "/utf8, Radix/binary>>; {invalid_triple_quoted_string_indentation, Expected_indentation, Line} -> <<<<<<<<"Invalid triple-quoted string: Expected the indentation `"/utf8, Expected_indentation/binary>>/binary, "` preceding the line `"/utf8>>/binary, Line/binary>>/binary, "`"/utf8>>; number_cannot_end_after_radix -> <<"Number cannot end directly after radix specification"/utf8>>; numeric_separator_not_allowed -> <<"Numeric separator is not allowed here"/utf8>>; {unknown_character, Character} -> <<<<"Unexpected character: `"/utf8, Character/binary>>/binary, "`"/utf8>>; unterminated_character -> <<"Unterminated character literal"/utf8>>; unterminated_escape_sequence -> <<"Unterminated escape sequence"/utf8>> end. -file("src/pearl.gleam", 335). ?DOC(" Get the beginning and ending characters for a sigil\n"). -spec sigil_delimiters(sigil_delimiter()) -> {binary(), binary()}. sigil_delimiters(Delimiter) -> case Delimiter of sigil_none -> {<<""/utf8>>, <<""/utf8>>}; sigil_angle -> {<<"<"/utf8>>, <<">"/utf8>>}; sigil_backtick -> {<<"`"/utf8>>, <<"`"/utf8>>}; sigil_brace -> {<<"{"/utf8>>, <<"}"/utf8>>}; sigil_double_quote -> {<<"\""/utf8>>, <<"\""/utf8>>}; sigil_hash -> {<<"#"/utf8>>, <<"#"/utf8>>}; sigil_paren -> {<<"("/utf8>>, <<")"/utf8>>}; sigil_pipe -> {<<"|"/utf8>>, <<"|"/utf8>>}; sigil_single_quote -> {<<"'"/utf8>>, <<"'"/utf8>>}; sigil_slash -> {<<"/"/utf8>>, <<"/"/utf8>>}; sigil_square -> {<<"["/utf8>>, <<"]"/utf8>>} end. -file("src/pearl.gleam", 184). ?DOC(" Convert a token back to its source code representation\n"). -spec token_to_source(token()) -> binary(). token_to_source(Token) -> case Token of {whitespace, Space} -> Space; {comment, Contents} -> <<"%"/utf8, Contents/binary>>; {doc_comment, Contents@1} -> <<"%%"/utf8, Contents@1/binary>>; {module_comment, Contents@2} -> <<"%%%"/utf8, Contents@2/binary>>; end_of_file -> <<""/utf8>>; {character, Char} -> <<"$"/utf8, Char/binary>>; {integer, Int} -> Int; {float, Float} -> Float; {atom, Name, true} -> <<<<"'"/utf8, Name/binary>>/binary, "'"/utf8>>; {atom, Name@1, false} -> Name@1; {string, Contents@3} -> <<<<"\""/utf8, Contents@3/binary>>/binary, "\""/utf8>>; {triple_quoted_string, Sigil, Number_of_quotes, Beginning_whitespace, Lines, End_indentation} -> <<<<<<<<<<<<(case Sigil of none -> <<""/utf8>>; {some, Sigil@1} -> <<"~"/utf8, Sigil@1/binary>> end)/binary, (gleam@string:repeat( <<"\""/utf8>>, Number_of_quotes ))/binary>>/binary, Beginning_whitespace/binary>>/binary, (gleam@string:join( gleam@list:map( Lines, fun(Line) -> <> end ), <<"\n"/utf8>> ))/binary>>/binary, "\n"/utf8>>/binary, End_indentation/binary>>/binary, (gleam@string:repeat( <<"\""/utf8>>, Number_of_quotes ))/binary>>; {sigil, Sigil@2, Delimiter, Contents@4} -> {Opening, Closing} = sigil_delimiters(Delimiter), <<<<<<<<"~"/utf8, Sigil@2/binary>>/binary, Opening/binary>>/binary, Contents@4/binary>>/binary, Closing/binary>>; {variable, Name@2} -> Name@2; 'after' -> <<"after"/utf8>>; 'begin' -> <<"begin"/utf8>>; 'case' -> <<"case"/utf8>>; 'catch' -> <<"catch"/utf8>>; 'cond' -> <<"cond"/utf8>>; 'else' -> <<"else"/utf8>>; 'end' -> <<"end"/utf8>>; 'fun' -> <<"fun"/utf8>>; 'if' -> <<"if"/utf8>>; 'let' -> <<"let"/utf8>>; 'maybe' -> <<"maybe"/utf8>>; 'of' -> <<"of"/utf8>>; 'receive' -> <<"receive"/utf8>>; 'try' -> <<"try"/utf8>>; 'when' -> <<"when"/utf8>>; left_paren -> <<"("/utf8>>; right_paren -> <<")"/utf8>>; left_brace -> <<"{"/utf8>>; right_brace -> <<"}"/utf8>>; left_square -> <<"["/utf8>>; right_square -> <<"]"/utf8>>; comma -> <<","/utf8>>; semicolon -> <<";"/utf8>>; colon -> <<":"/utf8>>; dot -> <<"."/utf8>>; minus_greater -> <<"->"/utf8>>; double_less -> <<"<<"/utf8>>; double_greater -> <<">>"/utf8>>; hash -> <<"#"/utf8>>; double_colon -> <<"::"/utf8>>; double_dot -> <<".."/utf8>>; triple_dot -> <<"..."/utf8>>; double_pipe -> <<"||"/utf8>>; equal_greater -> <<"=>"/utf8>>; colon_equal -> <<":="/utf8>>; less_minus -> <<"<-"/utf8>>; less_equal -> <<"<="/utf8>>; pipe -> <<"|"/utf8>>; double_equal -> <<"=="/utf8>>; slash_equal -> <<"/="/utf8>>; equal_less -> <<"=<"/utf8>>; less -> <<"<"/utf8>>; greater_equal -> <<">="/utf8>>; greater -> <<">"/utf8>>; equal_colon_equal -> <<"=:="/utf8>>; equal_slash_equal -> <<"=/="/utf8>>; plus -> <<"+"/utf8>>; minus -> <<"-"/utf8>>; star -> <<"*"/utf8>>; slash -> <<"/"/utf8>>; 'bnot' -> <<"bnot"/utf8>>; 'div' -> <<"div"/utf8>>; 'rem' -> <<"rem"/utf8>>; 'band' -> <<"band"/utf8>>; 'bor' -> <<"bor"/utf8>>; 'bxor' -> <<"bxor"/utf8>>; 'bsl' -> <<"bsl"/utf8>>; 'bsr' -> <<"bsr"/utf8>>; 'not' -> <<"not"/utf8>>; 'and' -> <<"and"/utf8>>; 'or' -> <<"or"/utf8>>; 'xor' -> <<"xor"/utf8>>; 'andalso' -> <<"andalso"/utf8>>; 'orelse' -> <<"orelse"/utf8>>; double_plus -> <<"++"/utf8>>; double_minus -> <<"--"/utf8>>; question_equal -> <<"?="/utf8>>; question -> <<"?"/utf8>>; bang -> <<"!"/utf8>>; equal -> <<"="/utf8>>; {unknown, Char@1} -> Char@1; {unterminated_string, Contents@5} -> <<"\""/utf8, Contents@5/binary>>; {unterminated_sigil, Sigil@3, Delimiter@1, Contents@6} -> {Opening@1, _} = sigil_delimiters(Delimiter@1), <<<<<<"~"/utf8, Sigil@3/binary>>/binary, Opening@1/binary>>/binary, Contents@6/binary>>; {unterminated_atom, Contents@7} -> <<"'"/utf8, Contents@7/binary>>; {invalid_triple_quoted_string, Contents@8} -> <<<<"\"\"\""/utf8, Contents@8/binary>>/binary, "\"\"\""/utf8>> end. -file("src/pearl.gleam", 316). ?DOC(" Convert a list of tokens back to their original source code\n"). -spec to_source(list(token())) -> binary(). to_source(Tokens) -> gleam@list:fold( Tokens, <<""/utf8>>, fun(Code, Token) -> <> end ). -file("src/pearl.gleam", 361). -spec make_splitters() -> splitters(). make_splitters() -> {splitters, splitter:new([<<"\n"/utf8>>, <<"\r\n"/utf8>>]), splitter:new([<<"\""/utf8>>, <<"\\"/utf8>>]), splitter:new([<<"'"/utf8>>, <<"\\"/utf8>>]), splitter:new([<<"}"/utf8>>, <<"\n"/utf8>>, <<"\r\n"/utf8>>]), splitter:new( [<<")"/utf8>>, <<"]"/utf8>>, <<"}"/utf8>>, <<">"/utf8>>, <<"/"/utf8>>, <<"|"/utf8>>, <<"'"/utf8>>, <<"\""/utf8>>, <<"`"/utf8>>, <<"#"/utf8>>, <<"\\"/utf8>>] ), splitter:new( [<<")"/utf8>>, <<"]"/utf8>>, <<"}"/utf8>>, <<">"/utf8>>, <<"/"/utf8>>, <<"|"/utf8>>, <<"'"/utf8>>, <<"\""/utf8>>, <<"`"/utf8>>, <<"#"/utf8>>] ), splitter:new([<<"\n"/utf8>>, <<"\r\n"/utf8>>, <<"\"\"\""/utf8>>])}. -file("src/pearl.gleam", 351). -spec new(binary()) -> lexer(). new(Source) -> {lexer, Source, false, false, [], make_splitters()}. -file("src/pearl.gleam", 377). -spec ignore_comments(lexer()) -> lexer(). ignore_comments(Lexer) -> {lexer, erlang:element(2, Lexer), true, erlang:element(4, Lexer), erlang:element(5, Lexer), erlang:element(6, Lexer)}. -file("src/pearl.gleam", 381). -spec ignore_whitespace(lexer()) -> lexer(). ignore_whitespace(Lexer) -> {lexer, erlang:element(2, Lexer), erlang:element(3, Lexer), true, erlang:element(5, Lexer), erlang:element(6, Lexer)}. -file("src/pearl.gleam", 1070). -spec is_whitespace(binary()) -> boolean(). is_whitespace(String) -> case String of <<""/utf8>> -> true; <<" "/utf8, String@1/binary>> -> is_whitespace(String@1); <<"\n"/utf8, String@1/binary>> -> is_whitespace(String@1); <<"\r"/utf8, String@1/binary>> -> is_whitespace(String@1); <<"\t"/utf8, String@1/binary>> -> is_whitespace(String@1); <<"\f"/utf8, String@1/binary>> -> is_whitespace(String@1); _ -> false end. -file("src/pearl.gleam", 1082). -spec strip_line_prefixes(list(binary()), binary(), list(binary())) -> {ok, list(binary())} | {error, binary()}. strip_line_prefixes(Lines, End_indentation, Acc) -> case Lines of [] -> {ok, Acc}; [Line | Lines@1] -> case pearl_ffi:strip_prefix(Line, End_indentation) of {ok, Line@1} -> strip_line_prefixes( Lines@1, End_indentation, [Line@1 | Acc] ); {error, _} -> {error, Line} end end. -file("src/pearl.gleam", 1326). -spec advance(lexer(), binary()) -> lexer(). advance(Lexer, Source) -> {lexer, Source, erlang:element(3, Lexer), erlang:element(4, Lexer), erlang:element(5, Lexer), erlang:element(6, Lexer)}. -file("src/pearl.gleam", 663). -spec extract_octal_digit(lexer()) -> {ok, {lexer(), binary()}} | {error, nil}. extract_octal_digit(Lexer) -> case erlang:element(2, Lexer) of <<"0"/utf8, Source/binary>> -> Char = <<"0"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"1"/utf8, Source/binary>> -> Char = <<"1"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"2"/utf8, Source/binary>> -> Char = <<"2"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"3"/utf8, Source/binary>> -> Char = <<"3"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"4"/utf8, Source/binary>> -> Char = <<"4"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"5"/utf8, Source/binary>> -> Char = <<"5"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"6"/utf8, Source/binary>> -> Char = <<"6"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"7"/utf8, Source/binary>> -> Char = <<"7"/utf8>>, {ok, {advance(Lexer, Source), Char}}; _ -> {error, nil} end. -file("src/pearl.gleam", 652). -spec lex_octal_escape_sequence(lexer(), binary()) -> {lexer(), binary()}. lex_octal_escape_sequence(Lexer, First) -> case extract_octal_digit(Lexer) of {error, _} -> {Lexer, First}; {ok, {Lexer@1, Second}} -> case extract_octal_digit(Lexer@1) of {error, _} -> {Lexer@1, <>}; {ok, {Lexer@2, Third}} -> {Lexer@2, <<<>/binary, Third/binary>>} end end. -file("src/pearl.gleam", 688). -spec extract_hex_digit(lexer()) -> {ok, {lexer(), binary()}} | {error, nil}. extract_hex_digit(Lexer) -> case erlang:element(2, Lexer) of <<"0"/utf8, Source/binary>> -> Char = <<"0"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"1"/utf8, Source/binary>> -> Char = <<"1"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"2"/utf8, Source/binary>> -> Char = <<"2"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"3"/utf8, Source/binary>> -> Char = <<"3"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"4"/utf8, Source/binary>> -> Char = <<"4"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"5"/utf8, Source/binary>> -> Char = <<"5"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"6"/utf8, Source/binary>> -> Char = <<"6"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"7"/utf8, Source/binary>> -> Char = <<"7"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"8"/utf8, Source/binary>> -> Char = <<"8"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"9"/utf8, Source/binary>> -> Char = <<"9"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"a"/utf8, Source/binary>> -> Char = <<"a"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"b"/utf8, Source/binary>> -> Char = <<"b"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"c"/utf8, Source/binary>> -> Char = <<"c"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"d"/utf8, Source/binary>> -> Char = <<"d"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"e"/utf8, Source/binary>> -> Char = <<"e"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"f"/utf8, Source/binary>> -> Char = <<"f"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"A"/utf8, Source/binary>> -> Char = <<"A"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"B"/utf8, Source/binary>> -> Char = <<"B"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"C"/utf8, Source/binary>> -> Char = <<"C"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"D"/utf8, Source/binary>> -> Char = <<"D"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"E"/utf8, Source/binary>> -> Char = <<"E"/utf8>>, {ok, {advance(Lexer, Source), Char}}; <<"F"/utf8, Source/binary>> -> Char = <<"F"/utf8>>, {ok, {advance(Lexer, Source), Char}}; _ -> {error, nil} end. -file("src/pearl.gleam", 1063). -spec count_extra_quotes(lexer(), integer()) -> {lexer(), integer()}. count_extra_quotes(Lexer, Extra) -> case erlang:element(2, Lexer) of <<"\""/utf8, Source/binary>> -> count_extra_quotes(advance(Lexer, Source), Extra + 1); _ -> {Lexer, Extra} end. -file("src/pearl.gleam", 1150). -spec consume_extra_quotes(lexer(), integer()) -> {ok, lexer()} | {error, nil}. consume_extra_quotes(Lexer, Extra_quotes) -> case {Extra_quotes, erlang:element(2, Lexer)} of {0, _} -> {ok, Lexer}; {_, <<"\""/utf8, Source/binary>>} -> consume_extra_quotes(advance(Lexer, Source), Extra_quotes - 1); {_, _} -> {error, nil} end. -file("src/pearl.gleam", 1185). -spec lex_variable_or_atom(lexer(), binary()) -> {lexer(), binary()}. lex_variable_or_atom(Lexer, Lexed) -> case erlang:element(2, Lexer) of <<"a"/utf8, Source/binary>> -> Char = <<"a"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"b"/utf8, Source/binary>> -> Char = <<"b"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"c"/utf8, Source/binary>> -> Char = <<"c"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"d"/utf8, Source/binary>> -> Char = <<"d"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"e"/utf8, Source/binary>> -> Char = <<"e"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"f"/utf8, Source/binary>> -> Char = <<"f"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"g"/utf8, Source/binary>> -> Char = <<"g"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"h"/utf8, Source/binary>> -> Char = <<"h"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"i"/utf8, Source/binary>> -> Char = <<"i"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"j"/utf8, Source/binary>> -> Char = <<"j"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"k"/utf8, Source/binary>> -> Char = <<"k"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"l"/utf8, Source/binary>> -> Char = <<"l"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"m"/utf8, Source/binary>> -> Char = <<"m"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"n"/utf8, Source/binary>> -> Char = <<"n"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"o"/utf8, Source/binary>> -> Char = <<"o"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"p"/utf8, Source/binary>> -> Char = <<"p"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"q"/utf8, Source/binary>> -> Char = <<"q"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"r"/utf8, Source/binary>> -> Char = <<"r"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"s"/utf8, Source/binary>> -> Char = <<"s"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"t"/utf8, Source/binary>> -> Char = <<"t"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"u"/utf8, Source/binary>> -> Char = <<"u"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"v"/utf8, Source/binary>> -> Char = <<"v"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"w"/utf8, Source/binary>> -> Char = <<"w"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"x"/utf8, Source/binary>> -> Char = <<"x"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"y"/utf8, Source/binary>> -> Char = <<"y"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"z"/utf8, Source/binary>> -> Char = <<"z"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"A"/utf8, Source/binary>> -> Char = <<"A"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"B"/utf8, Source/binary>> -> Char = <<"B"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"C"/utf8, Source/binary>> -> Char = <<"C"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"D"/utf8, Source/binary>> -> Char = <<"D"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"E"/utf8, Source/binary>> -> Char = <<"E"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"F"/utf8, Source/binary>> -> Char = <<"F"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"G"/utf8, Source/binary>> -> Char = <<"G"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"H"/utf8, Source/binary>> -> Char = <<"H"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"I"/utf8, Source/binary>> -> Char = <<"I"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"J"/utf8, Source/binary>> -> Char = <<"J"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"K"/utf8, Source/binary>> -> Char = <<"K"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"L"/utf8, Source/binary>> -> Char = <<"L"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"M"/utf8, Source/binary>> -> Char = <<"M"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"N"/utf8, Source/binary>> -> Char = <<"N"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"O"/utf8, Source/binary>> -> Char = <<"O"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"P"/utf8, Source/binary>> -> Char = <<"P"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"Q"/utf8, Source/binary>> -> Char = <<"Q"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"R"/utf8, Source/binary>> -> Char = <<"R"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"S"/utf8, Source/binary>> -> Char = <<"S"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"T"/utf8, Source/binary>> -> Char = <<"T"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"U"/utf8, Source/binary>> -> Char = <<"U"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"V"/utf8, Source/binary>> -> Char = <<"V"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"W"/utf8, Source/binary>> -> Char = <<"W"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"X"/utf8, Source/binary>> -> Char = <<"X"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"Y"/utf8, Source/binary>> -> Char = <<"Y"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"Z"/utf8, Source/binary>> -> Char = <<"Z"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"0"/utf8, Source/binary>> -> Char = <<"0"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"1"/utf8, Source/binary>> -> Char = <<"1"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"2"/utf8, Source/binary>> -> Char = <<"2"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"3"/utf8, Source/binary>> -> Char = <<"3"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"4"/utf8, Source/binary>> -> Char = <<"4"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"5"/utf8, Source/binary>> -> Char = <<"5"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"6"/utf8, Source/binary>> -> Char = <<"6"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"7"/utf8, Source/binary>> -> Char = <<"7"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"8"/utf8, Source/binary>> -> Char = <<"8"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"9"/utf8, Source/binary>> -> Char = <<"9"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"_"/utf8, Source/binary>> -> Char = <<"_"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); <<"@"/utf8, Source/binary>> -> Char = <<"@"/utf8>>, lex_variable_or_atom( advance(Lexer, Source), <> ); _ -> {Lexer, Lexed} end. -file("src/pearl.gleam", 1257). -spec lex_variable(lexer(), binary()) -> {lexer(), token()}. lex_variable(Lexer, Char) -> {Lexer@1, Name} = lex_variable_or_atom(Lexer, Char), {Lexer@1, {variable, Name}}. -file("src/pearl.gleam", 1262). -spec lex_atom(lexer(), binary()) -> {lexer(), token()}. lex_atom(Lexer, Char) -> {Lexer@1, Name} = lex_variable_or_atom(Lexer, Char), Token = case Name of <<"after"/utf8>> -> 'after'; <<"begin"/utf8>> -> 'begin'; <<"case"/utf8>> -> 'case'; <<"catch"/utf8>> -> 'catch'; <<"cond"/utf8>> -> 'cond'; <<"else"/utf8>> -> 'else'; <<"end"/utf8>> -> 'end'; <<"fun"/utf8>> -> 'fun'; <<"if"/utf8>> -> 'if'; <<"let"/utf8>> -> 'let'; <<"maybe"/utf8>> -> 'maybe'; <<"of"/utf8>> -> 'of'; <<"receive"/utf8>> -> 'receive'; <<"try"/utf8>> -> 'try'; <<"when"/utf8>> -> 'when'; <<"bnot"/utf8>> -> 'bnot'; <<"div"/utf8>> -> 'div'; <<"rem"/utf8>> -> 'rem'; <<"band"/utf8>> -> 'band'; <<"bor"/utf8>> -> 'bor'; <<"bxor"/utf8>> -> 'bxor'; <<"bsl"/utf8>> -> 'bsl'; <<"bsr"/utf8>> -> 'bsr'; <<"not"/utf8>> -> 'not'; <<"and"/utf8>> -> 'and'; <<"or"/utf8>> -> 'or'; <<"xor"/utf8>> -> 'xor'; <<"andalso"/utf8>> -> 'andalso'; <<"orelse"/utf8>> -> 'orelse'; _ -> {atom, Name, false} end, {Lexer@1, Token}. -file("src/pearl.gleam", 1301). -spec lex_until_end_of_line(lexer()) -> {lexer(), binary()}. lex_until_end_of_line(Lexer) -> {Before, After} = splitter_ffi:split_after( erlang:element(2, erlang:element(6, Lexer)), erlang:element(2, Lexer) ), {advance(Lexer, After), Before}. -file("src/pearl.gleam", 1330). -spec error(lexer(), error()) -> lexer(). error(Lexer, Error) -> {lexer, erlang:element(2, Lexer), erlang:element(3, Lexer), erlang:element(4, Lexer), [Error | erlang:element(5, Lexer)], erlang:element(6, Lexer)}. -file("src/pearl.gleam", 677). -spec lex_hex_escape_sequence(lexer()) -> {lexer(), binary()}. lex_hex_escape_sequence(Lexer) -> case extract_hex_digit(Lexer) of {error, _} -> {error(Lexer, unterminated_escape_sequence), <<"x"/utf8>>}; {ok, {Lexer@1, First}} -> case extract_hex_digit(Lexer@1) of {error, _} -> {error(Lexer@1, unterminated_escape_sequence), <<"x"/utf8, First/binary>>}; {ok, {Lexer@2, Second}} -> {Lexer@2, <<<<"x"/utf8, First/binary>>/binary, Second/binary>>} end end. -file("src/pearl.gleam", 716). -spec lex_brace_escape_sequence(lexer()) -> {lexer(), binary()}. lex_brace_escape_sequence(Lexer) -> case splitter_ffi:split_after( erlang:element(5, erlang:element(6, Lexer)), erlang:element(2, Lexer) ) of {Before, <<""/utf8>>} -> {error(Lexer, unterminated_escape_sequence), Before}; {Before@1, After} -> {advance(Lexer, After), Before@1} end. -file("src/pearl.gleam", 569). -spec lex_escape_sequence(lexer()) -> {lexer(), binary()}. lex_escape_sequence(Lexer) -> case erlang:element(2, Lexer) of <<"^a"/utf8, Source/binary>> -> Sequence = <<"^a"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^b"/utf8, Source/binary>> -> Sequence = <<"^b"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^c"/utf8, Source/binary>> -> Sequence = <<"^c"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^d"/utf8, Source/binary>> -> Sequence = <<"^d"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^e"/utf8, Source/binary>> -> Sequence = <<"^e"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^f"/utf8, Source/binary>> -> Sequence = <<"^f"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^g"/utf8, Source/binary>> -> Sequence = <<"^g"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^h"/utf8, Source/binary>> -> Sequence = <<"^h"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^i"/utf8, Source/binary>> -> Sequence = <<"^i"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^j"/utf8, Source/binary>> -> Sequence = <<"^j"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^k"/utf8, Source/binary>> -> Sequence = <<"^k"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^l"/utf8, Source/binary>> -> Sequence = <<"^l"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^m"/utf8, Source/binary>> -> Sequence = <<"^m"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^n"/utf8, Source/binary>> -> Sequence = <<"^n"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^o"/utf8, Source/binary>> -> Sequence = <<"^o"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^p"/utf8, Source/binary>> -> Sequence = <<"^p"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^q"/utf8, Source/binary>> -> Sequence = <<"^q"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^r"/utf8, Source/binary>> -> Sequence = <<"^r"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^s"/utf8, Source/binary>> -> Sequence = <<"^s"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^t"/utf8, Source/binary>> -> Sequence = <<"^t"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^u"/utf8, Source/binary>> -> Sequence = <<"^u"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^v"/utf8, Source/binary>> -> Sequence = <<"^v"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^w"/utf8, Source/binary>> -> Sequence = <<"^w"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^x"/utf8, Source/binary>> -> Sequence = <<"^x"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^y"/utf8, Source/binary>> -> Sequence = <<"^y"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^z"/utf8, Source/binary>> -> Sequence = <<"^z"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^A"/utf8, Source/binary>> -> Sequence = <<"^A"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^B"/utf8, Source/binary>> -> Sequence = <<"^B"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^C"/utf8, Source/binary>> -> Sequence = <<"^C"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^D"/utf8, Source/binary>> -> Sequence = <<"^D"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^E"/utf8, Source/binary>> -> Sequence = <<"^E"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^F"/utf8, Source/binary>> -> Sequence = <<"^F"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^G"/utf8, Source/binary>> -> Sequence = <<"^G"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^H"/utf8, Source/binary>> -> Sequence = <<"^H"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^I"/utf8, Source/binary>> -> Sequence = <<"^I"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^J"/utf8, Source/binary>> -> Sequence = <<"^J"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^K"/utf8, Source/binary>> -> Sequence = <<"^K"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^L"/utf8, Source/binary>> -> Sequence = <<"^L"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^M"/utf8, Source/binary>> -> Sequence = <<"^M"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^N"/utf8, Source/binary>> -> Sequence = <<"^N"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^O"/utf8, Source/binary>> -> Sequence = <<"^O"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^P"/utf8, Source/binary>> -> Sequence = <<"^P"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^Q"/utf8, Source/binary>> -> Sequence = <<"^Q"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^R"/utf8, Source/binary>> -> Sequence = <<"^R"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^S"/utf8, Source/binary>> -> Sequence = <<"^S"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^T"/utf8, Source/binary>> -> Sequence = <<"^T"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^U"/utf8, Source/binary>> -> Sequence = <<"^U"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^V"/utf8, Source/binary>> -> Sequence = <<"^V"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^W"/utf8, Source/binary>> -> Sequence = <<"^W"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^X"/utf8, Source/binary>> -> Sequence = <<"^X"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^Y"/utf8, Source/binary>> -> Sequence = <<"^Y"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^Z"/utf8, Source/binary>> -> Sequence = <<"^Z"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^@"/utf8, Source/binary>> -> Sequence = <<"^@"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^["/utf8, Source/binary>> -> Sequence = <<"^["/utf8>>, {advance(Lexer, Source), Sequence}; <<"^\\"/utf8, Source/binary>> -> Sequence = <<"^\\"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^]"/utf8, Source/binary>> -> Sequence = <<"^]"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^^"/utf8, Source/binary>> -> Sequence = <<"^^"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^_"/utf8, Source/binary>> -> Sequence = <<"^_"/utf8>>, {advance(Lexer, Source), Sequence}; <<"^?"/utf8, Source/binary>> -> Sequence = <<"^?"/utf8>>, {advance(Lexer, Source), Sequence}; <<"x{"/utf8, _/binary>> -> lex_brace_escape_sequence(Lexer); <<"x"/utf8, Source@1/binary>> -> lex_hex_escape_sequence(advance(Lexer, Source@1)); <<"0"/utf8, Source@2/binary>> -> Char = <<"0"/utf8>>, lex_octal_escape_sequence(advance(Lexer, Source@2), Char); <<"1"/utf8, Source@2/binary>> -> Char = <<"1"/utf8>>, lex_octal_escape_sequence(advance(Lexer, Source@2), Char); <<"2"/utf8, Source@2/binary>> -> Char = <<"2"/utf8>>, lex_octal_escape_sequence(advance(Lexer, Source@2), Char); <<"3"/utf8, Source@2/binary>> -> Char = <<"3"/utf8>>, lex_octal_escape_sequence(advance(Lexer, Source@2), Char); <<"4"/utf8, Source@2/binary>> -> Char = <<"4"/utf8>>, lex_octal_escape_sequence(advance(Lexer, Source@2), Char); <<"5"/utf8, Source@2/binary>> -> Char = <<"5"/utf8>>, lex_octal_escape_sequence(advance(Lexer, Source@2), Char); <<"6"/utf8, Source@2/binary>> -> Char = <<"6"/utf8>>, lex_octal_escape_sequence(advance(Lexer, Source@2), Char); <<"7"/utf8, Source@2/binary>> -> Char = <<"7"/utf8>>, lex_octal_escape_sequence(advance(Lexer, Source@2), Char); _ -> case gleam_stdlib:string_pop_grapheme(erlang:element(2, Lexer)) of {error, _} -> {error(Lexer, unterminated_escape_sequence), <<""/utf8>>}; {ok, {Char@1, Source@3}} -> {advance(Lexer, Source@3), Char@1} end end. -file("src/pearl.gleam", 554). -spec lex_character(lexer()) -> {lexer(), token()}. lex_character(Lexer) -> case erlang:element(2, Lexer) of <<"\\"/utf8, Source/binary>> -> {Lexer@1, Escape_sequence} = lex_escape_sequence( advance(Lexer, Source) ), {Lexer@1, {character, <<"\\"/utf8, Escape_sequence/binary>>}}; _ -> case gleam_stdlib:string_pop_grapheme(erlang:element(2, Lexer)) of {ok, {Char, Source@1}} -> {advance(Lexer, Source@1), {character, Char}}; {error, _} -> {error(Lexer, unterminated_character), {character, <<""/utf8>>}} end end. -file("src/pearl.gleam", 740). -spec lex_number(lexer(), binary(), lex_number_mode(), delimited_position()) -> {lexer(), token()}. lex_number(Lexer, Lexed, Mode, Position) -> Radix = case Mode of {radix, R} -> R; initial -> 10; decimal -> 10; exponent -> 10 end, case erlang:element(2, Lexer) of <<"0"/utf8, Source/binary>> -> Char = <<"0"/utf8>>, lex_number( advance(Lexer, Source), <>, Mode, after_number ); <<"1"/utf8, Source/binary>> -> Char = <<"1"/utf8>>, lex_number( advance(Lexer, Source), <>, Mode, after_number ); <<"2"/utf8, Source@1/binary>> when Radix >= 3 -> Char@1 = <<"2"/utf8>>, lex_number( advance(Lexer, Source@1), <>, Mode, after_number ); <<"3"/utf8, Source@2/binary>> when Radix >= 4 -> Char@2 = <<"3"/utf8>>, lex_number( advance(Lexer, Source@2), <>, Mode, after_number ); <<"4"/utf8, Source@3/binary>> when Radix >= 5 -> Char@3 = <<"4"/utf8>>, lex_number( advance(Lexer, Source@3), <>, Mode, after_number ); <<"5"/utf8, Source@4/binary>> when Radix >= 6 -> Char@4 = <<"5"/utf8>>, lex_number( advance(Lexer, Source@4), <>, Mode, after_number ); <<"6"/utf8, Source@5/binary>> when Radix >= 7 -> Char@5 = <<"6"/utf8>>, lex_number( advance(Lexer, Source@5), <>, Mode, after_number ); <<"7"/utf8, Source@6/binary>> when Radix >= 8 -> Char@6 = <<"7"/utf8>>, lex_number( advance(Lexer, Source@6), <>, Mode, after_number ); <<"8"/utf8, Source@7/binary>> when Radix >= 9 -> Char@7 = <<"8"/utf8>>, lex_number( advance(Lexer, Source@7), <>, Mode, after_number ); <<"9"/utf8, Source@8/binary>> when Radix >= 10 -> Char@8 = <<"9"/utf8>>, lex_number( advance(Lexer, Source@8), <>, Mode, after_number ); <<"a"/utf8, Source@9/binary>> when Radix >= 11 -> Char@9 = <<"a"/utf8>>, lex_number( advance(Lexer, Source@9), <>, Mode, after_number ); <<"A"/utf8, Source@9/binary>> when Radix >= 11 -> Char@9 = <<"A"/utf8>>, lex_number( advance(Lexer, Source@9), <>, Mode, after_number ); <<"b"/utf8, Source@10/binary>> when Radix >= 12 -> Char@10 = <<"b"/utf8>>, lex_number( advance(Lexer, Source@10), <>, Mode, after_number ); <<"B"/utf8, Source@10/binary>> when Radix >= 12 -> Char@10 = <<"B"/utf8>>, lex_number( advance(Lexer, Source@10), <>, Mode, after_number ); <<"c"/utf8, Source@11/binary>> when Radix >= 13 -> Char@11 = <<"c"/utf8>>, lex_number( advance(Lexer, Source@11), <>, Mode, after_number ); <<"C"/utf8, Source@11/binary>> when Radix >= 13 -> Char@11 = <<"C"/utf8>>, lex_number( advance(Lexer, Source@11), <>, Mode, after_number ); <<"d"/utf8, Source@12/binary>> when Radix >= 14 -> Char@12 = <<"d"/utf8>>, lex_number( advance(Lexer, Source@12), <>, Mode, after_number ); <<"D"/utf8, Source@12/binary>> when Radix >= 14 -> Char@12 = <<"D"/utf8>>, lex_number( advance(Lexer, Source@12), <>, Mode, after_number ); <<"e"/utf8, Source@13/binary>> when Radix >= 15 -> Char@13 = <<"e"/utf8>>, lex_number( advance(Lexer, Source@13), <>, Mode, after_number ); <<"E"/utf8, Source@13/binary>> when Radix >= 15 -> Char@13 = <<"E"/utf8>>, lex_number( advance(Lexer, Source@13), <>, Mode, after_number ); <<"f"/utf8, Source@14/binary>> when Radix >= 16 -> Char@14 = <<"f"/utf8>>, lex_number( advance(Lexer, Source@14), <>, Mode, after_number ); <<"F"/utf8, Source@14/binary>> when Radix >= 16 -> Char@14 = <<"F"/utf8>>, lex_number( advance(Lexer, Source@14), <>, Mode, after_number ); <<"g"/utf8, Source@15/binary>> when Radix >= 17 -> Char@15 = <<"g"/utf8>>, lex_number( advance(Lexer, Source@15), <>, Mode, after_number ); <<"G"/utf8, Source@15/binary>> when Radix >= 17 -> Char@15 = <<"G"/utf8>>, lex_number( advance(Lexer, Source@15), <>, Mode, after_number ); <<"h"/utf8, Source@16/binary>> when Radix >= 18 -> Char@16 = <<"h"/utf8>>, lex_number( advance(Lexer, Source@16), <>, Mode, after_number ); <<"H"/utf8, Source@16/binary>> when Radix >= 18 -> Char@16 = <<"H"/utf8>>, lex_number( advance(Lexer, Source@16), <>, Mode, after_number ); <<"i"/utf8, Source@17/binary>> when Radix >= 19 -> Char@17 = <<"i"/utf8>>, lex_number( advance(Lexer, Source@17), <>, Mode, after_number ); <<"I"/utf8, Source@17/binary>> when Radix >= 19 -> Char@17 = <<"I"/utf8>>, lex_number( advance(Lexer, Source@17), <>, Mode, after_number ); <<"j"/utf8, Source@18/binary>> when Radix >= 20 -> Char@18 = <<"j"/utf8>>, lex_number( advance(Lexer, Source@18), <>, Mode, after_number ); <<"J"/utf8, Source@18/binary>> when Radix >= 20 -> Char@18 = <<"J"/utf8>>, lex_number( advance(Lexer, Source@18), <>, Mode, after_number ); <<"k"/utf8, Source@19/binary>> when Radix >= 21 -> Char@19 = <<"k"/utf8>>, lex_number( advance(Lexer, Source@19), <>, Mode, after_number ); <<"K"/utf8, Source@19/binary>> when Radix >= 21 -> Char@19 = <<"K"/utf8>>, lex_number( advance(Lexer, Source@19), <>, Mode, after_number ); <<"l"/utf8, Source@20/binary>> when Radix >= 22 -> Char@20 = <<"l"/utf8>>, lex_number( advance(Lexer, Source@20), <>, Mode, after_number ); <<"L"/utf8, Source@20/binary>> when Radix >= 22 -> Char@20 = <<"L"/utf8>>, lex_number( advance(Lexer, Source@20), <>, Mode, after_number ); <<"m"/utf8, Source@21/binary>> when Radix >= 23 -> Char@21 = <<"m"/utf8>>, lex_number( advance(Lexer, Source@21), <>, Mode, after_number ); <<"M"/utf8, Source@21/binary>> when Radix >= 23 -> Char@21 = <<"M"/utf8>>, lex_number( advance(Lexer, Source@21), <>, Mode, after_number ); <<"n"/utf8, Source@22/binary>> when Radix >= 24 -> Char@22 = <<"n"/utf8>>, lex_number( advance(Lexer, Source@22), <>, Mode, after_number ); <<"N"/utf8, Source@22/binary>> when Radix >= 24 -> Char@22 = <<"N"/utf8>>, lex_number( advance(Lexer, Source@22), <>, Mode, after_number ); <<"o"/utf8, Source@23/binary>> when Radix >= 25 -> Char@23 = <<"o"/utf8>>, lex_number( advance(Lexer, Source@23), <>, Mode, after_number ); <<"O"/utf8, Source@23/binary>> when Radix >= 25 -> Char@23 = <<"O"/utf8>>, lex_number( advance(Lexer, Source@23), <>, Mode, after_number ); <<"p"/utf8, Source@24/binary>> when Radix >= 26 -> Char@24 = <<"p"/utf8>>, lex_number( advance(Lexer, Source@24), <>, Mode, after_number ); <<"P"/utf8, Source@24/binary>> when Radix >= 26 -> Char@24 = <<"P"/utf8>>, lex_number( advance(Lexer, Source@24), <>, Mode, after_number ); <<"q"/utf8, Source@25/binary>> when Radix >= 27 -> Char@25 = <<"q"/utf8>>, lex_number( advance(Lexer, Source@25), <>, Mode, after_number ); <<"Q"/utf8, Source@25/binary>> when Radix >= 27 -> Char@25 = <<"Q"/utf8>>, lex_number( advance(Lexer, Source@25), <>, Mode, after_number ); <<"r"/utf8, Source@26/binary>> when Radix >= 28 -> Char@26 = <<"r"/utf8>>, lex_number( advance(Lexer, Source@26), <>, Mode, after_number ); <<"R"/utf8, Source@26/binary>> when Radix >= 28 -> Char@26 = <<"R"/utf8>>, lex_number( advance(Lexer, Source@26), <>, Mode, after_number ); <<"s"/utf8, Source@27/binary>> when Radix >= 29 -> Char@27 = <<"s"/utf8>>, lex_number( advance(Lexer, Source@27), <>, Mode, after_number ); <<"S"/utf8, Source@27/binary>> when Radix >= 29 -> Char@27 = <<"S"/utf8>>, lex_number( advance(Lexer, Source@27), <>, Mode, after_number ); <<"t"/utf8, Source@28/binary>> when Radix >= 30 -> Char@28 = <<"t"/utf8>>, lex_number( advance(Lexer, Source@28), <>, Mode, after_number ); <<"T"/utf8, Source@28/binary>> when Radix >= 30 -> Char@28 = <<"T"/utf8>>, lex_number( advance(Lexer, Source@28), <>, Mode, after_number ); <<"u"/utf8, Source@29/binary>> when Radix >= 31 -> Char@29 = <<"u"/utf8>>, lex_number( advance(Lexer, Source@29), <>, Mode, after_number ); <<"U"/utf8, Source@29/binary>> when Radix >= 31 -> Char@29 = <<"U"/utf8>>, lex_number( advance(Lexer, Source@29), <>, Mode, after_number ); <<"v"/utf8, Source@30/binary>> when Radix >= 32 -> Char@30 = <<"v"/utf8>>, lex_number( advance(Lexer, Source@30), <>, Mode, after_number ); <<"V"/utf8, Source@30/binary>> when Radix >= 32 -> Char@30 = <<"V"/utf8>>, lex_number( advance(Lexer, Source@30), <>, Mode, after_number ); <<"w"/utf8, Source@31/binary>> when Radix >= 33 -> Char@31 = <<"w"/utf8>>, lex_number( advance(Lexer, Source@31), <>, Mode, after_number ); <<"W"/utf8, Source@31/binary>> when Radix >= 33 -> Char@31 = <<"W"/utf8>>, lex_number( advance(Lexer, Source@31), <>, Mode, after_number ); <<"x"/utf8, Source@32/binary>> when Radix >= 34 -> Char@32 = <<"x"/utf8>>, lex_number( advance(Lexer, Source@32), <>, Mode, after_number ); <<"X"/utf8, Source@32/binary>> when Radix >= 34 -> Char@32 = <<"X"/utf8>>, lex_number( advance(Lexer, Source@32), <>, Mode, after_number ); <<"y"/utf8, Source@33/binary>> when Radix >= 35 -> Char@33 = <<"y"/utf8>>, lex_number( advance(Lexer, Source@33), <>, Mode, after_number ); <<"Y"/utf8, Source@33/binary>> when Radix >= 35 -> Char@33 = <<"Y"/utf8>>, lex_number( advance(Lexer, Source@33), <>, Mode, after_number ); <<"z"/utf8, Source@34/binary>> when Radix >= 36 -> Char@34 = <<"z"/utf8>>, lex_number( advance(Lexer, Source@34), <>, Mode, after_number ); <<"Z"/utf8, Source@34/binary>> when Radix >= 36 -> Char@34 = <<"Z"/utf8>>, lex_number( advance(Lexer, Source@34), <>, Mode, after_number ); <<"#"/utf8, Source@35/binary>> when (Mode =:= initial) andalso (Position =:= after_number) -> case gleam_stdlib:parse_int( gleam@string:replace(Lexed, <<"_"/utf8>>, <<""/utf8>>) ) of {error, _} -> {error(advance(Lexer, Source@35), {invalid_radix, Lexed}), {integer, Lexed}}; {ok, Radix@1} when (Radix@1 < 2) orelse (Radix@1 > 36) -> {error(advance(Lexer, Source@35), {invalid_radix, Lexed}), {integer, Lexed}}; {ok, Radix@2} -> lex_number( advance(Lexer, Source@35), <>, {radix, Radix@2}, after_radix ) end; <<"_"/utf8, Source@36/binary>> when Position =:= after_number -> lex_number( advance(Lexer, Source@36), <>, Mode, after_separator ); <<"_"/utf8, _/binary>> -> {error(Lexer, numeric_separator_not_allowed), {integer, Lexed}}; <<"."/utf8, Source@37/binary>> when (Mode =:= initial) andalso (Position =:= after_number) -> lex_number( advance(Lexer, Source@37), <>, decimal, after_decimal ); <<"e-"/utf8, Source@38/binary>> when (Mode =:= decimal) andalso (Position =:= after_number) -> Prefix = <<"e-"/utf8>>, lex_number( advance(Lexer, Source@38), <>, exponent, after_exponent ); <<"e"/utf8, Source@38/binary>> when (Mode =:= decimal) andalso (Position =:= after_number) -> Prefix = <<"e"/utf8>>, lex_number( advance(Lexer, Source@38), <>, exponent, after_exponent ); <<"E-"/utf8, Source@38/binary>> when (Mode =:= decimal) andalso (Position =:= after_number) -> Prefix = <<"E-"/utf8>>, lex_number( advance(Lexer, Source@38), <>, exponent, after_exponent ); <<"E"/utf8, Source@38/binary>> when (Mode =:= decimal) andalso (Position =:= after_number) -> Prefix = <<"E"/utf8>>, lex_number( advance(Lexer, Source@38), <>, exponent, after_exponent ); _ -> Token = case Mode of decimal -> {float, Lexed}; exponent -> {float, Lexed}; initial -> {integer, Lexed}; {radix, _} -> {integer, Lexed} end, case Position of after_decimal -> {advance( Lexer, <<"."/utf8, (erlang:element(2, Lexer))/binary>> ), {integer, gleam@string:drop_end(Lexed, 1)}}; after_exponent -> {error(Lexer, expected_exponent), Token}; after_radix -> {error(Lexer, number_cannot_end_after_radix), Token}; after_number -> {Lexer, Token}; after_separator -> {error(Lexer, numeric_separator_not_allowed), Token} end end. -file("src/pearl.gleam", 938). -spec do_lex_sigil( lexer(), binary(), sigil_delimiter(), binary(), splitter:splitter(), binary() ) -> {lexer(), token()}. do_lex_sigil(Lexer, Sigil, Delimiter, Closing_char, Splitter, Contents) -> {Before, Split, After} = splitter_ffi:split( Splitter, erlang:element(2, Lexer) ), case Split of <<""/utf8>> -> {error(advance(Lexer, After), unterminated_string_literal), {unterminated_sigil, Sigil, Delimiter, <>}}; <<"\\"/utf8>> -> case gleam_stdlib:string_pop_grapheme(After) of {error, _} -> {error(advance(Lexer, After), unterminated_string_literal), {unterminated_sigil, Sigil, Delimiter, <<<>/binary, "\\"/utf8>>}}; {ok, {Character, Source}} -> do_lex_sigil( advance(Lexer, Source), Sigil, Delimiter, Closing_char, Splitter, <<<<<>/binary, "\\"/utf8>>/binary, Character/binary>> ) end; _ when Split =:= Closing_char -> {advance(Lexer, After), {sigil, Sigil, Delimiter, <>}}; _ -> do_lex_sigil( advance(Lexer, After), Sigil, Delimiter, Closing_char, Splitter, <<<>/binary, Split/binary>> ) end. -file("src/pearl.gleam", 994). -spec lex_string(lexer(), binary()) -> {lexer(), token()}. lex_string(Lexer, Contents) -> {Before, Split, After} = splitter_ffi:split( erlang:element(3, erlang:element(6, Lexer)), erlang:element(2, Lexer) ), case Split of <<""/utf8>> -> {error(advance(Lexer, After), unterminated_string_literal), {unterminated_string, <>}}; <<"\\"/utf8>> -> {Lexer@1, Escape} = lex_escape_sequence(advance(Lexer, After)), lex_string( Lexer@1, <<<<<>/binary, "\\"/utf8>>/binary, Escape/binary>> ); _ -> {advance(Lexer, After), {string, <>}} end. -file("src/pearl.gleam", 1101). -spec lex_triple_quoted_string_contents( lexer(), list(binary()), binary(), integer() ) -> {lexer(), list(binary()), binary()}. lex_triple_quoted_string_contents(Lexer, Lines, Current_line, Extra_quotes) -> {Before, Split, After} = splitter_ffi:split( erlang:element(8, erlang:element(6, Lexer)), erlang:element(2, Lexer) ), Before@1 = <>, case Split of <<"\"\"\""/utf8>> -> Lexer@1 = advance(Lexer, After), case is_whitespace(Before@1) of false -> lex_triple_quoted_string_contents( Lexer@1, Lines, <>, Extra_quotes ); true when Extra_quotes =:= 0 -> {Lexer@1, Lines, Before@1}; true -> case consume_extra_quotes(Lexer@1, Extra_quotes) of {ok, Lexer@2} -> {Lexer@2, Lines, Before@1}; {error, nil} -> lex_triple_quoted_string_contents( Lexer@1, Lines, <>, Extra_quotes ) end end; <<"\n"/utf8>> -> lex_triple_quoted_string_contents( advance(Lexer, After), [Before@1 | Lines], <<""/utf8>>, Extra_quotes ); <<"\r\n"/utf8>> -> lex_triple_quoted_string_contents( advance(Lexer, After), [Before@1 | Lines], <<""/utf8>>, Extra_quotes ); _ -> {error(Lexer, unterminated_string_literal), [Before@1 | Lines], <<""/utf8>>} end. -file("src/pearl.gleam", 1012). -spec lex_triple_quoted_string(lexer(), gleam@option:option(binary())) -> {lexer(), token()}. lex_triple_quoted_string(Lexer, Sigil) -> {Lexer@1, Extra_quotes} = count_extra_quotes(Lexer, 0), {Lexer@2, Beginning_whitespace} = case splitter_ffi:split( erlang:element(2, erlang:element(6, Lexer@1)), erlang:element(2, Lexer@1) ) of {_, <<""/utf8>>, _} -> {error(Lexer@1, expected_whitespace_after_triple_quote), <<""/utf8>>}; {Before, Newline, After} -> case is_whitespace(Before) of true -> {advance(Lexer@1, After), <>}; false -> {error(Lexer@1, expected_whitespace_after_triple_quote), <<""/utf8>>} end end, {Lexer@3, Lines, End_indentation} = lex_triple_quoted_string_contents( Lexer@2, [], <<""/utf8>>, Extra_quotes ), case strip_line_prefixes(Lines, End_indentation, []) of {error, Line} -> Contents = <<<<<>))/binary>>/binary, "\n"/utf8>>/binary, End_indentation/binary>>, {error( Lexer@3, {invalid_triple_quoted_string_indentation, End_indentation, Line} ), {invalid_triple_quoted_string, Contents}}; {ok, Lines@1} -> {Lexer@3, {triple_quoted_string, Sigil, Extra_quotes + 3, Beginning_whitespace, Lines@1, End_indentation}} end. -file("src/pearl.gleam", 884). -spec lex_sigil(lexer()) -> {lexer(), token()}. lex_sigil(Lexer) -> {Lexer@1, Sigil@2, Verbatim} = case erlang:element(2, Lexer) of <<"b"/utf8, Source/binary>> -> Sigil = <<"b"/utf8>>, {advance(Lexer, Source), Sigil, false}; <<"s"/utf8, Source/binary>> -> Sigil = <<"s"/utf8>>, {advance(Lexer, Source), Sigil, false}; <<"B"/utf8, Source@1/binary>> -> Sigil@1 = <<"B"/utf8>>, {advance(Lexer, Source@1), Sigil@1, true}; <<"S"/utf8, Source@1/binary>> -> Sigil@1 = <<"S"/utf8>>, {advance(Lexer, Source@1), Sigil@1, true}; _ -> {Lexer, <<""/utf8>>, false} end, case erlang:element(2, Lexer@1) of <<"\"\"\""/utf8, Source@2/binary>> -> lex_triple_quoted_string( advance(Lexer@1, Source@2), {some, Sigil@2} ); _ -> {Lexer@2, Delimiter, Closing_char} = case erlang:element(2, Lexer@1) of <<"("/utf8, Source@3/binary>> -> {advance(Lexer@1, Source@3), sigil_paren, <<")"/utf8>>}; <<"["/utf8, Source@4/binary>> -> {advance(Lexer@1, Source@4), sigil_square, <<"]"/utf8>>}; <<"{"/utf8, Source@5/binary>> -> {advance(Lexer@1, Source@5), sigil_brace, <<"}"/utf8>>}; <<"<"/utf8, Source@6/binary>> -> {advance(Lexer@1, Source@6), sigil_angle, <<">"/utf8>>}; <<"/"/utf8, Source@7/binary>> -> {advance(Lexer@1, Source@7), sigil_slash, <<"/"/utf8>>}; <<"|"/utf8, Source@8/binary>> -> {advance(Lexer@1, Source@8), sigil_pipe, <<"|"/utf8>>}; <<"'"/utf8, Source@9/binary>> -> {advance(Lexer@1, Source@9), sigil_single_quote, <<"'"/utf8>>}; <<"\""/utf8, Source@10/binary>> -> {advance(Lexer@1, Source@10), sigil_double_quote, <<"\""/utf8>>}; <<"`"/utf8, Source@11/binary>> -> {advance(Lexer@1, Source@11), sigil_backtick, <<"`"/utf8>>}; <<"#"/utf8, Source@12/binary>> -> {advance(Lexer@1, Source@12), sigil_hash, <<"#"/utf8>>}; _ -> {error(Lexer@1, expected_sigil_delimiter), sigil_none, <<""/utf8>>} end, case Delimiter of sigil_none -> {Lexer@2, {unterminated_sigil, Sigil@2, Delimiter, <<""/utf8>>}}; _ -> Splitter = case Verbatim of false -> erlang:element(6, erlang:element(6, Lexer@2)); true -> erlang:element(7, erlang:element(6, Lexer@2)) end, do_lex_sigil( Lexer@2, Sigil@2, Delimiter, Closing_char, Splitter, <<""/utf8>> ) end end. -file("src/pearl.gleam", 1159). -spec lex_quoted_atom(lexer(), binary()) -> {lexer(), token()}. lex_quoted_atom(Lexer, Contents) -> {Before, Split, After} = splitter_ffi:split( erlang:element(4, erlang:element(6, Lexer)), erlang:element(2, Lexer) ), case Split of <<""/utf8>> -> {error(advance(Lexer, After), unterminated_quoted_atom), {unterminated_atom, <>}}; <<"\\"/utf8>> -> case gleam_stdlib:string_pop_grapheme(After) of {error, _} -> {error(advance(Lexer, After), unterminated_string_literal), {unterminated_string, Contents}}; {ok, {Character, Source}} -> lex_string( advance(Lexer, Source), <<<<<>/binary, "\\"/utf8>>/binary, Character/binary>> ) end; _ -> {advance(Lexer, After), {atom, <>, true}} end. -file("src/pearl.gleam", 1467). -spec do_highlight_tokens(list(token()), list(highlight_token())) -> list(highlight_token()). do_highlight_tokens(In, Out) -> case In of [] -> lists:reverse(Out); [{atom, Value, false}, left_paren | In@1] -> do_highlight_tokens( In@1, [{highlight_punctuation, <<"("/utf8>>}, {highlight_function, Value} | Out] ); [{atom, Function, false}, slash, {integer, Arity} | In@2] -> do_highlight_tokens( In@2, [{highlight_number, Arity}, {highlight_punctuation, <<"/"/utf8>>}, {highlight_function, Function} | Out] ); [{atom, Module, false}, colon, {atom, Function@1, false}, slash, {integer, Arity@1} | In@3] -> do_highlight_tokens( In@3, [{highlight_number, Arity@1}, {highlight_punctuation, <<"/"/utf8>>}, {highlight_function, Function@1}, {highlight_punctuation, <<":"/utf8>>}, {highlight_module, Module} | Out] ); [{atom, Module@1, false}, colon, {atom, Function@2, false} | In@4] -> do_highlight_tokens( In@4, [{highlight_function, Function@2}, {highlight_punctuation, <<":"/utf8>>}, {highlight_module, Module@1} | Out] ); [question, {variable, Macro_name} | In@5] -> do_highlight_tokens( In@5, [{highlight_function, Macro_name}, {highlight_punctuation, <<"?"/utf8>>} | Out] ); [{whitespace, Space} | In@6] -> do_highlight_tokens(In@6, [{highlight_whitespace, Space} | Out]); [{comment, Contents} | In@7] -> do_highlight_tokens( In@7, [{highlight_comment, <<"%"/utf8, Contents/binary>>} | Out] ); [{doc_comment, Contents@1} | In@8] -> do_highlight_tokens( In@8, [{highlight_comment, <<"%%"/utf8, Contents@1/binary>>} | Out] ); [{module_comment, Contents@2} | In@9] -> do_highlight_tokens( In@9, [{highlight_comment, <<"%%%"/utf8, Contents@2/binary>>} | Out] ); [end_of_file | In@10] -> do_highlight_tokens(In@10, Out); [{character, Char} | In@11] -> do_highlight_tokens( In@11, [{highlight_string, <<"$"/utf8, Char/binary>>} | Out] ); [{integer, Int} | In@12] -> do_highlight_tokens(In@12, [{highlight_number, Int} | Out]); [{float, Float} | In@13] -> do_highlight_tokens(In@13, [{highlight_number, Float} | Out]); [{atom, Name, true} | In@14] -> do_highlight_tokens( In@14, [{highlight_atom, <<<<"'"/utf8, Name/binary>>/binary, "'"/utf8>>} | Out] ); [{atom, Name@1, false} | In@15] -> do_highlight_tokens(In@15, [{highlight_atom, Name@1} | Out]); [{string, Contents@3} | In@16] -> do_highlight_tokens( In@16, [{highlight_string, <<<<"\""/utf8, Contents@3/binary>>/binary, "\""/utf8>>} | Out] ); [{triple_quoted_string, Sigil, Number_of_quotes, Beginning_whitespace, Lines, End_indentation} | In@17] -> do_highlight_tokens( In@17, [{highlight_string, <<<<<<<<<<<<(case Sigil of none -> <<""/utf8>>; {some, Sigil@1} -> <<"~"/utf8, Sigil@1/binary>> end)/binary, (gleam@string:repeat( <<"\""/utf8>>, Number_of_quotes ))/binary>>/binary, Beginning_whitespace/binary>>/binary, (gleam@string:join( gleam@list:map( Lines, fun(Line) -> <> end ), <<"\n"/utf8>> ))/binary>>/binary, "\n"/utf8>>/binary, End_indentation/binary>>/binary, (gleam@string:repeat( <<"\""/utf8>>, Number_of_quotes ))/binary>>} | Out] ); [{sigil, Sigil@2, Delimiter, Contents@4} | In@18] -> do_highlight_tokens( In@18, [{highlight_string, begin {Opening, Closing} = sigil_delimiters(Delimiter), <<<<<<<<"~"/utf8, Sigil@2/binary>>/binary, Opening/binary>>/binary, Contents@4/binary>>/binary, Closing/binary>> end} | Out] ); [{variable, Name@2} | In@19] -> do_highlight_tokens(In@19, [{highlight_variable, Name@2} | Out]); ['after' | In@20] -> do_highlight_tokens( In@20, [{highlight_keyword, <<"after"/utf8>>} | Out] ); ['begin' | In@21] -> do_highlight_tokens( In@21, [{highlight_keyword, <<"begin"/utf8>>} | Out] ); ['case' | In@22] -> do_highlight_tokens( In@22, [{highlight_keyword, <<"case"/utf8>>} | Out] ); ['catch' | In@23] -> do_highlight_tokens( In@23, [{highlight_keyword, <<"catch"/utf8>>} | Out] ); ['cond' | In@24] -> do_highlight_tokens( In@24, [{highlight_keyword, <<"cond"/utf8>>} | Out] ); ['else' | In@25] -> do_highlight_tokens( In@25, [{highlight_keyword, <<"else"/utf8>>} | Out] ); ['end' | In@26] -> do_highlight_tokens( In@26, [{highlight_keyword, <<"end"/utf8>>} | Out] ); ['fun' | In@27] -> do_highlight_tokens( In@27, [{highlight_keyword, <<"fun"/utf8>>} | Out] ); ['if' | In@28] -> do_highlight_tokens( In@28, [{highlight_keyword, <<"if"/utf8>>} | Out] ); ['let' | In@29] -> do_highlight_tokens( In@29, [{highlight_keyword, <<"let"/utf8>>} | Out] ); ['maybe' | In@30] -> do_highlight_tokens( In@30, [{highlight_keyword, <<"maybe"/utf8>>} | Out] ); ['of' | In@31] -> do_highlight_tokens( In@31, [{highlight_keyword, <<"of"/utf8>>} | Out] ); ['receive' | In@32] -> do_highlight_tokens( In@32, [{highlight_keyword, <<"receive"/utf8>>} | Out] ); ['try' | In@33] -> do_highlight_tokens( In@33, [{highlight_keyword, <<"try"/utf8>>} | Out] ); ['when' | In@34] -> do_highlight_tokens( In@34, [{highlight_keyword, <<"when"/utf8>>} | Out] ); [left_paren | In@35] -> do_highlight_tokens( In@35, [{highlight_punctuation, <<"("/utf8>>} | Out] ); [right_paren | In@36] -> do_highlight_tokens( In@36, [{highlight_punctuation, <<")"/utf8>>} | Out] ); [left_brace | In@37] -> do_highlight_tokens( In@37, [{highlight_punctuation, <<"{"/utf8>>} | Out] ); [right_brace | In@38] -> do_highlight_tokens( In@38, [{highlight_punctuation, <<"}"/utf8>>} | Out] ); [left_square | In@39] -> do_highlight_tokens( In@39, [{highlight_punctuation, <<"["/utf8>>} | Out] ); [right_square | In@40] -> do_highlight_tokens( In@40, [{highlight_punctuation, <<"]"/utf8>>} | Out] ); [comma | In@41] -> do_highlight_tokens( In@41, [{highlight_punctuation, <<","/utf8>>} | Out] ); [semicolon | In@42] -> do_highlight_tokens( In@42, [{highlight_punctuation, <<";"/utf8>>} | Out] ); [colon | In@43] -> do_highlight_tokens( In@43, [{highlight_punctuation, <<":"/utf8>>} | Out] ); [dot | In@44] -> do_highlight_tokens( In@44, [{highlight_punctuation, <<"."/utf8>>} | Out] ); [minus_greater | In@45] -> do_highlight_tokens( In@45, [{highlight_punctuation, <<"->"/utf8>>} | Out] ); [double_less | In@46] -> do_highlight_tokens( In@46, [{highlight_punctuation, <<"<<"/utf8>>} | Out] ); [double_greater | In@47] -> do_highlight_tokens( In@47, [{highlight_punctuation, <<">>"/utf8>>} | Out] ); [hash | In@48] -> do_highlight_tokens( In@48, [{highlight_punctuation, <<"#"/utf8>>} | Out] ); [double_colon | In@49] -> do_highlight_tokens( In@49, [{highlight_punctuation, <<"::"/utf8>>} | Out] ); [double_dot | In@50] -> do_highlight_tokens( In@50, [{highlight_punctuation, <<".."/utf8>>} | Out] ); [triple_dot | In@51] -> do_highlight_tokens( In@51, [{highlight_punctuation, <<"..."/utf8>>} | Out] ); [question | In@52] -> do_highlight_tokens( In@52, [{highlight_punctuation, <<"?"/utf8>>} | Out] ); [double_pipe | In@53] -> do_highlight_tokens( In@53, [{highlight_operator, <<"||"/utf8>>} | Out] ); [equal_greater | In@54] -> do_highlight_tokens( In@54, [{highlight_operator, <<"=>"/utf8>>} | Out] ); [colon_equal | In@55] -> do_highlight_tokens( In@55, [{highlight_operator, <<":="/utf8>>} | Out] ); [less_minus | In@56] -> do_highlight_tokens( In@56, [{highlight_operator, <<"<-"/utf8>>} | Out] ); [less_equal | In@57] -> do_highlight_tokens( In@57, [{highlight_operator, <<"<="/utf8>>} | Out] ); [pipe | In@58] -> do_highlight_tokens( In@58, [{highlight_operator, <<"|"/utf8>>} | Out] ); [double_equal | In@59] -> do_highlight_tokens( In@59, [{highlight_operator, <<"=="/utf8>>} | Out] ); [slash_equal | In@60] -> do_highlight_tokens( In@60, [{highlight_operator, <<"/="/utf8>>} | Out] ); [equal_less | In@61] -> do_highlight_tokens( In@61, [{highlight_operator, <<"=<"/utf8>>} | Out] ); [less | In@62] -> do_highlight_tokens( In@62, [{highlight_operator, <<"<"/utf8>>} | Out] ); [greater_equal | In@63] -> do_highlight_tokens( In@63, [{highlight_operator, <<">="/utf8>>} | Out] ); [greater | In@64] -> do_highlight_tokens( In@64, [{highlight_operator, <<">"/utf8>>} | Out] ); [equal_colon_equal | In@65] -> do_highlight_tokens( In@65, [{highlight_operator, <<"=:="/utf8>>} | Out] ); [equal_slash_equal | In@66] -> do_highlight_tokens( In@66, [{highlight_operator, <<"=/="/utf8>>} | Out] ); [plus | In@67] -> do_highlight_tokens( In@67, [{highlight_operator, <<"+"/utf8>>} | Out] ); [minus | In@68] -> do_highlight_tokens( In@68, [{highlight_operator, <<"-"/utf8>>} | Out] ); [star | In@69] -> do_highlight_tokens( In@69, [{highlight_operator, <<"*"/utf8>>} | Out] ); [slash | In@70] -> do_highlight_tokens( In@70, [{highlight_operator, <<"/"/utf8>>} | Out] ); ['bnot' | In@71] -> do_highlight_tokens( In@71, [{highlight_operator, <<"bnot"/utf8>>} | Out] ); ['div' | In@72] -> do_highlight_tokens( In@72, [{highlight_operator, <<"div"/utf8>>} | Out] ); ['rem' | In@73] -> do_highlight_tokens( In@73, [{highlight_operator, <<"rem"/utf8>>} | Out] ); ['band' | In@74] -> do_highlight_tokens( In@74, [{highlight_operator, <<"band"/utf8>>} | Out] ); ['bor' | In@75] -> do_highlight_tokens( In@75, [{highlight_operator, <<"bor"/utf8>>} | Out] ); ['bxor' | In@76] -> do_highlight_tokens( In@76, [{highlight_operator, <<"bxor"/utf8>>} | Out] ); ['bsl' | In@77] -> do_highlight_tokens( In@77, [{highlight_operator, <<"bsl"/utf8>>} | Out] ); ['bsr' | In@78] -> do_highlight_tokens( In@78, [{highlight_operator, <<"bsr"/utf8>>} | Out] ); ['not' | In@79] -> do_highlight_tokens( In@79, [{highlight_operator, <<"not"/utf8>>} | Out] ); ['and' | In@80] -> do_highlight_tokens( In@80, [{highlight_operator, <<"and"/utf8>>} | Out] ); ['or' | In@81] -> do_highlight_tokens( In@81, [{highlight_operator, <<"or"/utf8>>} | Out] ); ['xor' | In@82] -> do_highlight_tokens( In@82, [{highlight_operator, <<"xor"/utf8>>} | Out] ); ['andalso' | In@83] -> do_highlight_tokens( In@83, [{highlight_operator, <<"andalso"/utf8>>} | Out] ); ['orelse' | In@84] -> do_highlight_tokens( In@84, [{highlight_operator, <<"orelse"/utf8>>} | Out] ); [double_plus | In@85] -> do_highlight_tokens( In@85, [{highlight_operator, <<"++"/utf8>>} | Out] ); [double_minus | In@86] -> do_highlight_tokens( In@86, [{highlight_operator, <<"--"/utf8>>} | Out] ); [question_equal | In@87] -> do_highlight_tokens( In@87, [{highlight_operator, <<"?="/utf8>>} | Out] ); [bang | In@88] -> do_highlight_tokens( In@88, [{highlight_operator, <<"!"/utf8>>} | Out] ); [equal | In@89] -> do_highlight_tokens( In@89, [{highlight_operator, <<"="/utf8>>} | Out] ); [{unknown, Char@1} | In@90] -> do_highlight_tokens(In@90, [{highlight_other, Char@1} | Out]); [{unterminated_string, Contents@5} | In@91] -> do_highlight_tokens( In@91, [{highlight_string, <<"\""/utf8, Contents@5/binary>>} | Out] ); [{unterminated_sigil, Sigil@3, Delimiter@1, Contents@6} | In@92] -> do_highlight_tokens( In@92, [{highlight_string, begin {Opening@1, _} = sigil_delimiters(Delimiter@1), <<<<<<"~"/utf8, Sigil@3/binary>>/binary, Opening@1/binary>>/binary, Contents@6/binary>> end} | Out] ); [{unterminated_atom, Contents@7} | In@93] -> do_highlight_tokens( In@93, [{highlight_atom, <<"'"/utf8, Contents@7/binary>>} | Out] ); [{invalid_triple_quoted_string, Contents@8} | In@94] -> do_highlight_tokens( In@94, [{highlight_string, <<<<"\"\"\""/utf8, Contents@8/binary>>/binary, "\"\"\""/utf8>>} | Out] ) end. -file("src/pearl.gleam", 1319). -spec maybe_token(lexer(), token(), boolean()) -> {lexer(), token()}. maybe_token(Lexer, Token, Condition) -> case Condition of true -> {Lexer, Token}; false -> next(Lexer) end. -file("src/pearl.gleam", 399). -spec next(lexer()) -> {lexer(), token()}. next(Lexer) -> case erlang:element(2, Lexer) of <<""/utf8>> -> {Lexer, end_of_file}; <<" "/utf8, Source/binary>> -> Space = <<" "/utf8>>, lex_whitespace(advance(Lexer, Source), Space); <<"\n"/utf8, Source/binary>> -> Space = <<"\n"/utf8>>, lex_whitespace(advance(Lexer, Source), Space); <<"\r"/utf8, Source/binary>> -> Space = <<"\r"/utf8>>, lex_whitespace(advance(Lexer, Source), Space); <<"\t"/utf8, Source/binary>> -> Space = <<"\t"/utf8>>, lex_whitespace(advance(Lexer, Source), Space); <<"\f"/utf8, Source/binary>> -> Space = <<"\f"/utf8>>, lex_whitespace(advance(Lexer, Source), Space); <<"%%%"/utf8, Source@1/binary>> -> {Lexer@1, Contents} = lex_until_end_of_line( advance(Lexer, Source@1) ), maybe_token( Lexer@1, {module_comment, Contents}, not erlang:element(3, Lexer@1) ); <<"%%"/utf8, Source@2/binary>> -> {Lexer@2, Contents@1} = lex_until_end_of_line( advance(Lexer, Source@2) ), maybe_token( Lexer@2, {doc_comment, Contents@1}, not erlang:element(3, Lexer@2) ); <<"%"/utf8, Source@3/binary>> -> {Lexer@3, Contents@2} = lex_until_end_of_line( advance(Lexer, Source@3) ), maybe_token( Lexer@3, {comment, Contents@2}, not erlang:element(3, Lexer@3) ); <<"::"/utf8, Source@4/binary>> -> {advance(Lexer, Source@4), double_colon}; <<":="/utf8, Source@5/binary>> -> {advance(Lexer, Source@5), colon_equal}; <<":"/utf8, Source@6/binary>> -> {advance(Lexer, Source@6), colon}; <<"..."/utf8, Source@7/binary>> -> {advance(Lexer, Source@7), triple_dot}; <<".."/utf8, Source@8/binary>> -> {advance(Lexer, Source@8), double_dot}; <<"("/utf8, Source@9/binary>> -> {advance(Lexer, Source@9), left_paren}; <<")"/utf8, Source@10/binary>> -> {advance(Lexer, Source@10), right_paren}; <<"{"/utf8, Source@11/binary>> -> {advance(Lexer, Source@11), left_brace}; <<"}"/utf8, Source@12/binary>> -> {advance(Lexer, Source@12), right_brace}; <<"["/utf8, Source@13/binary>> -> {advance(Lexer, Source@13), left_square}; <<"]"/utf8, Source@14/binary>> -> {advance(Lexer, Source@14), right_square}; <<","/utf8, Source@15/binary>> -> {advance(Lexer, Source@15), comma}; <<";"/utf8, Source@16/binary>> -> {advance(Lexer, Source@16), semicolon}; <<"."/utf8, Source@17/binary>> -> {advance(Lexer, Source@17), dot}; <<"->"/utf8, Source@18/binary>> -> {advance(Lexer, Source@18), minus_greater}; <<"<<"/utf8, Source@19/binary>> -> {advance(Lexer, Source@19), double_less}; <<">>"/utf8, Source@20/binary>> -> {advance(Lexer, Source@20), double_greater}; <<"#"/utf8, Source@21/binary>> -> {advance(Lexer, Source@21), hash}; <<"||"/utf8, Source@22/binary>> -> {advance(Lexer, Source@22), double_pipe}; <<"=>"/utf8, Source@23/binary>> -> {advance(Lexer, Source@23), equal_greater}; <<"<-"/utf8, Source@24/binary>> -> {advance(Lexer, Source@24), less_minus}; <<"<="/utf8, Source@25/binary>> -> {advance(Lexer, Source@25), less_equal}; <<"|"/utf8, Source@26/binary>> -> {advance(Lexer, Source@26), pipe}; <<"++"/utf8, Source@27/binary>> -> {advance(Lexer, Source@27), double_plus}; <<"--"/utf8, Source@28/binary>> -> {advance(Lexer, Source@28), double_minus}; <<"=="/utf8, Source@29/binary>> -> {advance(Lexer, Source@29), double_equal}; <<"/="/utf8, Source@30/binary>> -> {advance(Lexer, Source@30), slash_equal}; <<"=<"/utf8, Source@31/binary>> -> {advance(Lexer, Source@31), equal_less}; <<"<"/utf8, Source@32/binary>> -> {advance(Lexer, Source@32), less}; <<">="/utf8, Source@33/binary>> -> {advance(Lexer, Source@33), greater_equal}; <<">"/utf8, Source@34/binary>> -> {advance(Lexer, Source@34), greater}; <<"=:="/utf8, Source@35/binary>> -> {advance(Lexer, Source@35), equal_colon_equal}; <<"=/="/utf8, Source@36/binary>> -> {advance(Lexer, Source@36), equal_slash_equal}; <<"+"/utf8, Source@37/binary>> -> {advance(Lexer, Source@37), plus}; <<"-"/utf8, Source@38/binary>> -> {advance(Lexer, Source@38), minus}; <<"*"/utf8, Source@39/binary>> -> {advance(Lexer, Source@39), star}; <<"/"/utf8, Source@40/binary>> -> {advance(Lexer, Source@40), slash}; <<"?="/utf8, Source@41/binary>> -> {advance(Lexer, Source@41), question_equal}; <<"?"/utf8, Source@42/binary>> -> {advance(Lexer, Source@42), question}; <<"!"/utf8, Source@43/binary>> -> {advance(Lexer, Source@43), bang}; <<"="/utf8, Source@44/binary>> -> {advance(Lexer, Source@44), equal}; <<"a"/utf8, Source@45/binary>> -> Char = <<"a"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"b"/utf8, Source@45/binary>> -> Char = <<"b"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"c"/utf8, Source@45/binary>> -> Char = <<"c"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"d"/utf8, Source@45/binary>> -> Char = <<"d"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"e"/utf8, Source@45/binary>> -> Char = <<"e"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"f"/utf8, Source@45/binary>> -> Char = <<"f"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"g"/utf8, Source@45/binary>> -> Char = <<"g"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"h"/utf8, Source@45/binary>> -> Char = <<"h"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"i"/utf8, Source@45/binary>> -> Char = <<"i"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"j"/utf8, Source@45/binary>> -> Char = <<"j"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"k"/utf8, Source@45/binary>> -> Char = <<"k"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"l"/utf8, Source@45/binary>> -> Char = <<"l"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"m"/utf8, Source@45/binary>> -> Char = <<"m"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"n"/utf8, Source@45/binary>> -> Char = <<"n"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"o"/utf8, Source@45/binary>> -> Char = <<"o"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"p"/utf8, Source@45/binary>> -> Char = <<"p"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"q"/utf8, Source@45/binary>> -> Char = <<"q"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"r"/utf8, Source@45/binary>> -> Char = <<"r"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"s"/utf8, Source@45/binary>> -> Char = <<"s"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"t"/utf8, Source@45/binary>> -> Char = <<"t"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"u"/utf8, Source@45/binary>> -> Char = <<"u"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"v"/utf8, Source@45/binary>> -> Char = <<"v"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"w"/utf8, Source@45/binary>> -> Char = <<"w"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"x"/utf8, Source@45/binary>> -> Char = <<"x"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"y"/utf8, Source@45/binary>> -> Char = <<"y"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"z"/utf8, Source@45/binary>> -> Char = <<"z"/utf8>>, lex_atom(advance(Lexer, Source@45), Char); <<"A"/utf8, Source@46/binary>> -> Char@1 = <<"A"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"B"/utf8, Source@46/binary>> -> Char@1 = <<"B"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"C"/utf8, Source@46/binary>> -> Char@1 = <<"C"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"D"/utf8, Source@46/binary>> -> Char@1 = <<"D"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"E"/utf8, Source@46/binary>> -> Char@1 = <<"E"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"F"/utf8, Source@46/binary>> -> Char@1 = <<"F"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"G"/utf8, Source@46/binary>> -> Char@1 = <<"G"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"H"/utf8, Source@46/binary>> -> Char@1 = <<"H"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"I"/utf8, Source@46/binary>> -> Char@1 = <<"I"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"J"/utf8, Source@46/binary>> -> Char@1 = <<"J"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"K"/utf8, Source@46/binary>> -> Char@1 = <<"K"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"L"/utf8, Source@46/binary>> -> Char@1 = <<"L"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"M"/utf8, Source@46/binary>> -> Char@1 = <<"M"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"N"/utf8, Source@46/binary>> -> Char@1 = <<"N"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"O"/utf8, Source@46/binary>> -> Char@1 = <<"O"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"P"/utf8, Source@46/binary>> -> Char@1 = <<"P"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"Q"/utf8, Source@46/binary>> -> Char@1 = <<"Q"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"R"/utf8, Source@46/binary>> -> Char@1 = <<"R"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"S"/utf8, Source@46/binary>> -> Char@1 = <<"S"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"T"/utf8, Source@46/binary>> -> Char@1 = <<"T"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"U"/utf8, Source@46/binary>> -> Char@1 = <<"U"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"V"/utf8, Source@46/binary>> -> Char@1 = <<"V"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"W"/utf8, Source@46/binary>> -> Char@1 = <<"W"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"X"/utf8, Source@46/binary>> -> Char@1 = <<"X"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"Y"/utf8, Source@46/binary>> -> Char@1 = <<"Y"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"Z"/utf8, Source@46/binary>> -> Char@1 = <<"Z"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"_"/utf8, Source@46/binary>> -> Char@1 = <<"_"/utf8>>, lex_variable(advance(Lexer, Source@46), Char@1); <<"0"/utf8, Source@47/binary>> -> Char@2 = <<"0"/utf8>>, lex_number(advance(Lexer, Source@47), Char@2, initial, after_number); <<"1"/utf8, Source@47/binary>> -> Char@2 = <<"1"/utf8>>, lex_number(advance(Lexer, Source@47), Char@2, initial, after_number); <<"2"/utf8, Source@47/binary>> -> Char@2 = <<"2"/utf8>>, lex_number(advance(Lexer, Source@47), Char@2, initial, after_number); <<"3"/utf8, Source@47/binary>> -> Char@2 = <<"3"/utf8>>, lex_number(advance(Lexer, Source@47), Char@2, initial, after_number); <<"4"/utf8, Source@47/binary>> -> Char@2 = <<"4"/utf8>>, lex_number(advance(Lexer, Source@47), Char@2, initial, after_number); <<"5"/utf8, Source@47/binary>> -> Char@2 = <<"5"/utf8>>, lex_number(advance(Lexer, Source@47), Char@2, initial, after_number); <<"6"/utf8, Source@47/binary>> -> Char@2 = <<"6"/utf8>>, lex_number(advance(Lexer, Source@47), Char@2, initial, after_number); <<"7"/utf8, Source@47/binary>> -> Char@2 = <<"7"/utf8>>, lex_number(advance(Lexer, Source@47), Char@2, initial, after_number); <<"8"/utf8, Source@47/binary>> -> Char@2 = <<"8"/utf8>>, lex_number(advance(Lexer, Source@47), Char@2, initial, after_number); <<"9"/utf8, Source@47/binary>> -> Char@2 = <<"9"/utf8>>, lex_number(advance(Lexer, Source@47), Char@2, initial, after_number); <<"\"\"\""/utf8, Source@48/binary>> -> lex_triple_quoted_string(advance(Lexer, Source@48), none); <<"\""/utf8, Source@49/binary>> -> lex_string(advance(Lexer, Source@49), <<""/utf8>>); <<"'"/utf8, Source@50/binary>> -> lex_quoted_atom(advance(Lexer, Source@50), <<""/utf8>>); <<"$"/utf8, Source@51/binary>> -> lex_character(advance(Lexer, Source@51)); <<"~"/utf8, Source@52/binary>> -> lex_sigil(advance(Lexer, Source@52)); _ -> case gleam_stdlib:string_pop_grapheme(erlang:element(2, Lexer)) of {error, _} -> {Lexer, end_of_file}; {ok, {Char@3, Source@53}} -> {advance( error(Lexer, {unknown_character, Char@3}), Source@53 ), {unknown, Char@3}} end end. -file("src/pearl.gleam", 389). -spec do_tokenise(lexer(), list(token())) -> {list(token()), list(error())}. do_tokenise(Lexer, Tokens) -> case next(Lexer) of {Lexer@1, end_of_file} -> {lists:reverse([end_of_file | Tokens]), lists:reverse(erlang:element(5, Lexer@1))}; {Lexer@2, Token} -> do_tokenise(Lexer@2, [Token | Tokens]) end. -file("src/pearl.gleam", 385). -spec tokenise(lexer()) -> {list(token()), list(error())}. tokenise(Lexer) -> do_tokenise(Lexer, []). -file("src/pearl.gleam", 1307). -spec lex_whitespace(lexer(), binary()) -> {lexer(), token()}. lex_whitespace(Lexer, Lexed) -> case erlang:element(2, Lexer) of <<" "/utf8, Source/binary>> -> Space = <<" "/utf8>>, lex_whitespace( advance(Lexer, Source), <> ); <<"\n"/utf8, Source/binary>> -> Space = <<"\n"/utf8>>, lex_whitespace( advance(Lexer, Source), <> ); <<"\r"/utf8, Source/binary>> -> Space = <<"\r"/utf8>>, lex_whitespace( advance(Lexer, Source), <> ); <<"\t"/utf8, Source/binary>> -> Space = <<"\t"/utf8>>, lex_whitespace( advance(Lexer, Source), <> ); <<"\f"/utf8, Source/binary>> -> Space = <<"\f"/utf8>>, lex_whitespace( advance(Lexer, Source), <> ); _ -> maybe_token( Lexer, {whitespace, Lexed}, not erlang:element(4, Lexer) ) end. -file("src/pearl.gleam", 1462). ?DOC( " Convert a string of Erlang source code into highlighting tokens.\n" " Highlighting tokens only contain information about the kind of syntax\n" " being used, grouping similar tokens (e.g. all keywords) into one category.\n" " \n" " To convert code into syntax tokens, see `pearl.tokenise`.\n" ). -spec highlight_tokens(binary()) -> list(highlight_token()). highlight_tokens(Code) -> {Tokens, _} = tokenise(new(Code)), do_highlight_tokens(Tokens, []). -file("src/pearl.gleam", 1370). ?DOC( " Convert a string of Erlang source code into ansi highlighting.\n" " \n" " Colours taken from [`contour`](https://hexdocs.pm/contour):\n" " | Token | Colour |\n" " | ---------------------- | ----------- |\n" " | Keyword | Yellow |\n" " | Module | Cyan |\n" " | Function | Blue |\n" " | Operator | Magenta |\n" " | Comment | Italic grey |\n" " | String, Number, Atom | Green |\n" " | Whitespace, Variable | No colour |\n" "\n" " If you wish to use other colours or another format, use `to_tokens`.\n" ). -spec highlight_ansi(binary()) -> binary(). highlight_ansi(Code) -> _pipe = highlight_tokens(Code), gleam@list:fold( _pipe, <<""/utf8>>, fun(Code@1, Token) -> < gleam_community@ansi:reset(S); {highlight_keyword, S@1} -> gleam_community@ansi:yellow(S@1); {highlight_variable, S@2} -> gleam_community@ansi:reset(S@2); {highlight_string, S@3} -> gleam_community@ansi:green(S@3); {highlight_atom, S@4} -> gleam_community@ansi:green(S@4); {highlight_number, S@5} -> gleam_community@ansi:green(S@5); {highlight_module, S@6} -> gleam_community@ansi:cyan(S@6); {highlight_function, S@7} -> gleam_community@ansi:blue(S@7); {highlight_operator, S@8} -> gleam_community@ansi:magenta(S@8); {highlight_comment, S@9} -> gleam_community@ansi:italic( gleam_community@ansi:gray(S@9) ); {highlight_punctuation, S@10} -> gleam_community@ansi:reset(S@10); {highlight_other, S@11} -> gleam_community@ansi:reset(S@11) end)/binary>> end ). -file("src/pearl.gleam", 1426). ?DOC( " Convert a string of Erlang source code into an HTML string.\n" " Each token is wrapped in a `` with a class indicating the type of \n" " \n" " Class names taken from [`contour`](https://hexdocs.pm/contour):\n" " | Token | CSS class |\n" " | ----------- | -------------- |\n" " | Keyword | hl-keyword |\n" " | Variable | hl-variable |\n" " | Module | hl-module |\n" " | Function | hl-function |\n" " | Operator | hl-operator |\n" " | Punctuation | hl-punctuation |\n" " | Comment | hl-comment |\n" " | String | hl-string |\n" " | Atom | hl-atom |\n" " | Number | hl-number |\n" " | Whitespace | no class |\n" "\n" " Place the output within a `
...
` and add styling for\n" " these CSS classes to get highlighting on your website. Here's some CSS you\n" " could use:\n" "\n" " ```css\n" " pre code .hl-comment { color: #d4d4d4; font-style: italic }\n" " pre code .hl-function { color: #9ce7ff }\n" " pre code .hl-keyword { color: #ffd596 }\n" " pre code .hl-operator { color: #ffaff3 }\n" " pre code .hl-string { color: #c8ffa7 }\n" " pre code .hl-number { color: #c8ffa7 }\n" " pre code .hl-atom { color: #c8ffa7 }\n" " pre code .hl-module { color: #ffddfa }\n" " ```\n" "\n" " If you wish to use another format see `to_ansi` or `to_tokens`.\n" ). -spec highlight_html(binary()) -> binary(). highlight_html(Code) -> _pipe = highlight_tokens(Code), gleam@list:fold(_pipe, <<""/utf8>>, fun(Acc, Token) -> case Token of {highlight_whitespace, S} -> <>; {highlight_keyword, S@1} -> <<<<<"/utf8>>/binary, (houdini:escape(S@1))/binary>>/binary, "
"/utf8>>; {highlight_variable, S@2} -> <<<<<"/utf8>>/binary, (houdini:escape(S@2))/binary>>/binary, ""/utf8>>; {highlight_string, S@3} -> <<<<<"/utf8>>/binary, (houdini:escape(S@3))/binary>>/binary, ""/utf8>>; {highlight_atom, S@4} -> <<<<<"/utf8>>/binary, (houdini:escape(S@4))/binary>>/binary, ""/utf8>>; {highlight_number, S@5} -> <<<<<"/utf8>>/binary, (houdini:escape(S@5))/binary>>/binary, ""/utf8>>; {highlight_module, S@6} -> <<<<<"/utf8>>/binary, (houdini:escape(S@6))/binary>>/binary, ""/utf8>>; {highlight_function, S@7} -> <<<<<"/utf8>>/binary, (houdini:escape(S@7))/binary>>/binary, ""/utf8>>; {highlight_operator, S@8} -> <<<<<"/utf8>>/binary, (houdini:escape(S@8))/binary>>/binary, ""/utf8>>; {highlight_comment, S@9} -> <<<<<"/utf8>>/binary, (houdini:escape(S@9))/binary>>/binary, ""/utf8>>; {highlight_punctuation, S@10} -> <<<<<"/utf8>>/binary, (houdini:escape(S@10))/binary>>/binary, ""/utf8>>; {highlight_other, S@11} -> <> end end).