A rudimentary Java LISP implementation, based on the language description in the paper "The Roots of Lisp" by Paul Graham. The interpreter was written as a personal exercise to better understand interpreter and compiler construction. Also, LISP has been a subject of personal interest for quite some time, and this project gave an excuse to investigate the topic.
The implemented language only defines two significant constructs, atoms and conses. An atom is, in essence, a string identifier that has no other significance than being an identifier. A cons is a pair of memory cells, CAR and CDR, which may be used to refer to other atoms or conses. A valid program only contains a single expression.
Example:
(
(label subst (lambda (x y z)
(cond
((atom z) (cond
((eq z y) x)
('t z)
))
('t (cons
(subst x y (car z))
(subst x y (cdr z))
))
)
))
(
(label cadr (lambda (x) (car (cdr x))))
(cadr
(subst 'hello_world '2 '(1 2 3))
)
)
)
Clone the repository to a local directory of your choice.
$ git clone https://github.com:emanuelpalm/plisp.git
Use gradle to compile the project into a JAR and generate a default start-up script.
Windows:
> gradlew.bat installApp
Other:
$ ./gradlew installApp
The build results of interest will be in the build/install/plisp
directory, relative to the project root.
Assuming the project has been installed, the current directory is the project root, and the used machine is running a unix-like system, the following command may be used to run the bundled example application:
$ ./build/install/plisp/bin/plisp example.plp
Also, the interpreter contains a rudimentary static analyzer that may be invoked by adding the flag --analyze
when
running. If used, the loaded program is only analyzed. An example of running the analyzer on the example application
would be as follows:
$ ./build/install/plisp/bin/plisp example.plp --analyze