https://github.com/usethesource/typepal
TypePal is a framework for name analysis, type checking and type inference
https://github.com/usethesource/typepal
domain-specific-language rascal type-checking typechecker
Last synced: 9 months ago
JSON representation
TypePal is a framework for name analysis, type checking and type inference
- Host: GitHub
- URL: https://github.com/usethesource/typepal
- Owner: usethesource
- License: bsd-2-clause
- Created: 2017-11-29T14:56:18.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T14:08:10.000Z (about 1 year ago)
- Last Synced: 2024-10-29T15:17:54.248Z (about 1 year ago)
- Topics: domain-specific-language, rascal, type-checking, typechecker
- Language: Rascal
- Homepage: https://www.rascal-mpl.org/docs/Packages/Typepal/TypePal/
- Size: 2.07 MB
- Stars: 5
- Watchers: 24
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Citation: CITATION.md
Awesome Lists containing this project
README
# 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.