|
|
||
|---|---|---|
| examples | ||
| include | ||
| src | ||
| .gitignore | ||
| Makefile | ||
| README.md | ||
README.md
leao
minimal scheme dialect implementation written in ISO C11 meant to be used to write interpreters and compilers (that can therefore be easily bootstrapped).
This implementation is only an hobby and should be not taken seriously at all.
How to build
This project uses GNU Make, in order to build it, run in your shell:
$ make
leao features (or better, limitations)
Here is a list of features that are planned:
- Only ASCII is supported (for the full grammar check
src/parser.c) - There are only integers (probably int64_t) and integer arithmetic
- box primitive datatype, being the only one that allows mutation, all the other values are immutable
- First class functions
- First class undelimited continuations (maybe? I'm not sure yet, but they seem easy to implement)
- First class delimited continuations (seem easy)
- Hygienic macros (this is very hard, even less sure, but they can help in writing an interpreter)
Implementation notes
I'd like to implement a virtual machine influenced by the second architecture (stack based virtual machine)
exposed in Dybvig's thesis Three Implementation Models for Scheme.
Observe that the odd (for scheme) requirement of having all immutable values except for the box datatype is to allow for a slightly optimised virtual machine implementation.
In fact by making the user manually mark the mutable values in the program, the compiler can spare some heap allocations when needed.
Actually this limitation is not necessary at all, in fact the interpreter can do some analysis and automatically determine whether a variable can be mutated or not, but at the moment i like the idea of having explicitly marked mutations, it seems more functional (the idea is copied from Standard ML).
This limitation will probably change in the future.
For the garbage collection I'll get started with the Cheney's algorithm, which is pretty easy to implement. Maybe later a different algorithm may be due.
Core language
Since we want to hopefully implement macros, we start defining what the core, target, language looks like.
It has the following syntactic forms, whose semantics can be looked up on the R7RS standard:
- define
- let, letrec
- lambda
- quote
- if
- begin