On Thu, Jan 02, 2014 at 03:47:29PM +0000, Liam Proven wrote:
On 2 January 2014 15:11, Paul Koning <paulkoning at
comcast.net> wrote:
[...]
I keep looking
on and off for a good implementation of a Forth processor.
http://www.colorforth.com/S40.htm ? :?)
You're sick :)
A mutual friend of ours implemented a Forth-like language (which he's nicknamed
"Quarter") in Scala as an exercise in learning the latter:
https://github.com/jjl/quarter/blob/master/squarter.scala
While he was bitching at me about how Scala was fighting back and showing me
some code that was getting bogged down in complexity, I slapped together this
crude but simple example in about half an hour to demonstrate how Forth words
could be modelled as partial functions which pattern-match the top of the
stack, at which point it's just a foldl over said functions to execute the
code:
http://abuse.mooli.org.uk/forth.scala.txt
But that's almost inpenetrable unless you're already familiar with functional
programming. It's also rather gratuitous to write a Forth interpreter that runs
atop the JVM, even if only as a learning exercise!
A somewhat more interesting starting point for ideas on how to implement a
Forth processor might be the simple implementation in the Jupiter Ace's ROM:
http://www.jupiter-ace.co.uk/romlisting.html