Annotation of gforth/kernel/cond-old.fs, revision 1.2

1.1       anton       1: \ Structural Conditionals                              12dec92py
                      2: 
1.2     ! anton       3: \ Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
1.1       anton       4: 
                      5: \ This file is part of Gforth.
                      6: 
                      7: \ Gforth is free software; you can redistribute it and/or
                      8: \ modify it under the terms of the GNU General Public License
                      9: \ as published by the Free Software Foundation; either version 2
                     10: \ of the License, or (at your option) any later version.
                     11: 
                     12: \ This program is distributed in the hope that it will be useful,
                     13: \ but WITHOUT ANY WARRANTY; without even the implied warranty of
                     14: \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     15: \ GNU General Public License for more details.
                     16: 
                     17: \ You should have received a copy of the GNU General Public License
                     18: \ along with this program; if not, write to the Free Software
                     19: \ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
                     20: 
                     21: 0 constant defstart
                     22: 
                     23: : ?struc      ( flag -- )       abort" unstructured " ;
                     24: : sys?        ( sys -- )        dup 0= ?struc ;
                     25: : >mark       ( -- sys )        here  0 , ;
                     26: : >resolve    ( sys -- )        here over - swap ! ;
                     27: : <resolve    ( sys -- )        here - , ;
                     28: 
                     29: : BUT       sys? swap ;                      immediate restrict
                     30: : YET       sys? dup ;                       immediate restrict
                     31: 
                     32: \ Structural Conditionals                              12dec92py
                     33: 
                     34: : AHEAD     compile branch >mark ;           immediate restrict
                     35: : IF        compile ?branch >mark ;          immediate restrict
                     36: : THEN      sys? dup @ ?struc >resolve ;     immediate restrict
                     37: : ELSE      sys? compile AHEAD swap compile THEN ;
                     38:                                              immediate restrict
                     39: 
                     40: ' THEN Alias ENDIF immediate restrict
                     41: 
                     42: : BEGIN     here ;                           immediate restrict
                     43: : WHILE     sys? compile IF swap ;           immediate restrict
                     44: : AGAIN     sys? compile branch  <resolve ;  immediate restrict
                     45: : UNTIL     sys? compile ?branch <resolve ;  immediate restrict
                     46: : REPEAT    over 0= ?struc compile AGAIN compile THEN ;
                     47:                                              immediate restrict
                     48: 
                     49: \ Structural Conditionals                              12dec92py
                     50: 
                     51: Variable leavings
                     52: 
                     53: : (leave)   here  leavings @ ,  leavings ! ;
                     54: : LEAVE     compile branch  (leave) ;  immediate restrict
                     55: : ?LEAVE    compile 0= compile ?branch  (leave) ;
                     56:                                              immediate restrict
                     57: 
                     58: : DONE   ( addr -- )  leavings @
                     59:   BEGIN  2dup u<=  WHILE  dup @ swap >resolve  REPEAT
                     60:   leavings ! drop ;                          immediate restrict
                     61: 
                     62: \ Structural Conditionals                              12dec92py
                     63: 
                     64: : DO        compile (do)   here ;            immediate restrict
                     65: 
                     66: : ?DO       compile (?do)  (leave) here ;
                     67:                                              immediate restrict
                     68: : FOR       compile (for)  here ;            immediate restrict
                     69: 
                     70: : loop]     dup <resolve 2 cells - compile done compile unloop ;
                     71: 
                     72: : LOOP      sys? compile (loop)  loop] ;     immediate restrict
                     73: : +LOOP     sys? compile (+loop) loop] ;     immediate restrict
                     74: : NEXT      sys? compile (next)  loop] ;     immediate restrict
                     75: 
                     76: : EXIT compile ;s ; immediate restrict
                     77: : ?EXIT postpone IF postpone EXIT postpone THEN ; immediate restrict
                     78: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>