Skip to content

FransFaase/MES-replacement

Repository files navigation

GNU Mes replacement

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.

Analyzing C-grammar used for TCC

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.

WIP 11 July 2024

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.

WIP 19 August 2024

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!'.

WIP 17 April 2025

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.

WIP 28 April 2025

The commit 93fba047 contains a version of tcc_cc.c that can parse the TCC sources and its own source

WIP 7 May 2025

The commit 9122a22a contains a version of tcc_cc.c that determines the type of all expressions.

WIP 2 June 2025: compiled first program

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.

WIP 18 June 2025: compile stack_c.c

The commit 5808d49c

28 June 2025: Self hosting compiler

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.

23 July 2025: Stack_c interpreter

The commit 54fc4685 gives an interpreter voor the Stack_c language.

About

Investigation into replacing the MES compiler

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published