-module(yum@yaml@lexer@double_quoted_scalar).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/yum/yaml/lexer/double_quoted_scalar.gleam").
-export([lexer/0, escape_lexer/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.
?MODULEDOC(false).
-file("src/yum/yaml/lexer/double_quoted_scalar.gleam", 6).
?DOC(false).
-spec lexer() -> nibble@lexer:matcher(yum@yaml@token:token(), yum@yaml@lexer@context:context()).
lexer() ->
nibble@lexer:custom(
fun(Ctx, Lexeme, Lookahead) ->
Prev@1 = case Ctx of
{double_quoted_scalar, Prev} -> Prev;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
file => <<?FILEPATH/utf8>>,
module => <<"yum/yaml/lexer/double_quoted_scalar"/utf8>>,
function => <<"lexer"/utf8>>,
line => 8,
value => _assert_fail,
start => 229,
'end' => 279,
pattern_start => 240,
pattern_end => 273})
end,
case {Lexeme, Lookahead} of
{<<"\""/utf8>>, _} ->
_pipe = double_quote,
{keep, _pipe, Prev@1};
{<<"\\"/utf8>>, _} ->
{drop, {double_quoted_escape, Ctx}};
{L, <<"\""/utf8>>} ->
_pipe@1 = {double_quoted_scalar, L},
{keep, _pipe@1, Ctx};
{L@1, <<"\\"/utf8>>} ->
_pipe@2 = {double_quoted_scalar, L@1},
{keep, _pipe@2, Ctx};
{_, _} ->
skip
end
end
).
-file("src/yum/yaml/lexer/double_quoted_scalar.gleam", 20).
?DOC(false).
-spec escape_lexer() -> nibble@lexer:matcher(yum@yaml@token:token(), yum@yaml@lexer@context:context()).
escape_lexer() ->
nibble@lexer:custom(
fun(Ctx, Lexeme, _) ->
Prev@1 = case Ctx of
{double_quoted_escape, Prev} -> Prev;
_assert_fail ->
erlang:error(#{gleam_error => let_assert,
message => <<"Pattern match failed, no pattern matched the value."/utf8>>,
file => <<?FILEPATH/utf8>>,
module => <<"yum/yaml/lexer/double_quoted_scalar"/utf8>>,
function => <<"escape_lexer"/utf8>>,
line => 22,
value => _assert_fail,
start => 676,
'end' => 726,
pattern_start => 687,
pattern_end => 720})
end,
case Lexeme of
<<"0"/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<"a"/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<"b"/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<"t"/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<"n"/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<"v"/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<"f"/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<"r"/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<"e"/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<" "/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<"\""/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<"/"/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<"\\"/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<"N"/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<"_"/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<"L"/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<"P"/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<"x"/utf8, Ns_hex_digit_2/binary>> ->
case string:length(Ns_hex_digit_2) of
2 ->
{keep, {escape, Lexeme}, Prev@1};
_ ->
skip
end;
<<"u"/utf8, Ns_hex_digit_4/binary>> ->
case string:length(Ns_hex_digit_4) of
4 ->
{keep, {escape, Lexeme}, Prev@1};
_ ->
skip
end;
<<"U"/utf8, Ns_hex_digit_8/binary>> ->
case string:length(Ns_hex_digit_8) of
8 ->
{keep, {escape, Lexeme}, Prev@1};
_ ->
skip
end;
<<"\n"/utf8>> ->
{keep, {escape, Lexeme}, Prev@1};
<<""/utf8>> ->
skip;
_ ->
{keep, invalid_escape, Prev@1}
end
end
).