Lispex v0.1.0 Lispex View Source

Lisp parser and interpreter written in Elixir. Uses the Scheme flavour of Lisp.

Link to this section Summary

Functions

Takes in the Scheme source code and the current execution Environment and pipes the source code through Parse.parse/1 and Eval.eval/2

REPL - Read Evaluate Print Loop for the Scheme code. Takes input from the user, pipes the output through interpret/2 and scheme_string/1 and finally prints it on console

Converts the output from interpret/2 to a Scheme style. Replaces ‘[‘ and ‘]’ with ‘(‘ and ‘)’

Link to this section Functions

Takes in the Scheme source code and the current execution Environment and pipes the source code through Parse.parse/1 and Eval.eval/2.

Returns Tuple of output and an environment

Parameters

  • program : String Scheme source code
  • env : Map The current execution environment. Find more here Env.

Example

iex> Lispex.interpret("(begin (define a 5) (* a 4))", Env.new_env())
{5, %{..}}

REPL - Read Evaluate Print Loop for the Scheme code. Takes input from the user, pipes the output through interpret/2 and scheme_string/1 and finally prints it on console.

Example

iex> Lispex.repl
lispex> (begin (define a 4) (* a 5))
20
lispex> (if a<3 (* a 4) (* a 6))
24

Converts the output from interpret/2 to a Scheme style. Replaces ‘[‘ and ‘]’ with ‘(‘ and ‘)’.

Returns String

Example

iex> Lispex.scheme_string([1 2 [3 4]])
(1 2 (3 4))