- Hash tag on SNS:
#PureLISP_sh - Docker image:
docker run --rm -it ytaki0801/plsh - PureLISP.js: JavaScript version of PureLISP.sh
- Kilo-PureLISP: Kilo with C version of PureLISP.sh
This software is a Pure LISP interpreter written in shell script conformed to POSIX shell, inspired from John McCarthy's 1960 paper, Paul Graham's Common Lisp implementation, Lispkit Lisp, MIT's Structure and Interpretation of Computer Programs, Peter Norvig's Lispy, and The Julia Programming Language's femtolisp/tiny
- To use in education and research of basic LISP language processing easily
- To use in ALL computer environments by running on a POSIX-conformant shell
Run the script to use REPL, like the following on busybox-w32 in a Command Prompt of Windows 10. You must type a blank line after input of LISP codes to eval.
C:\Users\TAKIZAWA Yozo\busybox>busybox.exe sh PureLISP.sh
S> (def reduce
(lambda (f L i)
(cond ((eq L nil) i)
(t (f (car L) (reduce f (cdr L) i))))))
reduce
S> (reduce cons '(a b c) '(d e f g))
(a b c d e f g)
S> (def rappend (lambda (x y) (reduce cons x y)))
rappend
S> (reduce rappend '((a b) (c d e) (f) (g h i)) '())
(a b c d e f g h i)
S> exit
C:\Users\TAKIZAWA Yozo\busybox>
Or, you can send a text file of LISP codes to PureLISP.sh with "-snl" or "-sl" option, prompt suppression mode, via redirection in a shell interpreter.
C:\Users\TAKIZAWA Yozo\busybox>busybox.exe sh
~/busybox $ cat examples/closure-stream.plsh
(def make-linear
(lambda (x)
(cons x (lambda () (make-linear (cons 'n x))))))
(def s (make-linear nil))
(car s)
(car ((cdr s)))
(car ((cdr ((cdr s)))))
(car ((cdr ((cdr ((cdr s)))))))
(car ((cdr ((cdr ((cdr ((cdr s)))))))))
(car ((cdr ((cdr ((cdr ((cdr ((cdr s)))))))))))
exit
~/busybox $ sh PureLISP.sh -snl < examples/closure-stream.plsh
make-linear
s
()
(n)
(n n)
(n n n)
(n n n n)
(n n n n n)
~/busybox $ exit
C:\Users\TAKIZAWA Yozo\busybox>
You can also try REPL by using Docker image created from Busybox base image.
$ docker run --rm -it ytaki0801/plsh
S> (def reverse-append
(lambda (x y)
(cond ((eq x nil) y)
(t (reverse-append
(cdr x)
(cons (car x) y))))))
reverse-append
S> (reverse-append '(a b c) '(x y z))
(c b a x y z)
S> (def reverse-list
(lambda (x)
(reverse-append x nil)))
reverse-list
S> (reverse-list '(a b c d e))
(e d c b a)
S> (def append-list
(lambda (x y)
(reverse-append (reverse-list x) y)))
append-list
S> (append-list '(a b c) '(x y z))
(a b c x y z)
S> exit
$
-
Built-in functions in Pure LISP:
cons,car,cdr,atom,eq -
Special forms in Pure LISP:
quote,condand lexically scopedlambda -
Special form not in PureLISP:
defto bind variables in global environment -
Special form not in Pure LISP:
macroto do meta-programming -
Built-in function not in Pure LISP:
lengthto treat lists as numbers -
Simple REPL with
exitcommand, comment notation;and the following exec options- default: prompt and pre-loading init file
init.plshin the current directory -snlor-s: no prompt and no pre-loading init file-sl: no prompt and pre-loading init file-nl: prompt and no pre-loading init file
- default: prompt and pre-loading init file
See init.plsh and codes in examples directory for details.
(FYI, firstly implemented referring to a John McCarthy's Original Lisp evaluator but now a SICP's one)
- Conscells are firstly implemented to easy to program as a metacircular evaluator
- Pseudo-Array and Stack implementation by using global variables
- Using pattern-matching fully, to do S-expression lexical analysis especially
- Much more comments in the source code
The codes in this repository are licensed under CC0, Creative Commons Zero v1.0 Universal

