Famix AST representation for Python based on TreeSitter
To install this project on your Pharo image, execute the following script:
Metacello new
githubUser: 'moosetechnology' project: 'FAST-Python' commitish: 'main' path: 'src';
baseline: 'FASTPython';
loadTo add this project to your baseline:
spec
baseline: 'FASTPython'
with: [ spec repository: 'github://moosetechnology/FAST-Python:main/src' ]Note you can replace the #master by another branch such as #development or a tag such as #v1.0.0, #v1.? or #v1.2.? .
In order to parse a chain of character or a file you can do this:
FASTPythonImporter parse: 'if x > 0:
if x < 10:
1
else:
2
else:
3'Or
FASTPythonImporter parseFile: myFileThe best documentation to read about this project is located in Pharo Tree Sitter's repository here: https://github.com/Evref-BL/Pharo-Tree-Sitter/blob/main/resources/doc/fast_importer.md and here: https://github.com/Evref-BL/Pharo-Tree-Sitter/blob/main/resources/doc/ts_utilities.md
| Version | Compatible Moose versions |
|---|---|
| v1.x.x | Moose 13 |
TreeSitter python changed after the version 0.25 to remove expression statement for the produced tree. The parser do not work in 100% of the case for version <= 0.25. So if you have tests that are not passing, first check the version of tree-sitter-python you are using.
This importer should work for Python 2 and 3 (but Python 2 code has less test coverage).
Latest tested python version is 3.13.3. Features added after this release might not be taken into account.
If you have any questions or problems do not hesitate to open an issue or contact cyril (a) ferlicot.fr