From 5e5dddb3ba05683120f187c3d820d0eb9751e77a Mon Sep 17 00:00:00 2001 From: Francesco Magliocca Date: Tue, 24 May 2022 17:08:52 +0200 Subject: [PATCH] Add readme --- README.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..8c85854 --- /dev/null +++ b/README.md @@ -0,0 +1,55 @@ +# leao + +minimal scheme dialect implementation written in ISO C11 meant to be used +to write interpreters and compilers (that can therefore be easily bootstrapped). + +## 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: + +* Input source code can be encoded in UTF-8, but identifiers are very limited (cfr. `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