-- http://www.lua.org/gems/ -- http://www.lua.org/gems/selected.html Title: Boostraping a Forth in 40 lines of Lua code Author: Eduardo Ochs http://angg.twu.net/ eduardoochs@gmail.com Text of the abstract: The core of a conventional Forth system is composed of two main programs: an _outer interpreter_, that interprets textual scripts, and an _inner interpreter_, that runs bytecodes; the outer interpreter switches between an ``immediate mode'', where words as executed as soon as they are read, and a ``compile mode'', where the words being read are assembled into bytecodes to define new words. In Forth all variables are accessible from all parts of the system. Several important words use that to affect the parsing: they read parts of the input text themselves, process that somehow, and advance the input pointer - and with that they effectively implement other languages, with arbitrary syntax, on top of the basic language of the outer interpreter. Due mostly to cultural reasons, Forths tend to be built starting from very low-level pieces: first the inner interpreter, in Assembly or C, then the basic libraries and the outer interpreter, in Forth bytecodes, or - rarely - in C. We take another approach. If we consider that Lua is more accessible to us than C or Assembly - and thus for us Lua is ``more basic'' - then it is more natural to start from the outer interpreter, and the dictionary only has to have the definition for one word, one that means ``interpret everything that follows, up to a given delimiter, as Lua code, and execute that''. An outer interpreter like that fits in less than 40 lines of Lua code, and it can be used to bootstrap a whole Forth-like language.