Skip to content

tonyrog/ffe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Forth Flavoured Erlang

This is forth on steorids in an Erlang environment send and receiving message running in parallell.

And it is nearly functional ...

module based forth.

words are organized into modules/vocabularies, words are called by using :, built in words are access directly without the : module separator.

The words in interactive mode are added into a special module.

: sqr dup * ;

Run like this

$ ./priv/ffe.sh
 ok 
: sqr dup * ; ok
12 sqr . 144 ok

Or

echo ": sqr dup * ; 12 sqr ." | ./priv/ffe.sh

In a module:

\ module foo

\ ( x -- (x*x) )
: sqr dup * ;

\ ( <a1> .. <an> <n> -- <sum> )
: sum 0 do + loop ;

If compiled then this is translated into the module foo.

-module(foo).
-export(['_ffe_sqr'/0,'_ffe_sum'/0]).

'_ffe_sqr'() ->
    { 0, <<"sqr">>, fun ffe:docol/4, fun ffe:star/0, fun ffe:semis/0 }).

'_ffe_sum'() ->
    { 0, <<"sum">>, fun ffe:docol/4, fun ffe:lit/4, 0, 
      fun ffe:pdo/0, fun fee:plus/0, fun ffe:ploop/0, -2,
     ffe:semis/0 }.

CREATE DOES>

How do you compile CREATE DOES> in ffe? let's show an example.

: my-constant CREATE , DOES> @ ;

Compiles into

my-constant = 
  fun() -> {0,<<"my-constant">>, fun ffe:docol/4,
            fun ffe:'_ffe_create/0,
            fun ffe:comma/0,
            fun ffe:'ffe_does'/0,
            fun ffe:'ffe_fetch'/0,
            fun ffe:semis/0 }
  end.

This is a defining word that creat a constant used like this

10 my-constant ten

This compiles into

ten = 
  fun() -> {0, <<"ten">>, fun ffe:does1/4, 

About

Forth Flavoured Erlang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published