The other day I thought about implementing conditional
compilation with state information stored into the
wordlist stack. So we get by with one control structure,
an IF.
In the following VOCABULARY is a defining word that pushes
a wid, like so (untested)
: VOCABULARY CREATE WID , DOES> >R GET-ORDER 1+ R> @[EMAIL PROTECTED]
SWAP SET-ORDER ;
And ALIASED takes an execution token and a string and creates
a definition with that name and the same execution behaviour.
PREFIX matches a word if it starts with the prefix.
The code below is to convey the idea. It has not been tested.
\ ---------------------------
VOCABULARY SKIPPING-TE
SKIPPING-TE DEFINITIONS PREVIOUS
'NOOP "" ALIASED PREFIX
'PREVIOUS "[ELSE]" ALIASED
DEFINITIONS
VOCABULARY SKIPPING-TT
SKIPPING-TT DEFINITIONS PREVIOUS
'NOOP "" ALIASED PREFIX
'PREVIOUS "[THEN]" ALIAS
DEFINITIONS
: [IF] 0= IF SKIPPING-TE THEN ;
: [ELSE] SKIPPING-TT ;
: [THEN] ;
DEFINITIONS
\ ---------------------------
So while (skipping till then)
SKIPPING-TT
is the topmost wid, only
[THEN]
is recognized, and other words are ignored, because they match
the prefix.
In ugly Forths you may have to replace 'NOOP by
' NOOP (or ['] NOOP , I always forget) and
"[THEN]" by S" [THEN]" ).
Groetjes Albert
--
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- like all pyramid schemes -- ultimately falters.
albert@[EMAIL PROTECTED]
&=n http://home.hccnet.nl/a.w.m.van.der.horst


|