Forth In Lua

We wish we knew who the FirstPerson who wrote below is:

This is a Forth (see ForthLanguage) implemented in LuaLanguage. I found one that wasn't very good, and then I improved it. And, I will continue to improve it more later.

Forth is one of the best program languages. Now anything that uses embedded Lua can use embedded Forth as well. (Please note it is very slow. Also, some things don't work, and it is mostly best for experimental things, mostly. Writing a Forth interpreter in C is 100x faster.)

The primitives that it has so far are:

 ! !TABLE %L %S ' (') (SET-EXEC) * + - -ROT . / 0= 1+ 1- : ; < <> = > >R
 ?-GOTO ?DUP ?GOTO @ @TABLE AND CELLS>STRING CLEAR COMPILE COMPILE-HERE
 COMPILE-LIT-HERE CONCATENATE CONSTANT DEFINE-MODE DROP DO-CONSTANT
 DO-CUSTOM-MODE DUP EXECUTE EXIT GOTO HERE HERE! IMMEDIATE INCLUDE-FILE
 INVERT LIT MOD NEGATE NEXT-WORD NIP NULL-STRING OR OVER PICK R> R@ ROT
 SET-EXEC STRING>CELLS STRLEN TABLE TO-CHAR XOR [ [L \ ]

Everything else is defined from the primitives. For example:
 : IF COMPILE ?-GOTO COMPILE-HERE ; IMMEDIATE
 : THEN HERE SWAP ! ; IMMEDIATE
 : ELSE COMPILE GOTO COMPILE-HERE SWAP HERE SWAP ! ; IMMEDIATE


The initial version of the page in 2010 had the following additional line:

It is available at: http://zzo38computer.cjb.net/luaforth (BrokenLink 20131229 - actually a defunct web site)


CategoryForth CategoryProgrammingLanguage


EditText of this page (last edited December 29, 2013) or FindPage with title or text search