Skip to content

usethesource/typepal

This branch is 24 commits behind main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

0a07fe6 · Nov 25, 2024
May 8, 2024
Dec 24, 2023
Aug 14, 2020
Oct 18, 2024
Nov 25, 2024
Nov 3, 2024
Sep 15, 2022
Dec 24, 2023
Jun 13, 2024
Jun 13, 2024
Jun 13, 2024
Oct 14, 2019
May 22, 2024
Aug 14, 2020
Oct 13, 2020
Nov 5, 2024

Repository files navigation

TypePal

An experiment in type checker generation. Warning: work in progress!

From the user perspective the basic idea is as follows:

  1. Start with a Rascal grammar of the language of interest, say, MiniML.
  2. Write functions for specific language constructs
    • define captures all defining occurrences of variables and their scopes;
    • use captures all uses of variables;
    • require captures all static requirements on the use of certain constructs, such formal/actual parameter correspondence and the like;
    • calculate to compute a type for a language fragment using earlier calculated types, think of the result type of an operator based on its argument types.
  3. The above functions will populate a fact/requirement model (or TModel for short) of a source program to be type checked.
  4. Apply the collect function to a parsed program (a parse tree). This will apply define/use/require/calculate to all relevant places in the tree, will create scopes and use/def information and will also build a collection of constraints. They are all part of the TModel.
  5. Apply solve to the TModel resulting from the previous step. solve is happy if all constraints can be solved and generates error messages otherwise. solve also enhances the original TModel with derived facts that can be used for use/def analysis, interactive display of type information, and the like.