2016-07-22 20:12:05 +00:00
-*-mode:org-*-
2016-10-10 21:24:44 +00:00
2017-03-29 06:05:18 +00:00
* ROADMAP
** TODO release 0.5
1. mes.c: prototype Scheme interpreter in C, mature enough to run
2. guile/mescc.scm: C compiler on [Guile] Scheme, that can compile
2a. scaffold/hello.c: Simplest C program, compiled with 2.
2b. scaffold/micro-mes.c: main of 3. (2nd Scheme interpreter) + mlib.c
2c. scaffold/cons-mes.c: run simple hardcoded sexp
2d. scaffold/tiny-mes.c: load memory dump, run simple sexp
2e. scaffold/t.c: c compiler tests, enough to support compiling
3. scaffold/mini-mes.c: 2nd Scheme intepreter in C, without [g]libc, using
4. mlib.c: Minimal Mescc C library
4a. scaffold/hello.c: Simplest C program, compiled with 5.
4b. scaffold/micro-mes.c: main of 3. (2nd Scheme interpreter) + mlib.c
4c. scaffold/cons-mes.c: run simple hardcoded sexp
4d. scaffold/tiny-mes.c: load memory dump, run simple sexp
2017-04-01 14:12:51 +00:00
4x. *we are here, any more steps to reach 5*
rm -f a.out; MES_DEBUG=1 scripts/mescc.mes scaffold/tiny-mes.c > a.out
2017-03-29 06:05:18 +00:00
4e. scaffold/t.c: run c test suite with scripts/mescc.mes
5. scripts/mescc.mes: C compiler on mes, that can build mini-mes
5a. remove __MESC__/__NYAC__ C workarounds in gc.c
5b. module/language/c99/compiler.mes: refactor expr->arg, expr->accu, ast->info
5c. merge *.c into scaffold/mini-mes.c
5d. merge scaffold/mini-mes.c into mes.c
6. scripts/mescc.mes: C compiler on mes, that can build mes
7. release self-hosting Mes 0.5
7a. discuss full source bootstrap strategy on guile-user with
Orians Jeremiah (stage0+) Luca Saiu's (GNU Epsilon).
** release 0.x, unsorted
- produce intermediate annotated assembly-like mes.S
- AND/OR: connect to GNU Epsilon's VM
- AND/OR: connect to OriansJ's stage0...LISP bootstrapping tools
- real module support, bonus for supporting Guile's define-module/define-public syntax
- get full source syntax-case up (Andre van Tonder?) OR drop
psyntax/syntax-case and rewrite Nyacc without syntax-case+R7RS Ellipsis
- support regexp OR rewrite Nyacc without regexps
- split-off Guile C compiler as standalone Guile project, still
respecting no-syntax-case bootstrap requirement
*** Compile the [[https://en.wikipedia.org/wiki/Tiny_C_Compiler][Tiny C Compiler]]
- build tcc (tinycc)
** release 1.0
- work to replace GuixSD's bootstrap binaries for x86
- more architectures?
** DONE
** Support call-with-current-continuation, refactor catch/throw
** 0.4: Support Nyacc, Gcc-compiled Mes compiles minimal main.c using nyacc
** 0.3: Garbage collector
** 0.2: Support psyntax
** 0.1: Mes eval/apply feature complete; support syntax-rules, compile main.c using LALR, dump ELF
* Full source bootstrapping
2016-10-15 09:54:24 +00:00
2016-11-20 20:45:12 +00:00
** R6RS-like scheme interpreter
2016-10-15 09:54:24 +00:00
This first part is prototyped in C by the mes.c core and Scheme
bootstrap code in module/. Of course, while mes.c is pretty small it
2017-03-29 06:05:18 +00:00
cannot serve as a full source solution.
2016-10-15 09:54:24 +00:00
The initial idea was to have the minimal core support LISP-1.5 (or
something very close to that as a tribute to John McCarthy) and extend
eval/apply from LISP-1.5 source with define, define-macro etc. and
metamorphose into R6RS. It seemed to work but performance of the
LISP-intepreted RRS was so bad (~1000x slower than initial LISP-1.5)
that this track was abandoned after the initial ANNOUNCE.
2016-11-02 14:35:32 +00:00
The route changed, trying to strike a balance between core size and
performance: still writing as much as possible in Scheme but having a
2016-10-15 09:54:24 +00:00
mescc compiler that takes not more than some seconds to run.
2016-12-24 16:22:34 +00:00
Now that we have [[https://github.com/schemeway/lalr-scm][Dominique Boucher's LALR]], a [[https://www.cs.indiana.edu/chezscheme/syntax-case/old-psyntax.html][Pre-R6RS portable
syntax-case]] with R7RS ellipsis, [[http://www.nongnu.org/nyacc/][Nyacc]] and [[https://www.gnu.org/software/guile/docs/master/guile.html/PEG-Parsing.html][Guile's PEG]] parsers, it's
time to start doing something useful.
2016-10-15 09:54:24 +00:00
2016-12-24 16:22:34 +00:00
* Bugs
2017-04-01 13:06:07 +00:00
** test/match.test ("nyacc-simple"): hygiene problem in match
2016-12-24 16:22:34 +00:00
** The Scheme reader is very slow.
** Fluids are a hack for Nyacc.
** Prototype mes.c depends on a C compiler.
*** Translate C-prototype mes.c into annotated hex?
2017-01-22 13:16:22 +00:00
One idea is to use OriansJ's amazing self-hosting [[https://github.com/oriansj/stage0][stage0]] hex assembler
2016-10-15 09:54:24 +00:00
and minimal bootstrap binaries and rewrite the mes.c core to directly
bootstrap into Scheme.
2016-12-24 16:22:34 +00:00
*** Rewrite mes.c in Schemy/Sexp-C and generate annotated hex?
Another idea (thanks Rutger!) is to rewrite the mes.c core in a s-exp
2016-11-02 14:35:32 +00:00
C/Assembly variant and thave mescc produce the simple, annotated
2016-10-15 09:54:24 +00:00
bootstrap binary.
2016-12-24 16:22:34 +00:00
*** Compile the [[https://en.wikipedia.org/wiki/Tiny_C_Compiler][Tiny C Compiler]]
2016-10-16 12:00:40 +00:00
2016-10-15 09:54:24 +00:00
* OLD: Booting from LISP-1.5 into Mes
2016-07-22 20:12:05 +00:00
Mes started out experimenting with booting from a hex-coded minimal
2016-10-15 09:54:24 +00:00
LISP-1.5 (prototype in mes.c), into an almost-RRS Scheme.
2016-07-22 20:12:05 +00:00
When EOF is read, the LISP-1.5 machine calls loop2 from loop2.mes,
which reads the rest of stdin and takes over control. The functions
readenv, eval and apply-env in mes.mes introduced define, define-macro
quasiquote and macro expansion.
While this works, it's amazingly slow. We implemented a full reader
in mes.c, which makes running mes:apply-env mes:eval somewhat
bearable, still over 1000x slower than running mes.c.
2016-10-15 09:54:24 +00:00
Bootstrapping has been removed and mes.c implements enough of RRS to
2016-07-22 20:12:05 +00:00
run a macro-based define-syntax and syntax-rules.
loop.mes and mes.mes are unused and lagging behind. Probably it's not
worth considering this route without a VM. GNU Epsilon is taking the
more usual VM-route to provide multiple personas. While that sounds
2016-10-15 09:54:24 +00:00
neat, Lisp/Scheme, bootstrapping and trusted binaries are probably not
in scope as there is no mention of such things; only ML is mentioned
while Guile is used for bootstrapping.
2016-07-22 20:12:05 +00:00
2016-10-15 09:54:24 +00:00
* Assorted ideas and info
2017-01-22 13:16:22 +00:00
** Using GDB on assembly/a.out
info registers
p/x $eax
p/x $edx
set disassemble-next-line
gdb-display-disassembly-buffer
b *0x804a79d
** Create memory dump with 32 bit Gcc compiled Mes
guix environment --ad-hoc --system=i686-linux gcc-toolchain -- bash -c 'make mes CC=i686-unknown-linux-gnu-gcc LIBRARY_PATH=${PATH%%/bin:*}/lib'
2017-03-19 12:41:56 +00:00
mv mes mes-32
MES_TINY=1 ./mes-32 --dump < module/mes/tiny-0.mes > module/mes/tiny-0-32.mo
./mes-32 --dump < module/mes/read-0.mes > module/mes/read-0-32.mo
2016-10-15 09:54:24 +00:00
** C parser/compiler
*** [[https://savannah.gnu.org/projects/nyacc][nyacc]]
*** PEG: [[http://piumarta.com/software/peg/][parse C using PEG]]
*** [[https://en.wikipedia.org/wiki/Tiny_C_Compiler][Tiny C Compiler]]
*** [[http://www.t3x.org/subc/index.html][Sub C]]
*** [[https://groups.google.com/forum/#!topic/comp.lang.lisp/VPuX0VsjTTE][C intepreter in LISP/Scheme/Python]]
** C assembler/linker
*** [[http://www.tldp.org/HOWTO/Assembly-HOWTO/linux.html][Assembly HOWTO]]
*** ELF
7f 45 4c 46
*** [[http://www.muppetlabs.com/~breadbox/software/tiny/][Small ELF programs]]
*** [[http://www.cirosantilli.com/elf-hello-world/][Elf hello world]]
2016-12-10 21:47:13 +00:00
** SC - c as s-expressions
sc: http://sph.mn/content/3d3
2016-10-15 09:54:24 +00:00
** RNRS
*** [[http://www.scheme-reports.org/][Scheme Reports]]
*** [[ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-349.pdf][Scheme - Report on Scheme]]
*** [[ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-452.pdf][RRS - Revised Report on Scheme]]
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
** tiny schemes
http://forum.osdev.org/viewtopic.php?f=15&t=19937
http://www.stripedgazelle.org/joey/dreamos.html
http://armpit.sourceforge.net/
http://common-lisp.net/project/movitz/movitz.html
<civodul> janneke: https://github.com/namin/inc looks interesting [15:18]
2017-03-29 06:05:18 +00:00
** Orians Jeremiah
<OriansJ> janneke: also, if you look at
https://github.com/oriansj/stage0/tree/master/stage2/High_level_prototypes
[the garbage collected lisp I implemented], if there are any pieces
I could add to finish off your mes lisp bootstrap just let me know
because I would be more than happy to do that :D
<janneke> OriansJ: that's what I'm hoping for, that our efforts can be
complementary and we can work together
*** lfam (~lfam@2601:47:4180:2ffb:7c05:17de:cf5f:23ef) has quit: Ping timeout:
246 seconds [00:22]
<janneke> exciting times! [00:23]
<janneke> OriansJ: i looked a few times and saw 'LISP empty', so thanks for
the pointer! [00:24]
<civodul> OriansJ, janneke: from that page, there's also:
https://web.archive.org/web/20160604035203fw_/http://homepage.ntlworld.com/edmund.grimley-evans/bcompiler.html
** C4/C500
https://web.archive.org/web/20160604041431/http://homepage.ntlworld.com/edmund.grimley-evans/cc500/cc500.c
https://github.com/rswier/c4/blob/master/c4.c