Skip to content

nthery/NotQuiteForthInSwift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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



About

A naive very incomplete Forth interpreter for teaching myself some Swift

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published