View Source Minipeg.Combinators (Minipeg v0.1.4)

All public functions in this module take a parser and potentially more parameters and return a new parser

Link to this section Summary

Functions

Just parses with parser but displays, input and result to stderr

Unwrapps a wrapped parser and parses with it

Applies a parser as many times as possible, can use min_count (defaulting to 0) to fail unless the parser could parse min_count times

Succeeds if parser succeeds, but maps the ast with mapper_fun. If parser fails, it just fails

Returns a parser that only succeeds if the original parser succeeds and the satisfier function that is called with the ast of the original result returns {:ok, value}. It also changes the original ast with value in the final result.

Looks into the cache (for this parsing position) before parsing, if no result found parses and puts the result into the cache (for this parsing position)

Link to this section Types

@type ast_t() :: any()
@type binary?() :: maybe(binary())
@type char_set_t() :: [binary()] | binary()
Link to this type

either(success_t, error_t)

View Source
@type either(success_t, error_t) :: {:ok, success_t} | {:error, error_t}
@type input_t() :: binary() | [binary()] | Minipeg.Input.t()
@type maybe(t) :: nil | t
@type parser_function_t() ::
  (Minipeg.Input.t(), Minipeg.Cache.t(), binary() -> result_t())
@type result_t() :: Minipeg.Failure.t() | Minipeg.Success.t()
@type satisfier_result_t() :: either(any(), binary())
@type satisfier_t() :: (any() -> satisfier_result_t())
@type str_or_count_t() :: binary() | non_neg_integer()

Link to this section Functions

Link to this function

debug(parser, name \\ nil)

View Source
@spec debug(Minipeg.Parser.t(), binary?()) :: Minipeg.Parser.t()

Just parses with parser but displays, input and result to stderr

Link to this function

lazy(wrapped_parser, name \\ nil)

View Source
@spec lazy(Minipeg.Parser.t(), binary?()) :: Minipeg.Parser.t()

Unwrapps a wrapped parser and parses with it

Link to this function

many(parser, name \\ nil, min_count \\ 0)

View Source

Applies a parser as many times as possible, can use min_count (defaulting to 0) to fail unless the parser could parse min_count times

Link to this function

map(parser, mapper_fun, name \\ nil)

View Source
@spec map(Minipeg.Parser.t(), (ast_t() -> ast_t()), maybe(binary())) ::
  Minipeg.Parser.t()

Succeeds if parser succeeds, but maps the ast with mapper_fun. If parser fails, it just fails

Link to this function

maybe(parser, name \\ nil)

View Source
@spec maybe(Minipeg.Parser.t(), binary?()) :: Minipeg.Parser.t()
Link to this function

satisfy(parser, satisfier, name \\ nil)

View Source

Returns a parser that only succeeds if the original parser succeeds and the satisfier function that is called with the ast of the original result returns {:ok, value}. It also changes the original ast with value in the final result.

Link to this function

savepoint(parser, sp_name \\ nil, name \\ nil)

View Source
@spec savepoint(Minipeg.Parser.t(), binary?(), binary?()) :: Minipeg.Parser.t()

Looks into the cache (for this parsing position) before parsing, if no result found parses and puts the result into the cache (for this parsing position)

Link to this function

select(parsers, name \\ nil)

View Source
@spec select([Minipeg.Parser.t()], maybe(binary())) :: Minipeg.Parser.t()
Link to this function

sequence(parsers, name \\ nil)

View Source
@spec sequence([Minipeg.Parser.t()], binary?()) :: Minipeg.Parser.t()