Ergo.Context.next_char
You're seeing just the function
next_char
, go back to Ergo.Context module for more information.
Link to this function
next_char(context)
Reads the next character from the input
of the passed in Context
.
If the input
is empty returns status: {:error, :unexpected_eoi}
.
Otherwise returns a new Context
setting ast
to the character read and incrementing positional variables such as index
, line
, and column
appropriately.
Examples
iex> context = Context.next_char(Context.new("")) iex> assert %Context{status: {:error, [{:unexpected_eoi, {1, 1}, "Unexpected end of input"}] }} = context
iex> context = Context.next_char(Context.new("Hello World")) iex> assert %Context{status: :ok, input: "ello World", ast: ?H, index: 1, line: 1, col: 2} = context