Investigation into replacing the GNU Mes compiler which is part of live-bootstrap.
The reason for this is that the GNU Mes compiler is a bit of odd one out because it is compiled with a C-preprocessor and C-compiler and it is used to compile Tiny C Compiler, which itself might only use a subset of C itself. The gap between the two seems rather small.
The first step consists of analyzing what part of the C-grammar that is needed
for compiling TCC. For this I wrote a minimal C preprocessor: min_tcc_preprocessor.cpp
and CParser.c that is heavily based on RawParser.
The commit 058272
adds the files tcc_cc.c and gcc_tcc_cc.c. The second includes the first. The first is
an attempt to implement an iterator based C-preprocessor (which is not finished yet). It
does work when compiling gcc_tcc_cc.c with the following command:
gcc -Wno-builtin-declaration-mismatch -Wno-int-conversion -g gcc_tcc_cc.c -o gcc_tcc_cc
But when I compile it with M2-Mesoplanet using the following command:
M2-Mesoplanet -f tcc_cc.c --architecture x86 --max-string 6000 -o tcc_cc
it returns a segmentation fault after some time in a place where before it did not give it.
It looks like the return address on the stack is overwritten at some point. The error
also occurs when using Emulator.
The commit 590e5315
contains the first version of stack_c.cpp, a compiler for a small stack base
programming language, which can compile the hello.sl program with the help of
some live-bootstrap executables (see the script build_stack_hello) to an
executable hellosl that does print out the text 'hello world!'.
The commit 8084af1c
contains a version of tcc_cc.c that implements a preprocessor that can process
the TCC sources (it seems). It is based on iterators.
The commit 93fba047
contains a version of tcc_cc.c that can parse the TCC sources and its own source
The commit 9122a22a
contains a version of tcc_cc.c that determines the type of all expressions.
The commit 6ac84a5d
contains the version of tcc_cc.c with which the hello.c
program can be compiled to the stack_c language, and compiled to an ELF with the
stack_c compiler and the life-bootstrap programs blood-elf, M1 and hex2.
The commit 5808d49c
With commit c57b9bbd
the compiler is now a self hosting compiler in the sense that the compiled version of the compiler (with its source
as input) when used to compile its source, will return the same output.
fixes some bugs, such that compiling stack_c.c with the tcc_cc compiler, the resulting program produces the
same output when executed on the output of tcc_cc.
The commit 54fc4685 gives an interpreter voor the Stack_c language.