Ember is a zero-dependency C90 compiler currently being written in Rust. The compiler con- tains a hand-written recursive descent parser able to parse the entire C90 grammar, extensive visualisation of the generated abstract syntax tree (AST) and a purpose-built memory arena module for fast allocation of the AST. The code generation is currently in progress, but is already capable of turning the AST into a simple, custom static single assignment intermediate representation.
Features
Zero dependencies.
Hand-written lexer and parser.
Ember uses a hand-written recursive descent parser for parsing most of the C90 grammar. However, for efficiency expressions are parsed with precedence climbing instead.
- Runtime allocations with a custom-built memory arena module.
In order to minimize allocation overhead, Ember uses a small memory arena for allocating the generated AST. By tying the lifetime of every AST node to the arena, this also avoids the usual pitfalls of dealing with trees in Rust.
- Extensive visualisation of generated ASTs.
Ember can visualize its internal AST as a printable tree. The visualization has a canonical representation for all types (even the really gnarly looking function pointers!).
Take the following example:
int main(){
int (*(*fp_arr[3][9])[15])();
int a = 1;
int b = 4 + 2/a++;
if(b)
a = 5;
else
a = 8;
}
Ember can visualize this as:

Note that the declarator for fp_arr is [3] [9] * [15] * (). This can easily be understood as fp_array is "an array with length [3] of array with length [9] of pointers (*) to an array with length [15] of functions with no arguments (()) returning int."
Building
Since Ember is written in Rust, you will need an installation of Rust to compile it. Ember is known to compile with Rust 1.59 (Stable) or newer. Compatibility with older versions of Rust will be checked in the near future.
To build:
$ git clone https://github.com/JoachimSand/Ember
$ cd ember
$ cargo build --release
$ ./target/release/ember -h
Usage
Usage: ember [ -p ][ -c ] <file>
-p Parse specified file and print an AST
-c Compile specified file. WIP
-h Print this help menu
<file> can optionally be left empty, in which case input can be input directly with a REPL.
Tests
A full testing framework is currently being worked on, but you can already view a series of tests in the tests directory.