rascal-0.41.2
org.rascalmpl.typepal-0.15.5
Synopsis
Examples of type checkers built with TypePal.
Description
TypePal is used in a new type checker for the Rascal meta-programming language and also in type checkers for over a dozen domain-specific languages created by http://swat.engineering in the domains finance, forensics and privacy.
To get you started more quickly, we give below a list of complete TypePal-based type checkers ranging from very simple (intended only to illustrate specific TypePal features) to type checkers for FeatherweightJava and the complete Pascal programming language. For each example we give a description, the most distinctive TypePal features that are used, and its source at GitHub. Each example has the same structure:
Syntax.rsc the syntax of the example language.Checker.rsc the type checker for the language.Test.rsc functions to call the type checker and test framework.tests.ttl test cases for the type checker.examples (optionally) a directory with example.
Calc
Pico
| What | Toy language with declared variables in single scope, assignment, if and while statement |
|---|
| Illustrates | fact, define, use, enterScope, leaveScope, requireEqual, calculate, getType, report |
| Source | https://github.com/cwi-swat/typepal/tree/master/src/examples/pico |
Fun
| What | Functional language with explicit types, function declarations and calls, let and if expressions |
|---|
| Illustrates | fact, define, use, enterScope, leaveScope, requireEqual, calculate, getType, report |
| Source | https://github.com/cwi-swat/typepal/tree/master/src/examples/fun |
ModFun
Struct
Aliases
StaticFields
StructParameters
SmallOO
FWJava
| What | FeatherWeight Java, a minimal, Java-like, language with inheritance and constructors |
|---|
| Illustrates | useViaType, addPathToDef, isSubType, TypePalConfig, getTypeNamesAndRole, mayOverload, preSolver, setScopeInfo, getScopeInfo |
| Source | https://github.com/cwi-swat/typepal/tree/master/src/examples/fwjava |
Pascal
UntypedFun
| What | Functional language with implicit (inferred) types, function declarations and calls, let and if expressions |
|---|
| Illustrates | fact, define, use, enterScope, leaveScope, requireEqual, calculate, getType, report, newTypeVar, calculateEager, requireUnify, unify |
| Source | https://github.com/cwi-swat/typepal/tree/master/src/examples/untypedFun |