33 lines
2.4 KiB
Typst
33 lines
2.4 KiB
Typst
#import "../../requirements.typ": isc-hei-bthesis
|
|
#import isc-hei-bthesis: todo
|
|
#import "../../figs/architecture.typ"
|
|
#import "@preview/acrostiche:0.7.0": acr
|
|
|
|
= Architecture Overview <sec:impl-overview>
|
|
|
|
Our type checker is composed of several interdependent elements shown in @fig:architecture. At its core, there is a type registry which holds a list of all registered types. This registry is initialized with builtin types, like `float` and `str`, and can be further populated by user definitions written in the Midas language. Finally, it is used when type checking the Python source code based on the type checking rules we defined in @sec:theory-typing.
|
|
|
|
#figure(
|
|
architecture.overview,
|
|
caption: [Implementation Architecture Overview],
|
|
kind: image,
|
|
supplement: [Figure],
|
|
) <fig:architecture>
|
|
|
|
The different components have the following responsibilities:
|
|
/ Midas Typer: Take in a Midas definition file or some source code, parse it, process each statement and register new types in the registry. It must also check references between types and provide users with diagnostics in case of errors.
|
|
/ Python Typer: Take in a Python file or some source code, parse it, walk through each statement and expression, take note of type hints and otherwise infer types if possible, detect any incompatibilities, i.e. type errors and report them to the user.
|
|
/ Types Registry: Hold a registry of existing types (builtin or user-defined) and predicates, provide a method to check subtyping according to our rules (i.e. `is_subtype(type1, type2)`) and provide some methods to register, lookup and manipulate types.
|
|
/ Generator: Take in a Python #acr("AST"), type judgments (i.e. conclusions of the type checker) and the registry to produce new Python code with assertions that check types at runtime where necessary as well as constraint predicates.
|
|
|
|
Apart from the types registry, another component will be used across the whole system which is not shown in @fig:architecture: the reporter. The reporter is a simple object that will collect all diagnostics produced at different steps of the process. That includes syntax errors in Midas files, unknown references, type errors and more.
|
|
|
|
/*
|
|
- Main elements
|
|
- Definition language
|
|
- Supported Python syntax (cf. grammar and typing rules)
|
|
- Parse and type check
|
|
- Produce user-facing diagnostics
|
|
- Generate runtime assertions
|
|
- Architecture overview
|
|
*/ |