Talk from IWST 2025: FASTTypeScript metamodel generation using FAST traits and TreeSitter project
PDF: https://archive.esug.org/ESUG2025/iwst-day2/iwst-202-hosr-fasttypescript-metamodel-generation.pdf
3. 4
4
4
Motivation
§ DRIT: a department specialized in
research and composed of
researchers, PhD students, engineers
and trainees.
§ LabGL: a research team specialized
in Software Analysis, by submitting
scientific publications and creating
prototypes and innovations.
LabGL team
Applications
4. 5
5
5
Motivation
We use different materials, but we rely on:
§ Moose: Platform for software and data analysis in Pharo. Allows
importing, parsing data, modelling, measuring, querying …
§ Famix: Abstract representation of source code
§ FAST: Famix Abstract Syntax Tree
§ MoTion: Object pattern matching in Pharo
§ …
5. 6
6
6
Motivation
§ At Berger-Levrault we use a variety of languages
to develop our applications, for example:
§ Java is used to develop back-end applications
à LabGL team can develop tools using
FASTJava and FamixJava.
§ TypeScript is used to develop front-End
applications à FASTTypeScript does not exist,
LabGL team is blocked L
…..
9. 10
10
10
§ Provides incremental parsing based
on Wagner et al. work (*)
§ Able to parse many languages:
Java, TypeScript, Python, C, C# …
§ Open source: >20k stars (Tree-sitter)
and >400 stars (Tree-sitter
TypeScript)
Solution
For parsing we chose Tree-Sitter:
* Efficient and flexible incremental parsing
Wagner et al.,1998
10. 11
11
11
§ Languages supported: TypeScript,
Python, C, Mermaid, Groovy
§ Cross-platform: Mac, Ubuntu,
Windows
§ Automated library generation for
easy setup and CI/CD integration
Solution
§ Integration in Pharo under Pharo-Tree-Sitter:
11. 12
12
12
class Person {
name: string;
}
Pharo-Tree-Sitter AST
Solution
FASTType_
identifier
FASTClass_
declaration
FASTClass_
body
FASTPublic_
field_
definition
FASTPrope
rty_
identifier
FASTType_
annotation
FASTPredifined_
type
FASTProgram
ü AST generated
12. 13
13
13
class Person {
name: string;
}
Pharo-Tree-Sitter AST
ü AST generated
Limited info per
each node
Solution à Limited L
FASTType_
identifier
FASTClass_
declaration
FASTClass_
body
FASTPublic_
field_
definition
FASTPrope
rty_
identifier
FASTType_
annotation
FASTPredifined_
type
FASTProgram
14. 15
15
15
§ Create first version of FASTTypeScript metamodel automatically based on
the grammar of Tree-Sitter-TypeScript
Solution
FASTTypescriptClass_
declaration
FASTTypescriptFor_
in_
statement
FASTTypescriptMethod_
definition
……
FASTTypescriptIf_
statement
FASTTypescriptTry_
statement
FASTTypescript-Model Package
15. 16
16
16
§ Create first version of FASTTypeScript metamodel automatically based on
the grammar of Tree-Sitter-TypeScript
§ Add properties for each class to enrich the metamodel and use FAST traits
Solution
FASTTypescriptClass_
declaration
FASTTypescriptFor_
in_
statement
FASTTypescriptMethod_
definition
FASTTypescriptEntity
16. 17
17
17
§ Create first version of FASTTypeScript metamodel automatically based on
the grammar of Tree-Sitter-TypeScript
§ Add properties for each class to enrich the metamodel and use FAST traits
Solution
FASTTypescriptClass_
declaration
FASTTypescriptFor_
in_
statement
FASTTypescriptMethod_
definition
FASTTypescriptEntity
Use FAST traits:
- FASTTEntity
- FASTTWithComments
17. 18
18
18
§ Create first version of FASTTypeScript metamodel automatically based on
the grammar of Tree-Sitter-TypeScript
§ Add properties for each class to enrich the metamodel and use FAST traits
Solution
FASTTypescriptClass_
declaration
FASTTypescriptFor_
in_
statement
FASTTypescriptMethod_
definition
FASTTypescriptEntity
Use FAST traits:
- FASTTEntity
- FASTTWithComments
- Body
- Name
- Body
- Name
- Parameters
- Return_Type
- Body
- Left
- Right
18. 19
19
19
§ Create first version of FASTTypeScript metamodel automatically
based on the grammar of Tree-Sitter-TypeScript
§ Add properties for each class to enrich the metamodel and use FAST
traits
§ Create an importer from Pharo-Tree-Sitter to FASTTypeScript
Solution
23. 24
24
24
Use cases
§ Methodology use case example:
§ Implementation of Famix metamodels for Perl C using Pharo-Tree-Sitter
§ FASTTypeScript use case example:
§ 2 separate projects are using FASTTypeScript at BL
§ MoTion (pattern matching library) could be used with FASTTypeScript as a searching
engine