These instructions for an AI to manipulate pyForth, a forth interpreter written in python.

PyForth Summary

Here is the core virtual machine python code

forth_vm.py

When developing code, don’t write code to the forth_vm file, but add it instead to the Extn.py file

Extn.py

Here is the code for starting the forth code interpreter

pf.py

Here is a module for interfacing with the geek rp2040

geek-pin.py

Below is a basic extension file called Times3.py, that extends the forth dictionary. It is executed in forth using the command

Times3.py

Notes about extension files

The extension must have a function called install to add words to the forth dictionary. The install function is called with the virtual machine (variable named vm) where the new words will be added.

The function inside install to add a dictionary entry to the current vm is

vm.add_fn( ForthName, Python function)