wollok-doc

GitHub Discord Email

Compilation Pipeline

Before a Wollok program or test can be executed, the text on it’s sources needs to be processed into a more useful structure and checked for possible problems. This is done through a series of steps we call the Compilation Pipeline. Each step is modeled as an independent module that receives the output of the previous one and returns a more refined representation of the AST.

On this section we will address a general description of each stage. For a more in-depth explanation on each of them, follow the links to the corresponding wiki pages.

Pipeline

Parser

The Parser is the first step of the pipeline. It takes Wollok Code and builds an Abstract Syntax Tree based on its content. Different parsers are provided, designed to parse specific Wollok abstractions, such as a single expression or a whole source file. The Parser does not need to process a complete Wollok project at the same time: it can work on independent file sources; that’s why the AST branches generated by the Parser are disconected and can’t yet relate with abstractions from other branches. To do so, they need to move to the next stage.

Linker

The Linker takes multiple isolated ASTs and connects them together to form a Linked Environment. This effectively connects all the previously parsed branches into a single, integrated AST. During this process each Node gets assigned an unique id and is provided with all the information about its Visibility Scope. This allows all the References to know exactly what Node they are targeting an allows the detection of any missing definitions.

From this point onwards the generated Environment is fully functional, but it still might contain some invalid constructions that could not be detected so far. To make sure the AST is completely healthy it still needs to go through one more stage.

Validator

The Validator checks an Environment searching for possible issues that the previous steps are unable to detect and returns a List of Problems. If this list is empty the AST can be considered a Valid Environment and thus, ready to be interpreted or used to perform refactors and code analysis routines.