Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Compiler Architecture

This document provides a high-level overview of the architecture of the Elara compiler. It is intended for those who wish to understand the internal workings of the compiler, contribute to its development, or extend its functionality.

Design Principles

Query-Based: The compiler is designed around the Rock query system between compilation stages, enabling memoisation and incremental compilation (not implemented yet). Each compilation stage is implemented as a query or group of queries that can fetch results from other stages.

Effectful: The the Effectful library is used to manage side effects in a structured way. For more information on how effects are used in the compiler, see the Effects section.

Trees that Grow: The compiler adopts the Trees that Grow pattern to avoid unnecessary AST duplication between compilation stages. Every Stage until ToCore uses the same AST type with different extensions to represent the information available at that stage.