Ergo.Terminals.digit

You're seeing just the function digit, go back to Ergo.Terminals module for more information.

The digit/0 parser accepts a character in the range of 0..9

Examples

iex> alias Ergo.Context
iex> import Ergo.Terminals
iex> parser = digit()
iex> assert %Context{status: :ok, ast: ?0, input: "000", index: 1, line: 1, col: 2} = Ergo.parse(parser, "0000")

iex> alias Ergo.Context
iex> import Ergo.Terminals
iex> import Ergo.Terminals
iex> parser = digit()
iex> assert %Context{status: {:error, [{:unexpected_char, "Expected: 0..9 Actual: A"}]}, input: "AAAA", index: 0, line: 1, col: 1} = Ergo.parse(parser, "AAAA")

iex> alias Ergo.{Context, Parser}
iex> import Ergo.Terminals
iex> context = Context.new(&Ergo.Parser.call/2, "")
iex> parser = digit()
iex> assert %Context{status: {:error, [{:unexpected_eoi, "Unexpected end of input"}]}, input: "", index: 0, line: 1, col: 1} = Parser.invoke(parser, context)