Annotation of gforth/kernel/files.fs, revision 1.1

1.1     ! anton       1: \ File specifiers                                       11jun93jaw
        !             2: 
        !             3: \ Copyright (C) 1995-1997 Free Software Foundation, Inc.
        !             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: 4 Constant w/o ( -- fam ) \ file       w-o
        !            22: 2 Constant r/w ( -- fam ) \ file       r-w
        !            23: 0 Constant r/o ( -- fam ) \ file       r-o
        !            24: 
        !            25: : bin ( fam1 -- fam2 ) \ file
        !            26:     1 or ;
        !            27: 
        !            28: \ BIN WRITE-LINE                                        11jun93jaw
        !            29: 
        !            30: : write-line ( c-addr u fileid -- ior ) \ file
        !            31:     dup >r write-file
        !            32:     ?dup IF
        !            33:        r> drop EXIT
        !            34:     THEN
        !            35:     #lf r> emit-file ;
        !            36: 
        !            37: \ include-file                                         07apr93py
        !            38: 
        !            39: : push-file  ( -- )  r>
        !            40:   sourceline# >r  loadfile @ >r
        !            41:   blk @ >r  tibstack @ >r  >tib @ >r  #tib @ >r
        !            42:   >tib @ tibstack @ = IF  r@ tibstack +!  THEN
        !            43:   tibstack @ >tib ! >in @ >r  >r ;
        !            44: 
        !            45: : pop-file   ( throw-code -- throw-code )
        !            46:   dup IF
        !            47:          source >in @ sourceline# sourcefilename
        !            48:         error-stack dup @ dup 1+
        !            49:         max-errors 1- min error-stack !
        !            50:         6 * cells + cell+
        !            51:         5 cells bounds swap DO
        !            52:                            I !
        !            53:         -1 cells +LOOP
        !            54:   THEN
        !            55:   r>
        !            56:   r> >in !  r> #tib !  r> >tib !  r> tibstack !  r> blk !
        !            57:   r> loadfile ! r> loadline !  >r ;
        !            58: 
        !            59: : read-loop ( i*x -- j*x )
        !            60:   BEGIN  refill  WHILE  interpret  REPEAT ;
        !            61: 
        !            62: : include-file ( i*x fid -- j*x ) \ file
        !            63:   push-file  loadfile !
        !            64:   0 loadline ! blk off  ['] read-loop catch
        !            65:   loadfile @ close-file swap 2dup or
        !            66:   pop-file  drop throw throw ;
        !            67: 
        !            68: \ additional words only needed if there is file support
        !            69: 
        !            70: : ( ( compilation 'ccc<close-paren>' -- ; run-time -- ) \ core,file    paren
        !            71:     loadfile @ 0= IF  postpone (  EXIT  THEN
        !            72:     BEGIN
        !            73:        >in @
        !            74:        [char] ) parse nip
        !            75:        >in @ rot - = \ is there no delimter?
        !            76:     WHILE
        !            77:        refill 0=
        !            78:        IF
        !            79:            warnings @
        !            80:            IF
        !            81:                ." warning: ')' missing" cr
        !            82:            THEN
        !            83:            EXIT
        !            84:        THEN
        !            85:     REPEAT ; immediate
        !            86: 

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