Sha256: 922dea0403c0da327d6eb8e55d65479ad5a43733941cf74bebe6d8fa084a2bde

Contents?: true

Size: 950 Bytes

Versions: 69

Compression:

Stored size: 950 Bytes

Contents

defmodule Forth do
  @opaque evaluator :: any

  @doc """
  Create a new evaluator.
  """
  @spec new() :: evaluator
  def new() do
  end

  @doc """
  Evaluate an input string, updating the evaluator state.
  """
  @spec eval(evaluator, String.t()) :: evaluator
  def eval(ev, s) do
  end

  @doc """
  Return the current stack as a string with the element on top of the stack
  being the rightmost element in the string.
  """
  @spec format_stack(evaluator) :: String.t()
  def format_stack(ev) do
  end

  defmodule StackUnderflow do
    defexception []
    def message(_), do: "stack underflow"
  end

  defmodule InvalidWord do
    defexception word: nil
    def message(e), do: "invalid word: #{inspect(e.word)}"
  end

  defmodule UnknownWord do
    defexception word: nil
    def message(e), do: "unknown word: #{inspect(e.word)}"
  end

  defmodule DivisionByZero do
    defexception []
    def message(_), do: "division by zero"
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.138 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.137 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.136 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.135 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.134 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.133 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.132 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.131 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.130 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.129 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.128 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.127 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.126 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.125 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.124 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.123 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.122 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.121 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.120 tracks/elixir/exercises/forth/forth.exs