Skip to main content

src/yum@yaml@lexer@node_property.erl

-module(yum@yaml@lexer@node_property).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/yum/yaml/lexer/node_property.gleam").
-export([token/1]).

-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/node_property.gleam", 14).
?DOC(false).
-spec name(binary()) -> gleam@option:option(binary()).
name(Lexeme) ->
    Name = begin
        _pipe = Lexeme,
        _pipe@1 = gleam@string:drop_start(_pipe, 1),
        gleam@string:trim_end(_pipe@1)
    end,
    case gleam@string:is_empty(Name) of
        true ->
            none;

        false ->
            {some, Name}
    end.

-file("src/yum/yaml/lexer/node_property.gleam", 5).
?DOC(false).
-spec token(binary()) -> gleam@option:option(yum@yaml@token:token()).
token(Lexeme) ->
    case {Lexeme, name(Lexeme)} of
        {<<"&"/utf8, _/binary>>, {some, Anchor}} ->
            {some, {anchor, Anchor}};

        {<<"*"/utf8, _/binary>>, {some, Alias}} ->
            {some, {alias, Alias}};

        {<<"!"/utf8, _/binary>>, {some, Tag}} ->
            {some, {tag, Tag}};

        {_, _} ->
            none
    end.