Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
Flua is an implementation, written in Lua, C and Nasm, of a variant of Forth. Its main ideas are: * A Flua program IS its bytecode, as it is the bytecode that will be executed by the engine (in Forth jargon: the "inner interpreter"). The source is just a way to generate the bytecode. Most modern free Forths for *NIX systems seem to take the position that users don't want to see the bytecodes, only the Forth source, and thus it is hard to figure out how these Forths implement the several kinds of defining words, the DOES> construct, etc. In Flua, in contrast, the bytecode corresponding to a program is compiled to a ".asm" file, that can then be processed by Nasm to generate a very nice ".lst" file. * Efficiency is attained by running well-written programs (i.e., well-written bytecodes) on fast inner interpreters; and the best way to have readable programs generating very efficient bytecodes is to have good optimizers and users that write code that the optimizers can handle well... and to do that users need to be able to understand how the optimizers work, and they should be able to add their own extensions, disable features, inspect each step of the optimization process, etc; as the bytecode is just free-form data if it were very easy to manipulate free-form data then it would be easy to write optimizers. I think that the RSR trick is a nice trick for that. More later. The links below, about the oldest predecessor of Flua ("Crim"), may be interesting. # (find-fline "~/crim/") # (find-fline "~/crim/letter.txt") # (find-fline "~/crim/ETC.txt") # (find-angghtml "crim/index.html") The immediate predecessor of Flua was written in Tcl: # (find-fline "~/CRIM1/") # (find-fline "~/CRIM1/README") The links will work if you are using a perfectly-configured ;) Emacs with the eev package installed (see http://angg.twu.net/), or if you are reading the htmlized version of this file, at: http://angg.twu.net/LUA/lua-0.02/README.html http://angg.twu.net/LUA/lua-0.02/ The files in this directory: Makefile :-) README This file. flua-comp.lua The bulk of the compiler. flua-demos-old.lua Code for five demos, in the "old style". A good stating point. flua-demos.lua Same, but in a shorter (and more powerful) format. flua-lua.lua Let compiled Flua programs call Lua functions. flua.lua The front line for the compiler. inc.lua Some library functions used by the other ".lua"s. skel.bytecode.asm The skeleton used to generate the Nasm bytecode files. skel.engine.c The skeleton used to generate the engine files in C. You can get a package with the files above from <http://angg.twu.net/LUA/flua-0.02.tar.gz>; the other files on this directory are generated automatically from those: ___.html HTMLized versions of the files above. demo_.engine.c The engine (or "inner interpreter") in C for demo_. demo_.bytecode.asm The bytecode for demo_, as a Nasm file. demo_.bytecode.lst The "listing file" generated from the above by Nasm. demo_ The binary obtained by compiling and linking demo_.engine.c and demo_.bytecode.asm, demo_.dbg.out The output of running demo_ with the debugging flags turned on; shows a complete single-stepping. The files above are the ones that get packed in the lua-0.02.tar.gz # (find-flua "Makefile") # (find-flua "README") # (find-flua "flua-comp.lua") # (find-flua "flua-demos-old.lua") # (find-flua "flua-demos.lua") # (find-flua "flua-lua.lua") # (find-flua "flua.lua") # (find-flua "inc.lua") # (find-flua "skel.bytecode.asm") # (find-flua "skel.engine.c") # (find-fluafile "") (setq sentence-end-double-space t) (setq sentence-end-double-space nil)