The compilation of EDDI Source files to assembly is made in several phases.
Parsing
First of all, the source code is parsed using Boost Spirit. The source code is translated into an Abstract Syntax Tree (AST).
Once the AST has been parsed, the dependencies are resolved and included into the AST.
Transformations
After the dependencies have been resolved, the AST is cleaned. Namely, some minor changes are made to the AST.
After that, the default values are added to the AST. Then, the strings are collected and the string pool is filled. Finally, the Symbol Table are completed and the functions are resolved.
Some nodes are also transformed into another one. Foreach for example are transformed into a For node.
Checks
The types ares then verified in all assignments and variables usages.
Some other checks are performed, for examples functions and variables that are never used.
Intermediate representation
Once all the operations are done on the AST, it is compiled into an intermediate representation : Three-Address-Code
Then, the TAC statements of every functions are separated into basic blocks.
Optimizations
The compiler runs several optimization on the TAC statements in order to generate code as efficient as possible.
Code generation
At the end, the TAC program is translated into Intel assembly.
If specified in the command line options, the assembly file is assembled and linked into an executable.