Ergo.Parser (ergo v0.3.5)

Ergo.Parser contains the Parser record type. Ergo parsers are anonymous functions but we embed them in a Parser record that can hold arbitrary metadata. The primary use for the metadata is the storage of debugging information.

Link to this section Summary

Functions

call/2 invokes the specified parser by calling its parsing function with the specified context having first reset the context status.

description/1 returns the description metadata for the parser.

new/2 creates a new Parser from the given parsing function and with the specified metadata.

Link to this section Functions

Link to this function

call(parser, ctx)

call/2 invokes the specified parser by calling its parsing function with the specified context having first reset the context status.

Link to this function

description(parser)

description/1 returns the description metadata for the parser.

Examples

iex> parser = Parser.new(identity, %{description: "Not a parser at all"})
iex> Ergo.Parser.description(parser)
"Not a parser at all"
Link to this function

new(parser_fn, meta \\ [])

new/2 creates a new Parser from the given parsing function and with the specified metadata.