rob@idacom.uucp (Rob Chapman) (09/26/90)
>I can see why Forth in Forth (metacompiling) might be a little more >intimidating to the novice, but if you're interested in modifying >Forth itself, or to play around with new language concepts, my >experience is that it's the way to go. If you just want to Agreed! botForth is undergoing a transmutation which will leave the entire kernel written in Forth. An excerpt from the beginning: ( ==== Stacks ==== ) ( ==== Return stack ==== ) : R> ( -- m ) R> ; : >R ( m -- ) >R ; : R ( -- m ) R> DUP >R ; ( ==== Data stack ==== ) : SWAP ( m \ n -- n \ m ) SWAP ; : DUP ( m -- m \ m ) DUP ; : DROP ( m -- ) DROP ; : NUP ( m \ n -- m \ m \ n ) >R DUP R> ; : NIP ( m \ n -- n ) SWAP DROP ; : OVER ( m \ n -- m \ n \ m ) NUP SWAP ; : TUCK ( m \ n -- n \ m \ n ) SWAP OVER ; : 2DUP ( m \ n -- m \ n \ m \ n ) OVER OVER ; : 2DROP ( m \ n -- ) DROP DROP ; These are all the stack operators written in terms of the 5 primitives: SWAP DUP DROP >R R>. Since those 5 stack operators are primitives, they are used to define themselves. I factored botForth into 6 pieces: Metacompiler ( define a target space and the necessary access words ) Assembler ( real simple for the RTX ) Compilers ( stuff like target LITERAL COMIPILE ] ) Primitives ( step math and interrupt stuff ) Optimizers ( to be rewritten ) Kernel ( botForth in botForth) This makes it easy to support many different processors with one kernel. To port botForth to different processors, the assembler, compiler and primitive modules need to be written. Initially, only 5 stack operators need to be defined. If the assembly language isn't Forth (as on the RTX), then the 5 stack primitives need to be defined in the primitives module in assembler. Once the kernel is running on the targeted processor, more words may be defined in the primitives module. The metacompiler will substitute them for the high level ones in the kernel module. An optimizer, like the one Andrew Scott wrote, allows reduction rules to be written for the new kernel in the optimizers module to produce a nice tight kernel. Rob