Code Organization¶
The main executable is located in app. The tests are located in test. The rest of the code is located within the src directory.
For understanding the code, it is best to start by looking at Syntax. This file contains main class definitions to describe the syntax of the program. The main piece of syntax is called RawPrgm m
or Prgm m
that includes some amount of additional metadata m
.
Most of the code works similar to a pipeline. It converts the program code from one format to another and from one metadata type to another until the end result is finally used. The pipeline flows as follows:
- Parser -
String -> RawPrgm PreTyped
. This parsers the syntax of the string text file into a raw format. - Desugar -
RawPrgm PreTyped -> Prgm PreTyped
. The desugar process removes various kinds of syntactic sugar and converts the code from the more user friendly external format into a more minimal format better suited towards optimization. - TypeCheck -
Prgm PreTyped -> Prgm Typed
. The typechecking will execute typechecking and type inference to ensure that all types are known for all of the functions. - TreeBuild -
Prgm Typed -> ResArrowTree
. Once typechecked, the implicit conversions are chosen and the code is formed into a single tree. This stage currently lives within the Eval stage as it requires knowledge about the primitive instructions and data types available. - Eval -
Prgm Typed -> Val
. The evaluator is an interpreter that will execute the code and produce final values. For building or compiling programs, it is executed through evaluation as a macro.