* Add map builtin * Rename ensure_length macro * Update documentation * Update map function * Rename map to mapcar * Add modulo to calculator * Add division, modulo, and exponential to lisp * Add type to built in functions * Add string comparisons * Update atom function * Add basic load function * Update load to parse multiple expressions * Escape quote in string display * Move print definition * Rename read-file to read * Simplify mapcar implementation * Update tests * Add comment and test * Add standard library * Add lib to install * Refactor eval * Refactor eq * Refactor eval with ensure macros * Add more tests * Redefine primitives * Move primitives to /ini/lisp/core.lsp * Update install file * Refactor eval * Create /ini/lisp
1.5 KiB
MOROS Lisp
A minimalist Lisp interpreter is available in MOROS to extend the capabilities of the Shell.
It started from Risp and was extended to include the seven primitive operators and the two special forms of John McCarthy's paper "Recursive Functions of Symbolic Expressions and Their Computation by Machine" (1960) and "The Roots of Lisp" (2002) by Paul Graham.
MOROS Lisp dialect is also inspired by Scheme and Clojure.
In version 0.2.0 the whole implementation was refactored and the parser was rewritten to use Nom. This allowed the addition of strings to the language and reading from the filesystem.
Seven Primitive Operators
quote
(with the'
syntax)atom
(aliased toatom?
)eq
(aliased toeq?
)car
(aliased tofirst
)cdr
(aliased torest
)cons
cond
Two Special Forms
label
(aliased todef
)lambda
(aliased tofn
)
Additional Builtins
defun
(aliased todefn
)mapcar
(aliased tomap
)print
read-file
lines
parse
Usage
The interpreter can be invoked from the shell:
> lisp
MOROS Lisp v0.1.0
> (+ 1 2)
3
> (exit)
And it can execute a file. For example a file located in /tmp/fibonacci.lsp
with the following content:
(label fib
(lambda (n)
(cond
((< n 2) n)
(true (+ (fib (- n 1)) (fib (- n 2)))))))
(print (fib 6))
Would produce the following output:
> lisp /tmp/fibonacci.lsp
8