Esperanto.Walker (esperanto v0.1.0)

Walker is used to go through input couting line and columns. Every parser is responsible to walk and leave the walker in the state he can continue

Link to this section Summary

Functions

Consume the current walk input

Start the walker by split it in input and rest

Walk through next input

Prevents walker from go fetch more content with the rest matches the barrier until the barrier is destroyed

Link to this section Types

Specs

t() :: %Esperanto.Walker{
  barriered: String.t(),
  barriers: list(),
  column: integer(),
  input: String.t(),
  line: integer(),
  rest: String.t() | atom()
}

Link to this section Functions

Link to this function

consume_input(walker, length \\ 0)

Specs

consume_input(t(), length :: integer()) :: t()

Consume the current walk input

Examples

iex> Esperanto.Walker.consume_input(Esperanto.Walker.start("abc"))
%Esperanto.Walker{input: "", rest: "bc", column: 1}
Link to this function

consume_input_matching_regex(walker, regex)

Link to this function

destroy_barrier(walker)

Specs

destroy_barrier(t()) :: t()
Link to this function

increment_line_and_column(input, line, column)

Link to this function

is_barried(walker)

Specs

is_barried(t()) :: boolean()

Specs

start(String.t()) :: t()

Start the walker by split it in input and rest

Examples

iex> Esperanto.Walker.start("abc")
%Esperanto.Walker{input: "a", rest: "bc"}

iex> Esperanto.Walker.start("")
%Esperanto.Walker{input: "", rest: ""}

iex> Esperanto.Walker.start("a")
%Esperanto.Walker{input: "a", rest: ""}
Link to this function

strip_from_regex(input, regex)

Specs

walk(t()) :: t()

Walk through next input

Examples

iex>
Esperanto.Walker.start("abc") |> Esperanto.Walker.walk()
%Esperanto.Walker{input: "ab", rest: "c", column: 2}

iex> Esperanto.Walker.start("a\nc") |> Esperanto.Walker.walk()
%Esperanto.Walker{input: "a\n", rest: "c", column: 1, line: 2}
Link to this function

walk_until(walker, regex)

Link to this function

with_barrier(walker, barrier)

Specs

with_barrier(t(), any()) :: t()

Prevents walker from go fetch more content with the rest matches the barrier until the barrier is destroyed