The very first toy language I wrote for studying the essence of programing language.
JCScheme = Jiacai's Scheme 😊
JCScheme use S-expression internally to represent AST like any other Scheme.
FYI, diagram below is the S-expression
of (+ 1 2 (* 3 4))
behind SExpression.java
.
As for evaluating code, JCScheme models after eval-apply cycle described in SICP 4.1
More explanations can be found in my Chinese blog 《我的第一个玩具语言 JCScheme 问世了》。
git clone git@github.com:jiacai2050/JCScheme.git
cd JCScheme; mvn clean package
java -jar target/JCScheme-*.jar
You can install rlwrap
to support line editing, persistent history and completion.
# ubuntu
sudo apt-get install rlwrap
# centos
sudo yum install rlwrap
# Mac
brew install rlwrap # for Homebrew
port install rlwrap # for MacPorts
Then, run JCScheme like this
rlwrap java -jar target/JCScheme-*.jar
- datatype
number
bool
string
pair
list
function
- builtin keywords
if
def
lambda
- builtin functions
bool
:and
、or
、not
number
:+
、-
、*
、/
、>
、<
、=
pair/list
:cons
、car
、cdr
、list
、null?
string
:str=?
、other
:print
Code snippets can be found in ChangeLog
- function application using normal order. Done at 2016-03-05, details can be found at this branch
MIT License © Jiacai Liu