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.180 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.179 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.178 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.177 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.176 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.175 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.174 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.173 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.172 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.171 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.170 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.169 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.167 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.166 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.165 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.164 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.163 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.162 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.161 tracks/elixir/exercises/forth/forth.exs
trackler-2.2.1.160 tracks/elixir/exercises/forth/forth.exs