View Source Minipeg.Combinators (Minipeg v0.4.1)
All public functions in this module take a parser and potentially more parameters and return a new parser
Summary
Functions
Just parses with parser
but displays, input and result to stderr
Parsers a string that would be parsed by parser but ignoring leading whitespace, if you also want to
ignore whitespace after the parsed string use tokenized
Unwrapps a wrapped parser and parses with it
Parses a list defined by an element_parser
and a seperator_parser
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
parses iff parser
parses then maps the ast to a string with IO.chardata_to_string/1
The ast must therefore be of type IO data
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)
Consume chars until parser
parses and return them as parsed ast, fails if parser never succeeds
can add the delimiter to the ast or leave it on the input stream
Types
@type ast_list_t() :: [ast_t()]
@type ast_t() :: any()
@type binaries() :: [binary()]
@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_t() :: (any() -> satisfier_result_t())
@type str_or_count_t() :: binary() | non_neg_integer()
@type wrapped_parser_t() :: (-> Minipeg.Parser.t())
Functions
@spec debug(Minipeg.Parser.t(), binary?()) :: Minipeg.Parser.t()
Just parses with parser
but displays, input and result to stderr
@spec ignore_ws(Minipeg.Parser.t(), binary?(), boolean()) :: Minipeg.Parser.t()
Parsers a string that would be parsed by parser but ignoring leading whitespace, if you also want to
ignore whitespace after the parsed string use tokenized
in_between_parser(ignored_start_parser, inside_parser, ignored_end_parser, name \\ nil)
View Source@spec in_between_parser( Minipeg.Parser.t(), Minipeg.Parser.t(), Minipeg.Parser.t(), binary?() ) :: Minipeg.Parser.t()
@spec lazy(wrapped_parser_t(), binary?()) :: Minipeg.Parser.t()
Unwrapps a wrapped parser and parses with it
list_parser(element_parser, seperator_parser, name \\ nil, min_count \\ 0)
View Source@spec list_parser( Minipeg.Parser.t(), Minipeg.Parser.t(), binary?(), non_neg_integer() ) :: Minipeg.Parser.t()
Parses a list defined by an element_parser
and a seperator_parser
@spec many(Minipeg.Parser.t(), maybe(binary()), non_neg_integer()) :: Minipeg.Parser.t()
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
@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
@spec map_to_string(Minipeg.Parser.t(), binary?()) :: Minipeg.Parser.t()
parses iff parser
parses then maps the ast to a string with IO.chardata_to_string/1
The ast must therefore be of type IO data
@spec maybe(Minipeg.Parser.t(), binary?()) :: Minipeg.Parser.t()
@spec satisfy(Minipeg.Parser.t(), satisfier_t(), binary?()) :: Minipeg.Parser.t()
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.
@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)
@spec select([Minipeg.Parser.t()], maybe(binary())) :: Minipeg.Parser.t()
@spec sequence([Minipeg.Parser.t()], binary?()) :: Minipeg.Parser.t()
@spec tokenize(Minipeg.Parser.t()) :: Minipeg.Parser.t()
@spec upto_parser_parser(Minipeg.Parser.t(), binary?(), upto_behavior_t()) :: Minipeg.Parser.t()
Consume chars until parser
parses and return them as parsed ast, fails if parser never succeeds
can add the delimiter to the ast or leave it on the input stream