All Projects β†’ jin β†’ scheme.ml

jin / scheme.ml

Licence: other
Scheme (R6RS subset) interpreter written in OCaml

Programming Languages

ocaml
1615 projects
Starlark
911 projects
Makefile
30231 projects
Standard ML
205 projects

Projects that are alternatives of or similar to scheme.ml

bfloader
🧠 Brainfuck IDE and interpreter in 512 bytes. (boot sector)
Stars: ✭ 41 (+192.86%)
Mutual labels:  interpreter
LambdaCore
An interpreted language written in Rust inspired by the Lisp family of languages.
Stars: ✭ 56 (+300%)
Mutual labels:  interpreter
monkey-rs
An interpreter for the Monkey programming language written in Rust
Stars: ✭ 27 (+92.86%)
Mutual labels:  interpreter
RSqueak
A Squeak/Smalltalk VM written in RPython.
Stars: ✭ 78 (+457.14%)
Mutual labels:  interpreter
ol
Otus Lisp (Ol in short) is a purely* functional dialect of Lisp.
Stars: ✭ 157 (+1021.43%)
Mutual labels:  interpreter
nopforth
A dialect of the Forth programming language
Stars: ✭ 22 (+57.14%)
Mutual labels:  interpreter
Garam-Interpreter
"ν›ˆλ―Όμ •μŒμ€ λ””μžμΈμ΄λ‹€" κ°€λžŒμ€ 튜링 μ™„μ „ ν”„λ‘œκ·Έλž˜λ° μ–Έμ–΄μž…λ‹ˆλ‹€.
Stars: ✭ 23 (+64.29%)
Mutual labels:  interpreter
Cosmo
Embeddable scripting language loosely based off of Lua
Stars: ✭ 14 (+0%)
Mutual labels:  interpreter
NPython
(Subset of) Python programming language implemented in Nim
Stars: ✭ 17 (+21.43%)
Mutual labels:  interpreter
Arduino-FVM
Byte Token Threaded Forth Virtual Machine (FVM) for Arduino
Stars: ✭ 35 (+150%)
Mutual labels:  interpreter
pawn-3.2-plus
Pawn scripting language with runtime fixes and improvements
Stars: ✭ 14 (+0%)
Mutual labels:  interpreter
MUA-Interpreter
MUA is a functional language for teaching use in Principles of Programming Languages course.
Stars: ✭ 16 (+14.29%)
Mutual labels:  interpreter
prolog
The only reasonable scripting engine for Go.
Stars: ✭ 408 (+2814.29%)
Mutual labels:  interpreter
xin
Xin (μ‹ /εΏƒ) is a flexible functional programming language with a tiny core, inspired by Lisp and CSP
Stars: ✭ 20 (+42.86%)
Mutual labels:  interpreter
lpp-vita
Lua Player Plus for PSVITA. Documentation on: http://rinnegatamante.github.io/lpp-vita/
Stars: ✭ 149 (+964.29%)
Mutual labels:  interpreter
tiny-lang
tiny-lang β€” A different programming language. Supports a bunch of spoken languages.
Stars: ✭ 26 (+85.71%)
Mutual labels:  interpreter
nj
NJ is a simple script engine in golang with Lua-like syntax.
Stars: ✭ 19 (+35.71%)
Mutual labels:  interpreter
gossa
The Go/Go+ Interpreter
Stars: ✭ 53 (+278.57%)
Mutual labels:  interpreter
fayrant-lang
Simple, interpreted, dynamically-typed programming language
Stars: ✭ 30 (+114.29%)
Mutual labels:  interpreter
g2d
Craft beautiful geometric art using code.
Stars: ✭ 40 (+185.71%)
Mutual labels:  interpreter

Scheme interpreter in OCaml

See test.ml for the set of implemented Scheme syntax.

How it works

scheme> (&& #f #t)
DEBUG: Tokens: [LParen, &&, #f, #t, RParen]
DEBUG: S-Expression: List(Atom(&&) Atom(#f) Atom(#t))
DEBUG: Result: #f
#f

scheme> (if (< 1 2) 4 5)
DEBUG: Tokens: [LParen, Keyword(if), LParen, <, Number(1), Number(2), RParen, Number(4), Number(5), RParen]
DEBUG: S-Expression: List(Atom(if) List(Atom(<) Atom(1) Atom(2)) Atom(4) Atom(5))
DEBUG: Result: 4
4

scheme> (car '(a b c))
DEBUG: Tokens: [LParen, Keyword(car), Quote, LParen, Variable(a), Variable(b), Variable(c), RParen, RParen]
DEBUG: S-Expression: List(Atom(car) List(Atom(') Atom(a) Atom(b) Atom(c)))
DEBUG: Result: a
a

scheme> (cdr (cons 1 '((* 1 2) (if (< 1 2) 3 4))))
DEBUG: Tokens: [LParen, Keyword(cdr), LParen, Keyword(cons), Number(1), Quote, LParen, LParen, Multiply, Number(1), Number(2), RParen, LParen, Keyword(if), LParen, <, Number(1), Number(2), RParen, Number(3), Number(4), RParen, RParen, RParen, RParen]
DEBUG: S-Expression: List(Atom(cdr) List(Atom(cons) Atom(1) List(Atom(') List(Atom(Multiply) Atom(1) Atom(2)) List(Atom(if) List(Atom(<) Atom(1) Atom(2)) Atom(3) Atom(4)))))
DEBUG: Result: (2, 3)
(2, 3)

Building and running

# install dependencies
opam install sedlex alcotest

# Build with either Make or [Bazel](https://bazel.io)

# MAKE
make

# run all examples and diffs output against respective expected output in examples/test
make test

# ----

# Bazel

bazel build //:scheme-bytecode # compiles the binary into bazel-bin/scheme-bytecode

# ----

# start the interpreter
./scheme

# or load a source file
./scheme examples/arithmetic.scm

What's next

In the order of features I want to look into.

  • More separation of eval logic from lexer/parser
  • Binary should accept filenames and not read from STDIN
  • cond
  • Lambdas
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].