Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

thorf

Interpreter for a massively simplified version of Forth.

I originally wrote this as a solution to an exercism.io exercise, but had so much fun that I decided to take it a bit further.

Supported "words"

Basic integer arithmetic operations:

  • +: add last two items
  • -: subtract last item from second to last item
  • *: multiply last two items
  • /: divide second to last item by last item

Stack manipulation operations:

  • DUP: duplicate the last item
  • DROP: remove the last item
  • SWAP: swap the order of the last two items
  • OVER: duplicate the second to last item

Output:

  • .: print the last item as an integer
  • .s: print the stack without consuming it
  • EMIT: print the last item as a unicode character

It also supports defining new words at runtime:

: word-name definition ;

Executable

$ go install github.com/fordhurley/thorf/cmd/thorf
$ thorf -e "1 2 + ."
3
$ thorf testdata/helloworld.fs
Hello, world!
$ echo "6 4 - ." | thorf
2

About

massively simplified forth interpreter

Resources

License

Releases

No releases published

Packages

No packages published