Skip to content

Latest commit

 

History

History
25 lines (15 loc) · 1.33 KB

internal.md

File metadata and controls

25 lines (15 loc) · 1.33 KB

Internals

For those who are interested in the internals of our compiler, here is a brief overview of the pipeline:

Source->Lexer->Token->Parser->AST->Infer->TypeCheck->TypedAst->Compiler->HIR->LIR->Asm->Linker->Executable

We start from the Falcon source code, which is then tokenized by the lexer. The tokens are then parsed into an abstract syntax tree (AST).

Type inference is then performed on the AST, because we encourage omitting type annotations in the source code. Consequently, the AST is transformed into a typed AST. The typed AST is then type-checked and transformed into a high-level intermediate representation (HIR).

After HIR construction, several classical optimizations are performed on the HIR, such as dead code elimination, CFG simplification, phi simplification, and local value numbering.

The HIR is then lowered into a low-level intermediate representation (LIR), which is then translated into assembly code. Finally, the assembly code is linked into an executable by using GCC toolchain.