Skip to main content

src/yum@yaml@lexer@comment.erl

-module(yum@yaml@lexer@comment).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/yum/yaml/lexer/comment.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/comment.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) -> case {Lexeme, Lookahead} of
                {<<"#"/utf8>>, <<"\n"/utf8>>} ->
                    {drop, Ctx};

                {<<"#"/utf8>>, <<""/utf8>>} ->
                    {drop, Ctx};

                {<<"#"/utf8, _/binary>>, <<"\n"/utf8>>} ->
                    {drop, Ctx};

                {<<"#"/utf8, _/binary>>, <<""/utf8>>} ->
                    {drop, Ctx};

                {<<"#"/utf8>>, _} ->
                    skip;

                {<<"#"/utf8, _/binary>>, _} ->
                    skip;

                {_, <<"#"/utf8>>} ->
                    case gleam@string:trim(Lexeme) =:= <<""/utf8>> of
                        true ->
                            {drop, Ctx};

                        false ->
                            no_match
                    end;

                {_, _} ->
                    no_match
            end end
    ).