A small C11 compiler
A small C11 compiler in C++11.
cmake . -Bbuild
cd build && make && make testmake installThen you can play with the examples:
wgtcc example/heart.c
wgtcc example/chinese.cTry this:
./wgtcc -no-pie -I../include ../example/heart.cAs wgtcc doesn't support PIC/PIE, if you are using gcc >= 6.2.0, specify -no-pie explicitly:
wgtcc -no-pie example/heart.c
wgtcc -no-pie example/chinese.cwgtcc is aimed to implement the full C11 standard with some exceptions:
A basic recursive descent parser.
wgtcc generates code from AST directly. The algorithm is TOSCA (top of stack caching). It is far from generating efficient code, but at least it works and generates code efficently.
Through wgtcc was written in C++, I paid no effort for memory management except for a simple memory pool to accelerate allocations. only new is preferred because wgtcc runs fast and exits immediately after finishing parsing and generating code.
No open issues yet, or sync has not completed.