/mscheme

simple scheme intepreter implemented by java8

Primary LanguageJavaGNU General Public License v3.0GPL-3.0

mscheme

My first scheme intepreter. This toy is written by java

Concepts

S-expression

mscheme use S-expression to represent AST

For exampple, the Sexpression of (* 2 (+ 3 4)) behind SExpression.java can be shown as:

AST_demo

eval-apply cycle

eval-apply cycle is described in SICP 4.1

eval-apply cycle

More details can be found here 元求值器

Install

git clone https://github.com/klose911/mscheme.git
cd mscheme
mvn clean package
java -jar target/mscheme-exec.jar

Features

  1. datatype
  • number
  • bool
  • string
  • pair
  • list
  • procedure
  1. special form
  • quote
  • define
  • set!
  • if
  • lambda
  • begin
  1. primitive procedures
  • number: +, -, *, /, >, <, =
  • pair/list: cons, car, cdr, list, null?
  • bool: and, or, not, eq
  • other: apply, print

TODO

  1. support begin expressions
  2. support cond expressions
  3. support continuation mechanism
  4. support syntax macros

Known Issues

  1. arithmetic overflow problem
  2. input with newline character will not be treated as a single expression
  3. lambda expression must be used to define procedure, like (define add (lambda (x y) (+ x y)) The format of (define (add x y) (+ x y)) should be supported
  4. split error for strings contains empty spaces