Yarnspinnex.Interpreter (yarnspinnex v0.3.0)

Copy Markdown View Source

Advances a Yarnspinnex.Cursor through a Yarnspinnex.Script one event at a time. Statements with nothing to show the host (<<set>>, <<declare>>, <<if>>, <<jump>>) are absorbed inside step/3, so every result is a line, a command, an option group, or the end.

Summary

Functions

Checks that cursor points at a valid position in this version of script.

Picks the option at index from the option group the cursor is paused on.

Runs from cursor until the next line, command, option group, or end of the script.

Types

choose_error()

@type choose_error() :: :no_options | :invalid_option | :option_disabled

cursor_error()

@type cursor_error() :: :stale_script | :unknown_node | :invalid_position

event()

@type event() ::
  {:line, Yarnspinnex.Line.t(), Yarnspinnex.Cursor.t()}
  | {:command, String.t(), [term()], Yarnspinnex.Cursor.t()}
  | {:options, [Yarnspinnex.Option.t()], Yarnspinnex.Cursor.t()}
  | {:done, Yarnspinnex.Cursor.t()}

Functions

check_cursor(script, cursor)

@spec check_cursor(Yarnspinnex.Script.t(), Yarnspinnex.Cursor.t()) ::
  :ok | {:error, cursor_error()}

Checks that cursor points at a valid position in this version of script.

choose(script, cursor, index, context \\ %{})

Picks the option at index from the option group the cursor is paused on.

step(script, cursor, context \\ %{})

Runs from cursor until the next line, command, option group, or end of the script.