Welcome to
*****************************************
#### ### ### # # #### # # ####
# # # # # # ## ## #
# #### # ##### #### # # # ####
# # # # # # # # #
#### ### ### # # #### # # ####
*****************************************
This is my implementation of a Scheme interpreter which has been developed for the lecture Design und Implementierung fortgeschrittener Programmiersprachen offered by Claus Gittinger at Stuttgart Media University (course of studies: Computer Science and Media). On the master branch, you will find a version that has been implemented in classical style, whereas the cont_passing branch offers tail call optimization in the form of continuation passing style.
Current branch: master (continuation passing disabled)
Currently, there're several ways to get JScheme up and running on your local machine. Before you can start using your preferred method, make sure you performed the following steps:
JScheme uses Maven 3 for build management. Ensure it's installed on your machine
and MVN_HOME
is set properly, pointing to the installation directory.
Checkout the latest version of JScheme:
$ git clone https://github.com/PaddySmalls/JScheme
Make sure Maven has been added to your PATH and run the following goals:
$ mvn compile exec:java
Instead of starting JScheme using Maven directly, you can also build a JAR and run it:
$ make
$ cd target/
$ java -jar JScheme-1.0-jar-with-dependencies.jar
Alternatively, you can also build a Docker image and launch JScheme from a Docker container. That approach requires Docker to be installed on your machine:
$ make docker
$ docker run -i -t pkleindienst/jscheme
Running JScheme from Docker hub is even more easier and preserves you from having to install and setup any other tooling except Docker:
$ docker run -i -t pkleindienst/jscheme
JScheme ships with a wide range of built-in data types:
- Strings
- Symbols
- Integers
- Floats
- Fractions
- Booleans
- Functions
- Lists
Special types:
- Void
- Nil
A great set of pre-defined functions are available out of the box.
Addition:
>> (+ 1 2)
=> 3
Subtraction:
>> (- 3 2.0)
=> 1.0
Multiplication:
>> (* 1 2)
=> 2
Division:
>> (/ 1 2)
=> 1/2
Absolute value:
>> (abs -42)
=> 42
Create lists (1):
>> (cons 1 (cons (2 nil)))
=> '(1 2)
Create lists (2):
>> '(1 2)
=> '(1 2)
Get CAR of list:
>> (car '(1 2))
=> 1
Get CDR of list:
>> (cdr '(1 2))
=> '(2)
Check if any Scheme object is a list:
>> (cons? '(1 2))
=> #t
>> (cons? "not a list")
=> #f
>> (eq? 1 1)
=> #t
>> (eq? "not" "equal")
=> #f
>> (define foo 42)
>> foo
=> 42
>> (define (add1 x) (+ x 1))
>> add1
=> <procedure:add1>
>> (add1 2)
=> 3
>> (define (make-adder x) (lambda (y) (+ x y)))
>> (define add5 (make-adder 5))
>> add5
=> <procedure: anonymous lambda>
>> (add5 1)
=> 6
>> (if #t "true" "false")
=> "true"
>> (if "" "true" "false")
=> "false"
>> (quote (+ 1 2 3 4 5))
=> '(+ 1 2 3 4 5)
>> 'foobar
=> foobar