This is a project that converts Python code to and from Zag Smalltalk's AST. It is implemented in Pharo Smalltalk.
This project is currently in the early stages of development; don't expect every Python feature to work at the moment.
Metacello new
githubUser: 'Zag-Research' project: 'Zag-Python-Converter' commitish: 'main' path: 'src';
baseline: 'ZagPythonConverter';
load
To convert Python code to a Zag AST:
ZagTSNode pythonToZagAST: '[PYTHON CODE]'
- Tree Sitter, Pharo Smalltalk version
This project implements a few extension messages in order to handle things as they would be in Python. Translated code uses these extensions in certain situations.
toPythonBooleanconverts a value to a boolean based on Python truthiness. Related messages likepythonOr:do boolean operations based on truthiness.zwAt:and related messages allows indexing arrays according to Python conventions (initial index is 0, negative indices access elements at the end).switchimplements a switch/cond statement, used for translating if/elif statements.ifTrue:andifTrue:ifFalse:are used for if statements without elifs.
This is the thesis project of Adrien Hopkins (a1hopkins@torontomu.ca), made as part of the Zag Research team.