5 1. mes.c: prototype Scheme interpreter in C, mature enough to run
6 2. guile/mescc.scm: C compiler on [Guile] Scheme, that can compile
7 2a. scaffold/hello.c: Simplest C program, compiled with 2.
8 2b. scaffold/micro-mes.c: main of 3. (2nd Scheme interpreter) + mlib.c
9 2c. scaffold/cons-mes.c: run simple hardcoded sexp
10 2d. scaffold/tiny-mes.c: load memory dump, run simple sexp
11 2e. scaffold/t.c: c compiler tests, enough to support compiling
12 3. scaffold/mini-mes.c: 2nd Scheme intepreter in C, without [g]libc, using
13 4. mlib.c: Minimal Mescc C library
14 4a. scaffold/hello.c: Simplest C program, compiled with 5.
15 4b. scaffold/micro-mes.c: main of 3. (2nd Scheme interpreter) + mlib.c
16 4c. scaffold/cons-mes.c: run simple hardcoded sexp
17 4d. scaffold/tiny-mes.c: load memory dump, run simple sexp
18 4x. *we are here, any more steps to reach 5*
19 rm -f a.out; MES_DEBUG=1 scripts/mescc.mes scaffold/tiny-mes.c > a.out
20 4e. scaffold/t.c: run c test suite with scripts/mescc.mes
21 5. scripts/mescc.mes: C compiler on mes, that can build mini-mes
22 5a. remove __MESC__/__NYAC__ C workarounds in gc.c
23 5b. module/language/c99/compiler.mes: refactor expr->arg, expr->accu, ast->info
24 5c. merge *.c into scaffold/mini-mes.c
25 5d. merge scaffold/mini-mes.c into mes.c
26 6. scripts/mescc.mes: C compiler on mes, that can build mes
27 7. release self-hosting Mes 0.5
28 7a. discuss full source bootstrap strategy on guile-user with
29 Orians Jeremiah (stage0+) Luca Saiu's (GNU Epsilon).
30 ** release 0.x, unsorted
31 - produce intermediate annotated assembly-like mes.S
32 - AND/OR: connect to GNU Epsilon's VM
33 - AND/OR: connect to OriansJ's stage0...LISP bootstrapping tools
34 - real module support, bonus for supporting Guile's define-module/define-public syntax
35 - get full source syntax-case up (Andre van Tonder?) OR drop
36 psyntax/syntax-case and rewrite Nyacc without syntax-case+R7RS Ellipsis
37 - support regexp OR rewrite Nyacc without regexps
38 - split-off Guile C compiler as standalone Guile project, still
39 respecting no-syntax-case bootstrap requirement
40 *** Compile the [[https://en.wikipedia.org/wiki/Tiny_C_Compiler][Tiny C Compiler]]
43 - work to replace GuixSD's bootstrap binaries for x86
47 ** Support call-with-current-continuation, refactor catch/throw
48 ** 0.4: Support Nyacc, Gcc-compiled Mes compiles minimal main.c using nyacc
49 ** 0.3: Garbage collector
50 ** 0.2: Support psyntax
51 ** 0.1: Mes eval/apply feature complete; support syntax-rules, compile main.c using LALR, dump ELF
53 * Full source bootstrapping
55 ** R6RS-like scheme interpreter
56 This first part is prototyped in C by the mes.c core and Scheme
57 bootstrap code in module/. Of course, while mes.c is pretty small it
58 cannot serve as a full source solution.
60 The initial idea was to have the minimal core support LISP-1.5 (or
61 something very close to that as a tribute to John McCarthy) and extend
62 eval/apply from LISP-1.5 source with define, define-macro etc. and
63 metamorphose into R6RS. It seemed to work but performance of the
64 LISP-intepreted RRS was so bad (~1000x slower than initial LISP-1.5)
65 that this track was abandoned after the initial ANNOUNCE.
67 The route changed, trying to strike a balance between core size and
68 performance: still writing as much as possible in Scheme but having a
69 mescc compiler that takes not more than some seconds to run.
71 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
72 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
73 time to start doing something useful.
76 ** test/match.test ("nyacc-simple"): hygiene problem in match
77 ** The Scheme reader is very slow.
78 ** Fluids are a hack for Nyacc.
79 ** Prototype mes.c depends on a C compiler.
80 *** Translate C-prototype mes.c into annotated hex?
81 One idea is to use OriansJ's amazing self-hosting [[https://github.com/oriansj/stage0][stage0]] hex assembler
82 and minimal bootstrap binaries and rewrite the mes.c core to directly
83 bootstrap into Scheme.
85 *** Rewrite mes.c in Schemy/Sexp-C and generate annotated hex?
86 Another idea (thanks Rutger!) is to rewrite the mes.c core in a s-exp
87 C/Assembly variant and thave mescc produce the simple, annotated
90 *** Compile the [[https://en.wikipedia.org/wiki/Tiny_C_Compiler][Tiny C Compiler]]
92 * OLD: Booting from LISP-1.5 into Mes
94 Mes started out experimenting with booting from a hex-coded minimal
95 LISP-1.5 (prototype in mes.c), into an almost-RRS Scheme.
97 When EOF is read, the LISP-1.5 machine calls loop2 from loop2.mes,
98 which reads the rest of stdin and takes over control. The functions
99 readenv, eval and apply-env in mes.mes introduced define, define-macro
100 quasiquote and macro expansion.
102 While this works, it's amazingly slow. We implemented a full reader
103 in mes.c, which makes running mes:apply-env mes:eval somewhat
104 bearable, still over 1000x slower than running mes.c.
106 Bootstrapping has been removed and mes.c implements enough of RRS to
107 run a macro-based define-syntax and syntax-rules.
109 loop.mes and mes.mes are unused and lagging behind. Probably it's not
110 worth considering this route without a VM. GNU Epsilon is taking the
111 more usual VM-route to provide multiple personas. While that sounds
112 neat, Lisp/Scheme, bootstrapping and trusted binaries are probably not
113 in scope as there is no mention of such things; only ML is mentioned
114 while Guile is used for bootstrapping.
116 * Assorted ideas and info
117 ** Using GDB on assembly/a.out
121 set disassemble-next-line
122 gdb-display-disassembly-buffer
124 ** Create memory dump with 32 bit Gcc compiled Mes
125 guix environment --ad-hoc --system=i686-linux gcc-toolchain -- bash -c 'make mes CC=i686-unknown-linux-gnu-gcc LIBRARY_PATH=${PATH%%/bin:*}/lib'
127 MES_TINY=1 ./mes-32 --dump < module/mes/tiny-0.mes > module/mes/tiny-0-32.mo
128 ./mes-32 --dump < module/mes/read-0.mes > module/mes/read-0-32.mo
130 *** [[https://savannah.gnu.org/projects/nyacc][nyacc]]
131 *** PEG: [[http://piumarta.com/software/peg/][parse C using PEG]]
132 *** [[https://en.wikipedia.org/wiki/Tiny_C_Compiler][Tiny C Compiler]]
133 *** [[http://www.t3x.org/subc/index.html][Sub C]]
134 *** [[https://groups.google.com/forum/#!topic/comp.lang.lisp/VPuX0VsjTTE][C intepreter in LISP/Scheme/Python]]
136 ** C assembler/linker
137 *** [[http://www.tldp.org/HOWTO/Assembly-HOWTO/linux.html][Assembly HOWTO]]
140 *** [[http://www.muppetlabs.com/~breadbox/software/tiny/][Small ELF programs]]
141 *** [[http://www.cirosantilli.com/elf-hello-world/][Elf hello world]]
142 ** SC - c as s-expressions
143 sc: http://sph.mn/content/3d3
145 *** [[http://www.scheme-reports.org/][Scheme Reports]]
146 *** [[ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-349.pdf][Scheme - Report on Scheme]]
147 *** [[ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-452.pdf][RRS - Revised Report on Scheme]]
150 http://forum.osdev.org/viewtopic.php?f=15&t=19937
152 http://www.stripedgazelle.org/joey/dreamos.html
153 http://armpit.sourceforge.net/
154 http://common-lisp.net/project/movitz/movitz.html
156 <civodul> janneke: https://github.com/namin/inc looks interesting [15:18]
158 <OriansJ> janneke: also, if you look at
159 https://github.com/oriansj/stage0/tree/master/stage2/High_level_prototypes
160 [the garbage collected lisp I implemented], if there are any pieces
161 I could add to finish off your mes lisp bootstrap just let me know
162 because I would be more than happy to do that :D
163 <janneke> OriansJ: that's what I'm hoping for, that our efforts can be
164 complementary and we can work together
165 *** lfam (~lfam@2601:47:4180:2ffb:7c05:17de:cf5f:23ef) has quit: Ping timeout:
167 <janneke> exciting times! [00:23]
168 <janneke> OriansJ: i looked a few times and saw 'LISP empty', so thanks for
170 <civodul> OriansJ, janneke: from that page, there's also:
171 https://web.archive.org/web/20160604035203fw_/http://homepage.ntlworld.com/edmund.grimley-evans/bcompiler.html
174 https://web.archive.org/web/20160604041431/http://homepage.ntlworld.com/edmund.grimley-evans/cc500/cc500.c
175 https://github.com/rswier/c4/blob/master/c4.c