Minipeg.Parsers.LispyParser (Minipeg v0.7.6)

View Source

Parses s-expressions (lispy) The syntax is very simple

s_exp:

----> ( `opening_literal`) ---------------------------------------------+-------------> ( `closing_literal` ) ------>

^ | | | | +---------+ |

                             +--- (whitespace) <--- | element | <-------+

+---------+

element:

  string | integer | name | s_exp

opening_literal defaults to ( and closing literal defaults to ), of course

Summary

Functions

Like the s_exp_parser but custom parsers can be added for specific element parsers that can be added with priority over the default element parsers or replace them.

parses a string, integer, name (atom) or s-exp

Parses a name which is actually any non digit starting printable character sequence

Parses an s-expression according to the schema above

Types

ast_list_t()

@type ast_list_t() :: [ast_t()]

ast_t()

@type ast_t() :: any()

atoms()

@type atoms() :: [atom()]

binaries()

@type binaries() :: [binary()]

binary?()

@type binary?() :: maybe(binary())

char_set_spec_t()

@type char_set_spec_t() :: maybe(binary() | list())

char_set_t()

@type char_set_t() :: [binary()] | binary()

either(success_t, error_t)

@type either(success_t, error_t) :: {:ok, success_t} | {:error, error_t}

input_t()

@type input_t() :: binary() | [binary()] | Minipeg.Input.t()

maybe(t)

@type maybe(t) :: nil | t

name_t()

@type name_t() :: atom() | binary()

name_t?()

@type name_t?() :: maybe(name_t())

parser_function_t()

@type parser_function_t() :: (Minipeg.Input.t(), Minipeg.Cache.t(), binary() ->
                          result_t())

position_t()

@type position_t() :: {pos_integer(), pos_integer()}

result_t()

@type result_t() :: Minipeg.Failure.t() | Minipeg.Ignore.t() | Minipeg.Success.t()

satisfier_result_t()

@type satisfier_result_t() :: either(any(), binary())

satisfier_t()

@type satisfier_t() :: (any() -> satisfier_result_t())

str_or_count_t()

@type str_or_count_t() :: binary() | non_neg_integer()

token1_comp_t()

@type token1_comp_t() ::
  {atom(), token_parse_part2()}
  | {atom(), token_parse_part2(), (binary() -> any())}

token1_spec_t()

@type token1_spec_t() ::
  {atom(), token_parse_part1()}
  | {atom(), token_parse_part1(), (binary() -> any())}

token_comp_t()

@type token_comp_t() :: [token1_comp_t()]

token_spec_t()

@type token_spec_t() :: [token1_spec_t()]

Functions

customized_s_exp_parser(name \\ nil, options \\ [])

@spec customized_s_exp_parser(binary?(), Keyword.t()) :: Minipeg.Parser.t()

Like the s_exp_parser but custom parsers can be added for specific element parsers that can be added with priority over the default element parsers or replace them.

And we can also configure the already configurable parts of the s_exp_parser via the keywords, which are:

opening_literal: defaulting to "(" closing_literal: defaulting to ")" element_parsers: list of parsers (which are parsed before the default elements parser) replace_default: defaults to false, but if set to true the default element parsers are not used

element_parser(name \\ nil)

@spec element_parser(binary?()) :: Minipeg.Parser.t()

parses a string, integer, name (atom) or s-exp

name_parser(name \\ nil)

@spec name_parser(binary?()) :: Minipeg.Parser.t()

Parses a name which is actually any non digit starting printable character sequence

s_exp_parser(name \\ nil, opening_literal \\ "(", closing_literal \\ ")")

@spec s_exp_parser(binary?(), binary(), binary()) :: Minipeg.Parser.t()

Parses an s-expression according to the schema above