tools-ext.txt


\ tools-ext 97.12.7 1:35 am NAB

: [THEN] ( --) ; immediate

variable 'else
: [ELSE] ( --)
  'else @ execute ; immediate

variable 'if
variable ifdepth
: [IF] ( flag --)  0 ifdepth !
  'if @ execute ; immediate

: ([if]) ( flag --)
  if  exit  then
  1 ifdepth +!
  begin
    begin
    bl word  dup c@  while
      dup 1+ c@ [char] [ =
      if  find  else  0  then
      if  dup  ['] [if] = if  0 recurse  then
        dup  ['] [else] =  ifdepth @ 1 =  and
        swap  ['] [then] =  or
        if  -1 ifdepth +!  exit  then
      else  drop  then
    repeat drop
  refill 0= until ;

: ([else]) ( --)  1 ifdepth !  0 ([if]) ;

' ([if]) 'if !
' ([else]) 'else !


  HTMLized by Forth2HTML