Skip to main content

src/yum@yaml@lexer@flow_sequence.erl

-module(yum@yaml@lexer@flow_sequence).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/yum/yaml/lexer/flow_sequence.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/flow_sequence.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_sequence, 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/flow_sequence"/utf8>>,
                                function => <<"lexer"/utf8>>,
                                line => 11,
                                value => _assert_fail,
                                start => 323,
                                'end' => 367,
                                pattern_start => 334,
                                pattern_end => 361})
            end,
            case {Lexeme, Lookahead} of
                {<<" "/utf8>>, _} ->
                    {drop, Ctx};

                {<<"\t"/utf8>>, _} ->
                    {drop, Ctx};

                {<<"\r"/utf8>>, _} ->
                    {drop, Ctx};

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

                {<<"]"/utf8>>, _} ->
                    _pipe = close_sequence,
                    {keep, _pipe, Prev@1};

                {<<","/utf8>>, _} ->
                    _pipe@1 = comma,
                    {keep, _pipe@1, Ctx};

                {<<":"/utf8>>, <<":"/utf8>>} ->
                    skip;

                {<<":"/utf8>>, _} ->
                    _pipe@2 = colon,
                    {keep, _pipe@2, Ctx};

                {<<"?"/utf8>>, _} ->
                    _pipe@3 = question_mark,
                    {keep, _pipe@3, Ctx};

                {<<"["/utf8>>, _} ->
                    _pipe@4 = open_sequence,
                    {keep, _pipe@4, {flow_sequence, Ctx}};

                {<<"{"/utf8>>, _} ->
                    _pipe@5 = open_mapping,
                    {keep, _pipe@5, {flow_mapping, Ctx}};

                {<<"\""/utf8>>, _} ->
                    _pipe@6 = double_quote,
                    {keep, _pipe@6, {double_quoted_scalar, Ctx}};

                {<<"'"/utf8>>, _} ->
                    _pipe@7 = single_quote,
                    {keep, _pipe@7, {single_quoted_scalar, Ctx}};

                {_, <<"#"/utf8>>} ->
                    case yum@yaml@lexer@flow_collection:ends_with_whitespace(
                        Lexeme
                    ) of
                        true ->
                            yum@yaml@lexer@flow_collection:keep_plain_scalar(
                                Lexeme,
                                Ctx
                            );

                        false ->
                            skip
                    end;

                {_, <<":"/utf8>>} ->
                    case yum@yaml@lexer@flow_collection:ends_with_whitespace(
                        Lexeme
                    ) of
                        true ->
                            yum@yaml@lexer@flow_collection:keep_plain_scalar(
                                Lexeme,
                                Ctx
                            );

                        false ->
                            skip
                    end;

                {_, <<" "/utf8>>} ->
                    case yum@yaml@lexer@node_property:token(Lexeme) of
                        {some, Token} ->
                            _pipe@8 = Token,
                            {keep, _pipe@8, Ctx};

                        none ->
                            case gleam_stdlib:string_ends_with(
                                Lexeme,
                                <<":"/utf8>>
                            ) of
                                true ->
                                    yum@yaml@lexer@flow_collection:keep_plain_scalar(
                                        Lexeme,
                                        Ctx
                                    );

                                false ->
                                    skip
                            end
                    end;

                {_, <<"\t"/utf8>>} ->
                    case yum@yaml@lexer@node_property:token(Lexeme) of
                        {some, Token} ->
                            _pipe@8 = Token,
                            {keep, _pipe@8, Ctx};

                        none ->
                            case gleam_stdlib:string_ends_with(
                                Lexeme,
                                <<":"/utf8>>
                            ) of
                                true ->
                                    yum@yaml@lexer@flow_collection:keep_plain_scalar(
                                        Lexeme,
                                        Ctx
                                    );

                                false ->
                                    skip
                            end
                    end;

                {_, <<"\r"/utf8>>} ->
                    case yum@yaml@lexer@node_property:token(Lexeme) of
                        {some, Token} ->
                            _pipe@8 = Token,
                            {keep, _pipe@8, Ctx};

                        none ->
                            case gleam_stdlib:string_ends_with(
                                Lexeme,
                                <<":"/utf8>>
                            ) of
                                true ->
                                    yum@yaml@lexer@flow_collection:keep_plain_scalar(
                                        Lexeme,
                                        Ctx
                                    );

                                false ->
                                    skip
                            end
                    end;

                {_, <<"\n"/utf8>>} ->
                    case yum@yaml@lexer@node_property:token(Lexeme) of
                        {some, Token} ->
                            _pipe@8 = Token,
                            {keep, _pipe@8, Ctx};

                        none ->
                            case gleam_stdlib:string_ends_with(
                                Lexeme,
                                <<":"/utf8>>
                            ) of
                                true ->
                                    yum@yaml@lexer@flow_collection:keep_plain_scalar(
                                        Lexeme,
                                        Ctx
                                    );

                                false ->
                                    skip
                            end
                    end;

                {_, <<"]"/utf8>>} ->
                    yum@yaml@lexer@flow_collection:keep_plain_scalar(
                        Lexeme,
                        Ctx
                    );

                {_, <<","/utf8>>} ->
                    yum@yaml@lexer@flow_collection:keep_plain_scalar(
                        Lexeme,
                        Ctx
                    );

                {_, <<"["/utf8>>} ->
                    yum@yaml@lexer@flow_collection:keep_plain_scalar(
                        Lexeme,
                        Ctx
                    );

                {_, <<"{"/utf8>>} ->
                    yum@yaml@lexer@flow_collection:keep_plain_scalar(
                        Lexeme,
                        Ctx
                    );

                {_, <<"\""/utf8>>} ->
                    yum@yaml@lexer@flow_collection:keep_plain_scalar(
                        Lexeme,
                        Ctx
                    );

                {_, <<"'"/utf8>>} ->
                    yum@yaml@lexer@flow_collection:keep_plain_scalar(
                        Lexeme,
                        Ctx
                    );

                {_, <<""/utf8>>} ->
                    yum@yaml@lexer@flow_collection:keep_plain_scalar(
                        Lexeme,
                        Ctx
                    );

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