nthery/NotQuiteForthInSwift
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
A naive very incomplete Forth interpreter hacked to teach myself some Swift. DISCLAIMER: I have never programmed in Forth. Forth reference used: http://www.forth.com/starting-forth/. XCode 6.1 used. FEATURES ======== * read-eval-print loop. * Forth API (ForthEvaluator.eval()). * Pushing integers on stack. * Addition, subtraction, multiplication and division. * Defining new words. * IF ELSE THEN. * EMIT. * CR. See tests for usage. DESIGN ====== Forth source statements are compiled into instructions for a virtual machine by the Compiler class. Compilation occurs when defining new words but also in immediate mode. The VM class interprets virtual machine code. The ForthEvaluator class coordinates the compiler and VM. BACKLOG ======= TODO: test stack level at end of tests TODO: add support for while loops TODO: add support for more primitive Forth words TODO: test recursivity (fibonnacci) TODO: add support for strings TODO: add support for arrays and pointers