Ergo.Parsers (ergo v0.1.2)
The Parsers module exists to house utility parsers that while they are terminals in the sense that they are not parameterised, they internally make use of parsers from the Combinators module.
Parsers
uint
decimal
digits
Link to this section Summary
Functions
Examples
iex> alias Ergo.Context
iex> import Ergo.Parsers
iex> context = Context.new("234.56")
iex> parser = decimal()
iex> assert %Context{status: :ok, ast: 234.56} = parser.(context)
The digits
parser matches a series of at least one digit and returns an enumeration
of the digits.
The unit
parser matches a series of at least one digit and returns the
integer value of the digits.
Link to this section Functions
Link to this function
decimal()
Examples
iex> alias Ergo.Context
iex> import Ergo.Parsers
iex> context = Context.new("234.56")
iex> parser = decimal()
iex> assert %Context{status: :ok, ast: 234.56} = parser.(context)
Link to this function
digits()
The digits
parser matches a series of at least one digit and returns an enumeration
of the digits.
Examples
iex> alias Ergo.{Context, Parsers}
iex> context = Context.new("2345")
iex> parser = Parsers.digits()
iex> assert %Context{status: :ok, ast: [2, 3, 4, 5]} = parser.(context)
Link to this function
uint()
The unit
parser matches a series of at least one digit and returns the
integer value of the digits.
Examples
iex> alias Ergo.Context
iex> import Ergo.Parsers
iex> context = Context.new("2345")
iex> parser = uint()
iex> parser.(context)
%Context{status: :ok, ast: 2345, char: ?5, index: 4, col: 5}