Next: Recognizers, Previous: Interpret/Compile states, Up: The Text Interpreter [Contents][Index]
These words are usually used in interpret state; typically to control which parts of a source file are processed by the text interpreter. There are only a few Standard Forth Standard words, but Gforth supplements these with a rich set of immediate control structure words to compensate for the fact that the non-immediate versions can only be used in compile state (see Control Structures). Typical usages:
FALSE Constant HAVE-ASSEMBLER . . HAVE-ASSEMBLER [IF] : ASSEMBLER-FEATURE ... ; [ENDIF] . . : SEE ... \ general-purpose SEE code [ HAVE-ASSEMBLER [IF] ] ... \ assembler-specific SEE code [ [ENDIF] ] ;
[IF]
( flag – ) tools-ext “bracket-if”
If flag is TRUE
do nothing (and therefore
execute subsequent words as normal). If flag is FALSE
,
parse and discard words from the parse
area (refilling it if necessary using
REFILL
) including nested instances of [IF]
..
[ELSE]
.. [THEN]
and [IF]
.. [THEN]
until the balancing [ELSE]
or [THEN]
has been
parsed and discarded. Immediate word.
[ELSE]
( – ) tools-ext “bracket-else”
Parse and discard words from the parse
area (refilling it if necessary using
REFILL
) including nested instances of [IF]
..
[ELSE]
.. [THEN]
and [IF]
.. [THEN]
until the balancing [THEN]
has been parsed and discarded.
[ELSE]
only gets executed if the balancing [IF]
was TRUE
; if it was FALSE
, [IF]
would
have parsed and discarded the [ELSE]
, leaving the
subsequent words to be executed as normal.
Immediate word.
[THEN]
( – ) tools-ext “bracket-then”
Do nothing; used as a marker for other words to parse and discard up to. Immediate word.
[ENDIF]
( – ) gforth-0.4 “bracket-end-if”
Do nothing; synonym for [THEN]
[IFDEF]
( "<spaces>name" – ) gforth-0.4 “bracket-if-def”
If name is found in the current search-order, behave like
[IF]
with a TRUE
flag, otherwise behave like
[IF]
with a FALSE
flag. Immediate word.
[IFUNDEF]
( "<spaces>name" – ) gforth-0.4 “bracket-if-un-def”
If name is not found in the current search-order, behave like
[IF]
with a TRUE
flag, otherwise behave like
[IF]
with a FALSE
flag. Immediate word.
[?DO]
( n-limit n-index – ) gforth-0.4 “bracket-question-do”
[DO]
( n-limit n-index – ) gforth-0.4 “bracket-do”
[FOR]
( n – ) gforth-0.4 “bracket-for”
[LOOP]
( – ) gforth-0.4 “bracket-loop”
[+LOOP]
( n – ) gforth-0.4 “bracket-question-plus-loop”
[NEXT]
( n – ) gforth-0.4 “bracket-next”
[BEGIN]
( – ) gforth-0.4 “bracket-begin”
[UNTIL]
( flag – ) gforth-0.4 “bracket-until”
[AGAIN]
( – ) gforth-0.4 “bracket-again”
[WHILE]
( flag – ) gforth-0.4 “bracket-while”
[REPEAT]
( – ) gforth-0.4 “bracket-repeat”
Next: Recognizers, Previous: Interpret/Compile states, Up: The Text Interpreter [Contents][Index]