This is a Forth-like scripting language built in Python 3 and is preceded by similar languages that were built in Delphi/Lazarus, Excel VBA, and JavaScript. It can be used either standalone or as a DSL embedded as part of a larger application.
Primitives are defined as Python methods attached to objects. They are roughly analagous to core words defined in assembly language in some Forth compilers. They are then passed to the buildPrimitive method in the CreoleForthBundle class, which assigns them a name, vocabulary, and integer token value, which is used as an address.
High-level or colon definitions are assemblages of primitives and previously defined high-level definitions. They are defined by the colon compiler.
-
Clone the cfpy project.
-
Navigate to the cfpy folder and run the following command: python runcfpyscr.py script1.f
-
A message saying "Hello World" should come up.
- Run python runcfypscr.py script2.f. This will run the VLIST word.
- Run python runcfypscr.py script3.f. This defines and executes the high-level definition TEST1. It uses IF-ELSE-THEN branching to either run the HELLO primitive or add and print the sum of 3 and 4.
- Define the primitives in AppSpec.py.
- Build the primitives with the cfb1.buildPrimitive method.
- Build high-level definitions with the cfb1.buildHighLevel method.
- Run runcfypscr.py test.f to run the sample testing definition in the APPSPEC vocabulary.