Ergo.Combinators.optional

You're seeing just the function optional, go back to Ergo.Combinators module for more information.
Link to this function

optional(parser, opts \\ [])

Examples

iex> alias Ergo.Context
iex> import Ergo.{Terminals, Combinators}
iex> context = Ergo.parse(optional(literal("Hello")), "Hello World")
iex> assert %Context{status: :ok, ast: "Hello", input: " World", index: 5, col: 6, char: ?o} = context

In this example we deliberately ensure that the Context ast is not nil
iex> alias Ergo.{Context, Parser}
iex> import Ergo.{Terminals, Combinators}
iex> context = %{Context.new(" World") | ast: []}
iex> parser = optional(literal("Hello"))
iex> new_context = Parser.call(parser, context)
iex> assert %Context{status: :ok, ast: nil, input: " World", index: 0, col: 1, char: 0} = new_context