Merge pull request #20 from Ekdohibs/readme

Add READMEs
This commit is contained in:
Gabriel Scherer 2020-12-07 22:08:13 +01:00 committed by GitHub
commit f6039c4315
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 0 deletions

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# camlboot: An OCaml bootstrap experiment
camlboot is an experiment on the boostraping of the [OCaml](https://ocaml.org/) compiler. It is composed of:
- An interpreter of OCaml, in the directory `interpreter/`, which is able to interpret the OCaml compiler. This interpreter is written in a subset of OCaml called miniml, for which a compiler is available as part of the experiment.
- A compiler for miniml, in the directory `miniml/compiler/`. This compiler compiles miniml to OCaml bytecode, which is then executed by the OCaml runtime. It is written in scheme (more specifically, [guile](https://www.gnu.org/software/guile/)), since the goal is to bootstrap OCaml. Note that guile is itself bootstrapped directly from gcc, and building OCaml needs a C compiler as well, so we effectively bootstrap OCaml from gcc.
- A handwritten lexer for the bootstrapping of ocamllex, in the directory `lex/`. This lexer is able to perform the lexing of ocamllex's own `lexer.mll`, the first step towards the bootstrap of ocamllex, and then OCaml.

10
interpreter/README.md Normal file
View File

@ -0,0 +1,10 @@
# OCaml interpreter
This directory contains an interpreter for OCaml, written in miniml. It aims to be as correct as possible while only using the untyped representation of the program.
It has three main modes:
- `./interp ocamlc`, which will interpret the compiler sources to get a replacement for `ocamlc`,
- `./interp ocamlopt`, which will interpret the compiler sources to get a replacement for `ocamlopt`,
- `./interp files [list of files]`, which will interpret the list of files given as argument.
For now, it is written in a subset of OCaml a bit larger than miniml, but we are working on making it compatible with miniml by avoiding the use of unnecessary features and adding other features to miniml.

16
miniml/compiler/README.md Normal file
View File

@ -0,0 +1,16 @@
# miniml compiler
The file `compile.scm` is a single-file compiler for the miniml language, written in Scheme. It targets the OCaml bytecode for the version 4.07.0 of the OCaml compiler.
It is used as such:
```bash
$ guile compile.scm file.ml -o file.byte
```
The file `file.byte` will then contain executable OCaml bytecode, which can be run using `ocamlrun` from version 4.07.0 of the OCaml compiler (in this repository's `ocaml-src/` submodule).
It can only process a single file of input; in case you wish to use multiple files, you must first bundle them all into a single `.ml` file, putting the contents of file `x.ml` between `module X = struct`/`end` delimiters.
All OCaml external functions can be used with `external` declarations, but primitives work differently: they call a single bytecode instruction, with the instruction number specified in the external declaration; see `hello.ml` for examples.
`miniml` is completely untyped, and error reporting during compilation is very limited. However, since syntax and semantics are almost completely compatible with OCaml, in most cases you can just use OCaml to find the syntax or type error.