Scheme implementation in C++ that depends on C++17s new
std::variant
and std::optional
.
Heavily inspired by Write Yourself a Scheme in 48 Hours.
Uses Haskell-like Maybe
and Either
types.
Tested with gcc 7.2.0 on Linux
git clone --recursive https://github.com/mrsch/CPPScheme.git
- Run
cmake -E chdir build cmake ..
to setup the project - Compile with
cmake --build build
- Run main:
cd bin && ./main
- Run ( non existanst :-( )tests:
cd bin && ./unit_test
- No proper tail recursion
- No tests
- Not all standard procedures implemented
- Only
floats
as numbers - No macros
- Not optimized
- Lots of unnessecary copies
- Haskell like error handling with
Either
type - Scheme values as Sum type with
std::variant
- Should not leak thanks to
std::shared_ptr
- Some standard procedures are implemented directly in Scheme (see
resources/stdlib.scm
)
- Booleans -
#t
and#f
- Numbers -
floats
- Strings
- Vector -
#()
- Lambdas
- Characters -
#\t
- Atoms
- [X] define
- [X] shorthand lambda define
- [X] quote
- [X] lambda
- [X] procedure call
- [X] if
- [X] set!
- [X] cond
- [X] case
- [X] and
- [X] or
- [X] let
- [X] begin
- [ ] do
- [ ] named let
- [ ] delay + force
- [ ] quasiquote
- [X] apply
- [X] eval
- [X] car
- [X] cdr
- [X] cons
- [X] eqv?
- [ ] eq?
- [ ] equal=
- [X] display
- [X] not
- [X] +
- [X] -
- [X] *
- [X] /
- [X] modulo
- [ ] remainder
- [ ] max
- [ ] min
- [ ] abs
- [ ] gcd
- [ ] lcm
- [ ] floor
- [ ] ceiling
- [ ] truncate
- [ ] round
- [ ] expt
- [X] =
- [X] <
- [X] >
- [X] <=
- [X] >=
- [X] zero?
- [X] positive?
- [X] negative?
- [X] odd?
- [X] even?
- [ ] min
- [ ] max
- [X] null?
- [X] length
- [X] reverse
- [X] map (only 1 list)
- [X] curry
- [X] id
- [X] flip
- [X] compose
- [X] folds (foldl foldr)
- [X] unfold
- [X] sum
- [X] product
- [X] filter