-module(yum@yaml@lexer@plain_scalar).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/yum/yaml/lexer/plain_scalar.gleam").
-export([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/plain_scalar.gleam", 96).
?DOC(false).
-spec mapping_key(binary()) -> yum@yaml@token:token().
mapping_key(Lexeme) ->
_pipe = Lexeme,
_pipe@1 = gleam@string:drop_end(_pipe, 1),
_pipe@2 = gleam@string:trim_end(_pipe@1),
{mapping_key, _pipe@2}.
-file("src/yum/yaml/lexer/plain_scalar.gleam", 103).
?DOC(false).
-spec plain_scalar(binary()) -> yum@yaml@token:token().
plain_scalar(Lexeme) ->
_pipe = Lexeme,
_pipe@1 = gleam@string:trim_end(_pipe),
{plain_scalar, _pipe@1}.
-file("src/yum/yaml/lexer/plain_scalar.gleam", 89).
?DOC(false).
-spec ends_with_whitespace(binary()) -> boolean().
ends_with_whitespace(S) ->
((gleam_stdlib:string_ends_with(S, <<" "/utf8>>) orelse gleam_stdlib:string_ends_with(
S,
<<"\t"/utf8>>
))
orelse gleam_stdlib:string_ends_with(S, <<"\r"/utf8>>))
orelse gleam_stdlib:string_ends_with(S, <<"\n"/utf8>>).
-file("src/yum/yaml/lexer/plain_scalar.gleam", 75).
?DOC(false).
-spec current_indent(yum@yaml@lexer@context:context()) -> integer().
current_indent(Ctx) ->
case Ctx of
{block_style, Indent} ->
Indent;
{flow_style, Prev} ->
current_indent(Prev);
{flow_mapping, Prev} ->
current_indent(Prev);
{flow_sequence, Prev} ->
current_indent(Prev);
{block_scalar, Prev, _} ->
current_indent(Prev);
{double_quoted_scalar, Prev} ->
current_indent(Prev);
{single_quoted_scalar, Prev} ->
current_indent(Prev);
{double_quoted_escape, Prev} ->
current_indent(Prev)
end.
-file("src/yum/yaml/lexer/plain_scalar.gleam", 68).
?DOC(false).
-spec keep_plain_or_mapping_key(
binary(),
yum@yaml@lexer@context:context(),
yum@yaml@lexer@context:context()
) -> nibble@lexer:match(yum@yaml@token:token(), yum@yaml@lexer@context:context()).
keep_plain_or_mapping_key(Lexeme, Ctx, Prev) ->
case gleam_stdlib:string_ends_with(Lexeme, <<":"/utf8>>) of
true ->
_pipe = mapping_key(Lexeme),
{keep, _pipe, Ctx};
false ->
_pipe@1 = plain_scalar(Lexeme),
{keep, _pipe@1, Prev}
end.
-file("src/yum/yaml/lexer/plain_scalar.gleam", 9).
?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
{flow_style, 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/plain_scalar"/utf8>>,
function => <<"lexer"/utf8>>,
line => 11,
value => _assert_fail,
start => 333,
'end' => 374,
pattern_start => 344,
pattern_end => 368})
end,
case {Lexeme, Lookahead} of
{<<" "/utf8>>, _} ->
{drop, Ctx};
{<<"\t"/utf8>>, _} ->
{drop, Ctx};
{<<"\r"/utf8>>, _} ->
{drop, Ctx};
{<<"-"/utf8>>, <<" "/utf8>>} ->
_pipe = hyphen,
{keep, _pipe, Ctx};
{<<"-"/utf8>>, <<"\n"/utf8>>} ->
_pipe = hyphen,
{keep, _pipe, Ctx};
{<<"-"/utf8>>, <<""/utf8>>} ->
_pipe = hyphen,
{keep, _pipe, Ctx};
{<<"{"/utf8>>, _} ->
_pipe@1 = open_mapping,
{keep, _pipe@1, {flow_mapping, Ctx}};
{<<"["/utf8>>, _} ->
_pipe@2 = open_sequence,
{keep, _pipe@2, {flow_sequence, Ctx}};
{<<"\""/utf8>>, _} ->
_pipe@3 = double_quote,
{keep, _pipe@3, {double_quoted_scalar, Ctx}};
{<<"'"/utf8>>, _} ->
_pipe@4 = single_quote,
{keep, _pipe@4, {single_quoted_scalar, Ctx}};
{<<"?"/utf8>>, <<" "/utf8>>} ->
_pipe@5 = question_mark,
{keep, _pipe@5, Ctx};
{<<"?"/utf8>>, <<"\t"/utf8>>} ->
_pipe@5 = question_mark,
{keep, _pipe@5, Ctx};
{<<"?"/utf8>>, <<"\r"/utf8>>} ->
_pipe@5 = question_mark,
{keep, _pipe@5, Ctx};
{<<"?"/utf8>>, <<"\n"/utf8>>} ->
_pipe@5 = question_mark,
{keep, _pipe@5, Ctx};
{<<"?"/utf8>>, <<""/utf8>>} ->
_pipe@5 = question_mark,
{keep, _pipe@5, Ctx};
{<<":"/utf8>>, <<" "/utf8>>} ->
_pipe@6 = colon,
{keep, _pipe@6, Ctx};
{<<":"/utf8>>, <<"\t"/utf8>>} ->
_pipe@6 = colon,
{keep, _pipe@6, Ctx};
{<<":"/utf8>>, <<"\r"/utf8>>} ->
_pipe@6 = colon,
{keep, _pipe@6, Ctx};
{<<":"/utf8>>, <<"\n"/utf8>>} ->
_pipe@6 = colon,
{keep, _pipe@6, Ctx};
{<<":"/utf8>>, <<""/utf8>>} ->
_pipe@6 = colon,
{keep, _pipe@6, Ctx};
{_, <<"\n"/utf8>>} ->
case yum@yaml@lexer@node_property:token(Lexeme) of
{some, Property} ->
case Property of
{anchor, _} ->
_pipe@7 = Property,
{keep, _pipe@7, Ctx};
{alias, _} ->
_pipe@8 = Property,
{keep, _pipe@8, Prev@1};
_ ->
_pipe@9 = Property,
{keep, _pipe@9, Ctx}
end;
none ->
case yum@yaml@lexer@block_scalar:header(
Lexeme,
current_indent(Prev@1)
) of
{some, Header} ->
_pipe@10 = Header,
{keep,
_pipe@10,
{block_scalar,
Prev@1,
current_indent(Prev@1)}};
none ->
keep_plain_or_mapping_key(
Lexeme,
Ctx,
Prev@1
)
end
end;
{_, <<""/utf8>>} ->
case yum@yaml@lexer@node_property:token(Lexeme) of
{some, Property} ->
case Property of
{anchor, _} ->
_pipe@7 = Property,
{keep, _pipe@7, Ctx};
{alias, _} ->
_pipe@8 = Property,
{keep, _pipe@8, Prev@1};
_ ->
_pipe@9 = Property,
{keep, _pipe@9, Ctx}
end;
none ->
case yum@yaml@lexer@block_scalar:header(
Lexeme,
current_indent(Prev@1)
) of
{some, Header} ->
_pipe@10 = Header,
{keep,
_pipe@10,
{block_scalar,
Prev@1,
current_indent(Prev@1)}};
none ->
keep_plain_or_mapping_key(
Lexeme,
Ctx,
Prev@1
)
end
end;
{_, <<"#"/utf8>>} ->
case ends_with_whitespace(Lexeme) of
true ->
_pipe@11 = plain_scalar(Lexeme),
{keep, _pipe@11, Prev@1};
false ->
skip
end;
{_, <<" "/utf8>>} ->
case yum@yaml@lexer@node_property:token(Lexeme) of
{some, Property@1} ->
case Property@1 of
{anchor, _} ->
_pipe@12 = Property@1,
{keep, _pipe@12, Ctx};
{alias, _} ->
_pipe@13 = Property@1,
{keep, _pipe@13, Prev@1};
_ ->
_pipe@14 = Property@1,
{keep, _pipe@14, Ctx}
end;
none ->
case gleam_stdlib:string_ends_with(
Lexeme,
<<":"/utf8>>
) of
true ->
_pipe@15 = mapping_key(Lexeme),
{keep, _pipe@15, Ctx};
false ->
skip
end
end;
{_, <<"\t"/utf8>>} ->
case yum@yaml@lexer@node_property:token(Lexeme) of
{some, Property@1} ->
case Property@1 of
{anchor, _} ->
_pipe@12 = Property@1,
{keep, _pipe@12, Ctx};
{alias, _} ->
_pipe@13 = Property@1,
{keep, _pipe@13, Prev@1};
_ ->
_pipe@14 = Property@1,
{keep, _pipe@14, Ctx}
end;
none ->
case gleam_stdlib:string_ends_with(
Lexeme,
<<":"/utf8>>
) of
true ->
_pipe@15 = mapping_key(Lexeme),
{keep, _pipe@15, Ctx};
false ->
skip
end
end;
{_, <<"\r"/utf8>>} ->
case yum@yaml@lexer@node_property:token(Lexeme) of
{some, Property@1} ->
case Property@1 of
{anchor, _} ->
_pipe@12 = Property@1,
{keep, _pipe@12, Ctx};
{alias, _} ->
_pipe@13 = Property@1,
{keep, _pipe@13, Prev@1};
_ ->
_pipe@14 = Property@1,
{keep, _pipe@14, Ctx}
end;
none ->
case gleam_stdlib:string_ends_with(
Lexeme,
<<":"/utf8>>
) of
true ->
_pipe@15 = mapping_key(Lexeme),
{keep, _pipe@15, Ctx};
false ->
skip
end
end;
{_, _} ->
skip
end
end
).