All Projects → ytaki0801 → PureLISP.sh

ytaki0801 / PureLISP.sh

Licence: CC0-1.0 license
A Pure LISP interpreter written in shell script conformed to POSIX shell

Programming Languages

shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to PureLISP.sh

smoosh
The Symbolic, Mechanized, Observable, Operational SHell: an executable formalization of the POSIX shell standard.
Stars: ✭ 86 (+186.67%)
Mutual labels:  posix-sh, posix-shell
lispkit
FUNCTIONAL PROGRAMMING: Application and Implementation, Peter Henderson, ISBN 0-13-331579-7
Stars: ✭ 33 (+10%)
Mutual labels:  lisp-interpreter
Tox
misc parsers in rust
Stars: ✭ 40 (+33.33%)
Mutual labels:  lisp-interpreter
Wart
An experimental, small, readable Lisp with thorough unit tests and extensible functions/macros.
Stars: ✭ 127 (+323.33%)
Mutual labels:  lisp-interpreter
Mumbler
My experimental programming language using Truffle
Stars: ✭ 100 (+233.33%)
Mutual labels:  lisp-interpreter
G Fu
Lisp 2 Go
Stars: ✭ 243 (+710%)
Mutual labels:  lisp-interpreter
Yascm
Yet Another Scheme Interpreter using flex and bison
Stars: ✭ 36 (+20%)
Mutual labels:  lisp-interpreter
abap scheme
ABAP Scheme
Stars: ✭ 13 (-56.67%)
Mutual labels:  lisp-interpreter
zapish
zapish - Zabbix API SHell binding
Stars: ✭ 28 (-6.67%)
Mutual labels:  posix-sh
Lips
Scheme based powerful lisp interpreter written in JavaScript
Stars: ✭ 120 (+300%)
Mutual labels:  lisp-interpreter
Lice
A multi-paradigm programming language running on JVM
Stars: ✭ 120 (+300%)
Mutual labels:  lisp-interpreter
Golisp
Lisp Interpreter
Stars: ✭ 107 (+256.67%)
Mutual labels:  lisp-interpreter
distrobox
Use any linux distribution inside your terminal. Enable both backward and forward compatibility with software and freedom to use whatever distribution you’re more comfortable with. Mirror available at: https://gitlab.com/89luca89/distrobox
Stars: ✭ 4,371 (+14470%)
Mutual labels:  posix-sh
Mal Zh
The Make-A-Lisp Process 中文翻译,如何写一个Lisp解释器
Stars: ✭ 100 (+233.33%)
Mutual labels:  lisp-interpreter
esh
Simple templating engine based on shell.
Stars: ✭ 165 (+450%)
Mutual labels:  posix-sh
Seax
A VM-based runtime environment for functional programming languages
Stars: ✭ 36 (+20%)
Mutual labels:  lisp-interpreter
Cisp
A Common Lisp Interpreter Built in COBOL
Stars: ✭ 120 (+300%)
Mutual labels:  lisp-interpreter
Esp Lisp
Beta: A small fast lisp interpeter for a ESP8266 as alternative to lua on the nodemcu.
Stars: ✭ 236 (+686.67%)
Mutual labels:  lisp-interpreter
genyris
Genyris presents a new programming paradigm. Objects can belong to multiple classes independent from construction allowing data to be classified into types after creation.
Stars: ✭ 14 (-53.33%)
Mutual labels:  lisp-interpreter
CoCoC
C development system for (Nitr)OS9/6x09, with source
Stars: ✭ 22 (-26.67%)
Mutual labels:  lisp-interpreter

CC0

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

demo

Purpose of this software

  • 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

BusyBox_ash NetBSD_sh dash NetBSD_ksh_(pdksh) ksh93%2frksh93 mksh oksh Bash yash bosh%2fpbosh

How to use

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

$ 

LISP Specification in this software

  • Built-in functions in Pure LISP: cons, car, cdr, atom, eq

  • Special forms in Pure LISP: quote, cond and lexically scoped lambda

  • Special form not in PureLISP: def to bind variables in global environment

  • Special form not in Pure LISP: macro to do meta-programming

  • Built-in function not in Pure LISP: length to treat lists as numbers

  • Simple REPL with exit command, comment notation ; and the following exec options

    • default: prompt and pre-loading init file init.plsh in the current directory
    • -snl or -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

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)

Shell Programming in this software

  • 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

Bugs and TODO

  • Much more comments in the source code

License

The codes in this repository are licensed under CC0, Creative Commons Zero v1.0 Universal

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].