Skip to main content

src/tomlet@ast.erl

-module(tomlet@ast).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/tomlet/ast.gleam").
-export_type([trivia/0, table/0, header/0, header_kind/0, entry/0, key/0, key_segment/0, value/0, special_float/0, string_style/0, array_item/0, inline_table_entry/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).

-type trivia() :: {trivia, binary()}.

-type table() :: {table, list(entry()), gleam@option:option(header())}.

-type header() :: {header, key(), header_kind(), trivia()}.

-type header_kind() :: standard_table | array_of_tables_header.

-type entry() :: {key_value, trivia(), key(), value(), trivia()} |
    {table_header, header()} |
    {comment, binary()} |
    blank_line.

-type key() :: {key, list(key_segment())}.

-type key_segment() :: {bare_key_segment, binary()} |
    {quoted_key_segment, binary(), binary()}.

-type value() :: {int, integer(), binary()} |
    {float, float(), binary()} |
    {special_float, special_float(), binary()} |
    {bool, boolean(), binary()} |
    {string, binary(), string_style(), binary()} |
    {date, binary()} |
    {time, binary()} |
    {date_time, binary()} |
    {array, list(array_item()), binary()} |
    {inline_table, list(inline_table_entry()), binary()} |
    {array_of_tables, list(table())}.

-type special_float() :: positive_infinity | negative_infinity | not_a_number.

-type string_style() :: basic_string |
    literal_string |
    multi_basic_string |
    multi_literal_string.

-type array_item() :: {array_item, trivia(), value(), trivia()}.

-type inline_table_entry() :: {inline_table_entry,
        trivia(),
        key(),
        value(),
        trivia()}.