Annotation of gforth/kernel/int.fs, revision 1.110

1.1       pazsan      1: \ definitions needed for interpreter only
                      2: 
1.90      anton       3: \ Copyright (C) 1995-2000 Free Software Foundation, Inc.
1.11      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
1.63      anton      19: \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
1.11      anton      20: 
1.1       pazsan     21: \ \ Revision-Log
                     22: 
                     23: \       put in seperate file                           14sep97jaw 
                     24: 
                     25: \ \ input stream primitives                            23feb93py
                     26: 
1.33      jwilke     27: require ./basics.fs    \ bounds decimal hex ...
                     28: require ./io.fs                \ type ...
                     29: require ./nio.fs       \ . <# ...
                     30: require ./errore.fs    \ .error ...
1.50      anton      31: require kernel/version.fs      \ version-string
1.33      jwilke     32: require ./../chains.fs
                     33: 
1.64      pazsan     34: has? new-input 0= [IF]
1.43      crook      35: : tib ( -- c-addr ) \ core-ext t-i-b
1.40      crook      36:     \G @i{c-addr} is the address of the Terminal Input Buffer.
1.29      crook      37:     \G OBSOLESCENT: @code{source} superceeds the function of this word.
1.1       pazsan     38:     >tib @ ;
                     39: 
1.29      crook      40: Defer source ( -- c-addr u ) \ core
1.1       pazsan     41: \ used by dodefer:, must be defer
1.40      crook      42: \G @i{c-addr} is the address of the input buffer and @i{u} is the
1.29      crook      43: \G number of characters in it.
1.1       pazsan     44: 
1.29      crook      45: : (source) ( -- c-addr u )
1.1       pazsan     46:     tib #tib @ ;
                     47: ' (source) IS source
1.64      pazsan     48: [THEN]
1.1       pazsan     49: 
                     50: : (word) ( addr1 n1 char -- addr2 n2 )
                     51:   dup >r skip 2dup r> scan  nip - ;
                     52: 
                     53: \ (word) should fold white spaces
                     54: \ this is what (parse-white) does
                     55: 
                     56: \ word parse                                           23feb93py
                     57: 
1.29      crook      58: : sword  ( char -- addr len ) \ gforth s-word
1.40      crook      59:     \G Parses like @code{word}, but the output is like @code{parse} output.
1.47      anton      60:     \G @xref{core-idef}.
1.3       anton      61:   \ this word was called PARSE-WORD until 0.3.0, but Open Firmware and
                     62:   \ dpANS6 A.6.2.2008 have a word with that name that behaves
                     63:   \ differently (like NAME).
1.1       pazsan     64:   source 2dup >r >r >in @ over min /string
                     65:   rot dup bl = IF  drop (parse-white)  ELSE  (word)  THEN
                     66:   2dup + r> - 1+ r> min >in ! ;
                     67: 
1.29      crook      68: : word   ( char "<chars>ccc<char>-- c-addr ) \ core
1.40      crook      69:     \G Skip leading delimiters. Parse @i{ccc}, delimited by
                     70:     \G @i{char}, in the parse area. @i{c-addr} is the address of a
1.29      crook      71:     \G transient region containing the parsed string in
1.40      crook      72:     \G counted-string format. If the parse area was empty or
1.29      crook      73:     \G contained no characters other than delimiters, the resulting
                     74:     \G string has zero length. A program may replace characters within
                     75:     \G the counted string. OBSOLESCENT: the counted string has a
                     76:     \G trailing space that is not included in its length.
                     77:     sword here place  bl here count + c!  here ;
                     78: 
                     79: : parse    ( char "ccc<char>" -- c-addr u ) \ core-ext
1.80      anton      80: \G Parse @i{ccc}, delimited by @i{char}, in the parse
                     81: \G area. @i{c-addr u} specifies the parsed string within the
                     82: \G parse area. If the parse area was empty, @i{u} is 0.
1.29      crook      83:     >r  source  >in @ over min /string  over  swap r>  scan >r
1.80      anton      84:     over - dup r> IF 1+ THEN  >in +! ;
1.1       pazsan     85: 
                     86: \ name                                                 13feb93py
                     87: 
                     88: [IFUNDEF] (name) \ name might be a primitive
                     89: 
1.40      crook      90: : (name) ( -- c-addr count ) \ gforth
1.1       pazsan     91:     source 2dup >r >r >in @ /string (parse-white)
                     92:     2dup + r> - 1+ r> min >in ! ;
                     93: \    name count ;
                     94: [THEN]
                     95: 
                     96: : name-too-short? ( c-addr u -- c-addr u )
                     97:     dup 0= -&16 and throw ;
                     98: 
                     99: : name-too-long? ( c-addr u -- c-addr u )
1.67      anton     100:     dup lcount-mask u> -&19 and throw ;
1.1       pazsan    101: 
                    102: \ \ Number parsing                                     23feb93py
                    103: 
                    104: \ number? number                                       23feb93py
                    105: 
                    106: hex
1.110   ! anton     107: const Create bases   0A , 10 ,   2 ,   0A ,
1.109     anton     108: \                    10   16     2     10
1.1       pazsan    109: 
1.18      anton     110: \ !! protect BASE saving wrapper against exceptions
1.1       pazsan    111: : getbase ( addr u -- addr' u' )
1.108     anton     112:     2dup s" 0x" string-prefix? >r
                    113:     2dup s" 0X" string-prefix? r> or
1.110   ! anton     114:     base @ #34 < and if
1.108     anton     115:        hex 2 /string
                    116:     endif
1.109     anton     117:     over c@ [char] # - dup 4 u<
1.1       pazsan    118:     IF
                    119:        cells bases + @ base ! 1 /string
                    120:     ELSE
                    121:        drop
                    122:     THEN ;
                    123: 
1.20      pazsan    124: : sign? ( addr u -- addr u flag )
1.33      jwilke    125:     over c@ [char] - =  dup >r
1.1       pazsan    126:     IF
                    127:        1 /string
                    128:     THEN
1.20      pazsan    129:     r> ;
                    130: 
1.109     anton     131: : s'>unumber? ( addr u -- ud flag )
                    132:     \ convert string "C" or "C'" to character code
                    133:     dup 0= if
                    134:        false exit
                    135:     endif
                    136:     over c@ >r
                    137:     1 /string s" '" 2swap string-prefix?
                    138:     r> 0 rot ;
                    139: 
1.20      pazsan    140: : s>unumber? ( addr u -- ud flag )
1.109     anton     141:     over c@ '' = if
                    142:        1 /string s'>unumber? exit
                    143:     endif
1.21      pazsan    144:     base @ >r  dpl on  getbase
1.20      pazsan    145:     0. 2swap
1.18      anton     146:     BEGIN ( d addr len )
1.1       pazsan    147:        dup >r >number dup
1.18      anton     148:     WHILE \ there are characters left
1.1       pazsan    149:        dup r> -
1.18      anton     150:     WHILE \ the last >number parsed something
                    151:        dup 1- dpl ! over c@ [char] . =
                    152:     WHILE \ the current char is '.'
1.1       pazsan    153:        1 /string
1.18      anton     154:     REPEAT  THEN \ there are unparseable characters left
1.21      pazsan    155:        2drop false
1.20      pazsan    156:     ELSE
                    157:        rdrop 2drop true
1.21      pazsan    158:     THEN
                    159:     r> base ! ;
1.20      pazsan    160: 
                    161: \ ouch, this is complicated; there must be a simpler way - anton
                    162: : s>number? ( addr len -- d f )
                    163:     \ converts string addr len into d, flag indicates success
1.21      pazsan    164:     sign? >r
1.20      pazsan    165:     s>unumber?
                    166:     0= IF
1.21      pazsan    167:         rdrop false
1.18      anton     168:     ELSE \ no characters left, all ok
1.20      pazsan    169:        r>
1.1       pazsan    170:        IF
                    171:            dnegate
                    172:        THEN
1.18      anton     173:        true
1.21      pazsan    174:     THEN ;
1.1       pazsan    175: 
1.18      anton     176: : s>number ( addr len -- d )
                    177:     \ don't use this, there is no way to tell success
                    178:     s>number? drop ;
                    179: 
1.1       pazsan    180: : snumber? ( c-addr u -- 0 / n -1 / d 0> )
1.18      anton     181:     s>number? 0=
1.1       pazsan    182:     IF
                    183:        2drop false  EXIT
                    184:     THEN
1.18      anton     185:     dpl @ dup 0< IF
1.1       pazsan    186:        nip
1.18      anton     187:     ELSE
                    188:        1+
1.1       pazsan    189:     THEN ;
                    190: 
                    191: : number? ( string -- string 0 / n -1 / d 0> )
                    192:     dup >r count snumber? dup if
                    193:        rdrop
                    194:     else
                    195:        r> swap
                    196:     then ;
                    197: 
                    198: : number ( string -- d )
                    199:     number? ?dup 0= abort" ?"  0<
                    200:     IF
                    201:        s>d
                    202:     THEN ;
                    203: 
                    204: \ \ Comments ( \ \G
                    205: 
1.29      crook     206: : ( ( compilation 'ccc<close-paren>' -- ; run-time -- ) \ thisone- core,file   paren
1.17      crook     207:     \G ** this will not get annotated. The alias in glocals.fs will instead **
1.29      crook     208:     \G It does not work to use "wordset-" prefix since this file is glossed
                    209:     \G by cross.fs which doesn't have the same functionalty as makedoc.fs
1.1       pazsan    210:     [char] ) parse 2drop ; immediate
                    211: 
1.51      anton     212: : \ ( compilation 'ccc<newline>' -- ; run-time -- ) \ thisone- core-ext,block-ext backslash
1.29      crook     213:     \G ** this will not get annotated. The alias in glocals.fs will instead ** 
                    214:     \G It does not work to use "wordset-" prefix since this file is glossed
                    215:     \G by cross.fs which doesn't have the same functionalty as makedoc.fs
1.12      pazsan    216:     [ has? file [IF] ]
1.1       pazsan    217:     blk @
                    218:     IF
                    219:        >in @ c/l / 1+ c/l * >in !
                    220:        EXIT
                    221:     THEN
1.12      pazsan    222:     [ [THEN] ]
1.1       pazsan    223:     source >in ! drop ; immediate
                    224: 
1.51      anton     225: : \G ( compilation 'ccc<newline>' -- ; run-time -- ) \ gforth backslash-gee
1.19      crook     226:     \G Equivalent to @code{\} but used as a tag to annotate definition
                    227:     \G comments into documentation.
1.1       pazsan    228:     POSTPONE \ ; immediate
                    229: 
                    230: \ \ object oriented search list                         17mar93py
                    231: 
                    232: \ word list structure:
                    233: 
                    234: struct
                    235:   cell% field find-method   \ xt: ( c_addr u wid -- nt )
                    236:   cell% field reveal-method \ xt: ( nt wid -- ) \ used by dofield:, must be field
                    237:   cell% field rehash-method \ xt: ( wid -- )      \ re-initializes a "search-data" (hashtables)
                    238:   cell% field hash-method   \ xt: ( wid -- )    \ initializes ""
                    239: \   \ !! what else
                    240: end-struct wordlist-map-struct
                    241: 
                    242: struct
1.6       pazsan    243:   cell% field wordlist-map \ pointer to a wordlist-map-struct
1.13      anton     244:   cell% field wordlist-id \ linked list of words (for WORDS etc.)
1.1       pazsan    245:   cell% field wordlist-link \ link field to other wordlists
1.13      anton     246:   cell% field wordlist-extend \ wordlist extensions (eg bucket offset)
1.1       pazsan    247: end-struct wordlist-struct
                    248: 
1.103     pazsan    249: has? f83headerstring [IF]
                    250: : f83find      ( addr len wordlist -- nt / false )
                    251:     wordlist-id @ (f83find) ;
                    252: [ELSE]
1.1       pazsan    253: : f83find      ( addr len wordlist -- nt / false )
1.67      anton     254:     wordlist-id @ (listlfind) ;
1.103     pazsan    255: [THEN]
1.1       pazsan    256: 
                    257: : initvoc              ( wid -- )
                    258:   dup wordlist-map @ hash-method perform ;
                    259: 
                    260: \ Search list table: find reveal
                    261: Create f83search ( -- wordlist-map )
                    262:     ' f83find A,  ' drop A,  ' drop A, ' drop A,
                    263: 
1.6       pazsan    264: here G f83search T A, NIL A, NIL A, NIL A,
1.1       pazsan    265: AValue forth-wordlist \ variable, will be redefined by search.fs
                    266: 
                    267: AVariable lookup               forth-wordlist lookup !
                    268: \ !! last is user and lookup?! jaw
                    269: AVariable current ( -- addr ) \ gforth
1.43      crook     270: \G @code{Variable} -- holds the @i{wid} of the compilation word list.
1.1       pazsan    271: AVariable voclink      forth-wordlist wordlist-link voclink !
1.38      anton     272: \ lookup AValue context ( -- addr ) \ gforth
                    273: Defer context ( -- addr ) \ gforth
1.43      crook     274: \G @code{context} @code{@@} is the @i{wid} of the word list at the
                    275: \G top of the search order.
1.1       pazsan    276: 
1.38      anton     277: ' lookup is context
1.1       pazsan    278: forth-wordlist current !
                    279: 
                    280: \ \ header, finding, ticks                              17dec92py
                    281: 
1.69      pazsan    282: \ The constants are defined as 32 bits, but then erased
                    283: \ and overwritten by the right ones
1.67      anton     284: 
1.103     pazsan    285: has? f83headerstring [IF]
                    286:     \ to save space, Gforth EC limits words to 31 characters
                    287:     $80 constant alias-mask
                    288:     $40 constant immediate-mask
                    289:     $20 constant restrict-mask
                    290:     $1f constant lcount-mask
                    291: [ELSE]    
1.67      anton     292: $80000000 constant alias-mask
1.69      pazsan    293: 1 bits/char 1 - lshift
                    294: -1 cells allot  bigendian [IF]   c, 0 1 cells 1- times
                    295:                           [ELSE] 0 1 cells 1- times c, [THEN]
1.67      anton     296: $40000000 constant immediate-mask
1.69      pazsan    297: 1 bits/char 2 - lshift
                    298: -1 cells allot  bigendian [IF]   c, 0 1 cells 1- times
                    299:                           [ELSE] 0 1 cells 1- times c, [THEN]
1.67      anton     300: $20000000 constant restrict-mask
1.69      pazsan    301: 1 bits/char 3 - lshift
                    302: -1 cells allot  bigendian [IF]   c, 0 1 cells 1- times
                    303:                           [ELSE] 0 1 cells 1- times c, [THEN]
1.67      anton     304: $1fffffff constant lcount-mask
1.69      pazsan    305: 1 bits/char 3 - lshift 1 -
1.71      pazsan    306: -1 cells allot  bigendian [IF]   c, -1 1 cells 1- times
                    307:                           [ELSE] -1 1 cells 1- times c, [THEN]
1.103     pazsan    308: [THEN]
1.1       pazsan    309: 
                    310: \ higher level parts of find
                    311: 
                    312: : flag-sign ( f -- 1|-1 )
                    313:     \ true becomes 1, false -1
                    314:     0= 2* 1+ ;
                    315: 
1.79      anton     316: : ticking-compile-only-error ( ... -- )
                    317:     -&2048 throw ;
1.1       pazsan    318: 
1.93      anton     319: : compile-only-error ( ... -- )
                    320:     -&14 throw ;
                    321: 
1.1       pazsan    322: : (cfa>int) ( cfa -- xt )
                    323: [ has? compiler [IF] ]
                    324:     dup interpret/compile?
                    325:     if
                    326:        interpret/compile-int @
                    327:     then 
                    328: [ [THEN] ] ;
                    329: 
1.67      anton     330: : (x>int) ( cfa w -- xt )
1.1       pazsan    331:     \ get interpretation semantics of name
                    332:     restrict-mask and
                    333:     if
1.93      anton     334:        drop ['] compile-only-error
1.1       pazsan    335:     else
                    336:        (cfa>int)
                    337:     then ;
                    338: 
1.103     pazsan    339: has? f83headerstring [IF]
                    340: : name>string ( nt -- addr count ) \ gforth     head-to-string
                    341:     \g @i{addr count} is the name of the word represented by @i{nt}.
                    342:     cell+ count lcount-mask and ;
                    343: 
                    344: : ((name>))  ( nfa -- cfa )
                    345:     name>string + cfaligned ;
                    346: 
                    347: : (name>x) ( nfa -- cfa w )
                    348:     \ cfa is an intermediate cfa and w is the flags cell of nfa
                    349:     dup ((name>))
                    350:     swap cell+ c@ dup alias-mask and 0=
                    351:     IF
                    352:         swap @ swap
                    353:     THEN ;
                    354: [ELSE]
1.1       pazsan    355: : name>string ( nt -- addr count ) \ gforth     head-to-string
1.40      crook     356:     \g @i{addr count} is the name of the word represented by @i{nt}.
1.67      anton     357:     cell+ dup cell+ swap @ lcount-mask and ;
1.1       pazsan    358: 
                    359: : ((name>))  ( nfa -- cfa )
                    360:     name>string + cfaligned ;
                    361: 
1.67      anton     362: : (name>x) ( nfa -- cfa w )
                    363:     \ cfa is an intermediate cfa and w is the flags cell of nfa
1.1       pazsan    364:     dup ((name>))
1.67      anton     365:     swap cell+ @ dup alias-mask and 0=
1.1       pazsan    366:     IF
                    367:         swap @ swap
                    368:     THEN ;
1.103     pazsan    369: [THEN]
1.1       pazsan    370: 
                    371: : name>int ( nt -- xt ) \ gforth
1.31      crook     372:     \G @i{xt} represents the interpretation semantics of the word
                    373:     \G @i{nt}. If @i{nt} has no interpretation semantics (i.e. is
                    374:     \G @code{compile-only}), @i{xt} is the execution token for
1.79      anton     375:     \G @code{ticking-compile-only-error}, which performs @code{-2048 throw}.
1.1       pazsan    376:     (name>x) (x>int) ;
                    377: 
                    378: : name?int ( nt -- xt ) \ gforth
1.79      anton     379:     \G Like @code{name>int}, but perform @code{-2048 throw} if @i{nt}
1.31      crook     380:     \G has no interpretation semantics.
1.1       pazsan    381:     (name>x) restrict-mask and
                    382:     if
1.79      anton     383:        ticking-compile-only-error \ does not return
1.1       pazsan    384:     then
                    385:     (cfa>int) ;
                    386: 
                    387: : (name>comp) ( nt -- w +-1 ) \ gforth
1.31      crook     388:     \G @i{w xt} is the compilation token for the word @i{nt}.
1.1       pazsan    389:     (name>x) >r 
                    390: [ has? compiler [IF] ]
                    391:     dup interpret/compile?
                    392:     if
                    393:         interpret/compile-comp @
                    394:     then 
                    395: [ [THEN] ]
                    396:     r> immediate-mask and flag-sign
                    397:     ;
                    398: 
                    399: : (name>intn) ( nfa -- xt +-1 )
1.67      anton     400:     (name>x) tuck (x>int) ( w xt )
1.1       pazsan    401:     swap immediate-mask and flag-sign ;
                    402: 
1.72      pazsan    403: const Create ???  0 , 3 , char ? c, char ? c, char ? c,
1.30      jwilke    404: \ ??? is used by dovar:, must be created/:dovar
                    405: 
                    406: [IFDEF] forthstart
                    407: \ if we have a forthstart we can define head? with it
                    408: \ otherwise leave out the head? check
                    409: 
1.14      anton     410: : head? ( addr -- f )
1.82      anton     411: \G heuristic check whether addr is a name token; may deliver false
                    412: \G positives; addr must be a valid address; returns 1 for
                    413: \G particularly unsafe positives
1.14      anton     414:     \ we follow the link fields and check for plausibility; two
                    415:     \ iterations should catch most false addresses: on the first
                    416:     \ iteration, we may get an xt, on the second a code address (or
                    417:     \ some code), which is typically not in the dictionary.
1.82      anton     418:     \ we added a third iteration for working with code and ;code words.
                    419:     3 0 do
1.41      anton     420:        dup dup aligned <> if \ protect @ against unaligned accesses
                    421:            drop false unloop exit
                    422:        then
1.14      anton     423:        dup @ dup
                    424:        if ( addr addr1 )
                    425:            dup rot forthstart within
                    426:            if \ addr1 is outside forthstart..addr, not a head
                    427:                drop false unloop exit
                    428:            then ( addr1 )
                    429:        else \ 0 in the link field, no further checks
1.81      anton     430:            2drop 1 unloop exit \ this is very unsure, so return 1
1.14      anton     431:        then
                    432:     loop
                    433:     \ in dubio pro:
                    434:     drop true ;
                    435: 
1.48      anton     436: : >head-noprim ( cfa -- nt ) \ gforth  to-head-noprim
1.97      anton     437:     \ also heuristic
                    438:     dup forthstart - max-name-length @ float+ cell+ min cell max cell ?do ( cfa )
1.70      pazsan    439:        dup i - dup @ [ alias-mask lcount-mask or ] literal
                    440:        [ 1 bits/char 3 - lshift 1 - 1 bits/char 1 - lshift or
1.71      pazsan    441:        -1 cells allot bigendian [IF]   c, -1 1 cells 1- times
                    442:        [ELSE] -1 1 cells 1- times c, [THEN] ]
1.70      pazsan    443:        and ( cfa len|alias )
1.97      anton     444:        swap + cell+ cfaligned over alias-mask + =
1.14      anton     445:        if ( cfa )
                    446:            dup i - cell - dup head?
                    447:            if
                    448:                nip unloop exit
                    449:            then
                    450:            drop
                    451:        then
                    452:        cell +loop
                    453:     drop ??? ( wouldn't 0 be better? ) ;
1.1       pazsan    454: 
1.30      jwilke    455: [ELSE]
                    456: 
1.48      anton     457: : >head-noprim ( cfa -- nt ) \ gforth  to-head-noprim
1.45      pazsan    458:     $25 cell do ( cfa )
1.70      pazsan    459:        dup i - dup @ [ alias-mask lcount-mask or ] literal
                    460:        [ 1 bits/char 3 - lshift 1 - 1 bits/char 1 - lshift or
1.71      pazsan    461:        -1 cells allot bigendian [IF]   c, -1 1 cells 1- times
                    462:        [ELSE] -1 1 cells 1- times c, [THEN] ]
1.70      pazsan    463:        and ( cfa len|alias )
1.67      anton     464:        swap + cell + cfaligned over alias-mask + =
1.30      jwilke    465:        if ( cfa ) i - cell - unloop exit
                    466:        then
                    467:        cell +loop
                    468:     drop ??? ( wouldn't 0 be better? ) ;
                    469: 
                    470: [THEN]
1.1       pazsan    471: 
1.83      anton     472: cell% 2* 0 0 field >body ( xt -- a_addr ) \ core
                    473: \G Get the address of the body of the word represented by @i{xt} (the
                    474: \G address of the word's data field).
                    475: drop drop
                    476: 
                    477: cell% -2 * 0 0 field body> ( xt -- a_addr )
1.84      anton     478:     drop drop
                    479: 
                    480: has? standardthreading has? compiler and [IF]
                    481: 
                    482: ' @ alias >code-address ( xt -- c_addr ) \ gforth
                    483: \G @i{c-addr} is the code address of the word @i{xt}.
                    484: 
                    485: : >does-code ( xt -- a_addr ) \ gforth
                    486: \G If @i{xt} is the execution token of a child of a @code{DOES>} word,
                    487: \G @i{a-addr} is the start of the Forth code after the @code{DOES>};
                    488: \G Otherwise @i{a-addr} is 0.
                    489:     dup @ dodoes: = if
                    490:        cell+ @
                    491:     else
                    492:        drop 0
                    493:     endif ;
                    494: 
1.85      anton     495: ' ! alias code-address! ( c_addr xt -- ) \ gforth
                    496: \G Create a code field with code address @i{c-addr} at @i{xt}.
                    497: 
                    498: : does-code! ( a_addr xt -- ) \ gforth
                    499: \G Create a code field at @i{xt} for a child of a @code{DOES>}-word;
                    500: \G @i{a-addr} is the start of the Forth code after @code{DOES>}.
                    501:     dodoes: over ! cell+ ! ;
                    502: 
1.86      anton     503: ' drop alias does-handler! ( a_addr -- ) \ gforth
                    504: \G Create a @code{DOES>}-handler at address @i{a-addr}. Normally,
                    505: \G @i{a-addr} points just behind a @code{DOES>}.
                    506: 
1.85      anton     507: 2 cells constant /does-handler ( -- n ) \ gforth
                    508: \G The size of a @code{DOES>}-handler (includes possible padding).
                    509: 
1.84      anton     510: [THEN] 
1.1       pazsan    511: 
1.31      crook     512: : (search-wordlist)  ( addr count wid -- nt | false )
1.1       pazsan    513:     dup wordlist-map @ find-method perform ;
                    514: 
1.31      crook     515: : search-wordlist ( c-addr count wid -- 0 | xt +-1 ) \ search
1.53      anton     516:     \G Search the word list identified by @i{wid} for the definition
                    517:     \G named by the string at @i{c-addr count}.  If the definition is
                    518:     \G not found, return 0. If the definition is found return 1 (if
                    519:     \G the definition is immediate) or -1 (if the definition is not
                    520:     \G immediate) together with the @i{xt}.  In Gforth, the @i{xt}
                    521:     \G returned represents the interpretation semantics.  ANS Forth
                    522:     \G does not specify clearly what @i{xt} represents.
1.1       pazsan    523:     (search-wordlist) dup if
                    524:        (name>intn)
                    525:     then ;
                    526: 
1.31      crook     527: : find-name ( c-addr u -- nt | 0 ) \ gforth
                    528:     \g Find the name @i{c-addr u} in the current search
                    529:     \g order. Return its @i{nt}, if found, otherwise 0.
1.1       pazsan    530:     lookup @ (search-wordlist) ;
                    531: 
                    532: : sfind ( c-addr u -- 0 / xt +-1  ) \ gforth-obsolete
                    533:     find-name dup
                    534:     if ( nt )
                    535:        state @
                    536:        if
                    537:            (name>comp)
                    538:        else
                    539:            (name>intn)
                    540:        then
                    541:    then ;
                    542: 
1.31      crook     543: : find ( c-addr -- xt +-1 | c-addr 0 ) \ core,search
1.53      anton     544:     \G Search all word lists in the current search order for the
                    545:     \G definition named by the counted string at @i{c-addr}.  If the
                    546:     \G definition is not found, return 0. If the definition is found
                    547:     \G return 1 (if the definition has non-default compilation
                    548:     \G semantics) or -1 (if the definition has default compilation
                    549:     \G semantics).  The @i{xt} returned in interpret state represents
                    550:     \G the interpretation semantics.  The @i{xt} returned in compile
                    551:     \G state represented either the compilation semantics (for
                    552:     \G non-default compilation semantics) or the run-time semantics
                    553:     \G that the compilation semantics would @code{compile,} (for
                    554:     \G default compilation semantics).  The ANS Forth standard does
                    555:     \G not specify clearly what the returned @i{xt} represents (and
                    556:     \G also talks about immediacy instead of non-default compilation
                    557:     \G semantics), so this word is questionable in portable programs.
                    558:     \G If non-portability is ok, @code{find-name} and friends are
                    559:     \G better (@pxref{Name token}).
1.1       pazsan    560:     dup count sfind dup
                    561:     if
                    562:        rot drop
                    563:     then ;
                    564: 
1.34      jwilke    565: \ ticks in interpreter
1.1       pazsan    566: 
                    567: : (') ( "name" -- nt ) \ gforth
1.32      anton     568:     name name-too-short?
1.28      anton     569:     find-name dup 0=
1.1       pazsan    570:     IF
1.42      anton     571:        drop -&13 throw
1.1       pazsan    572:     THEN  ;
                    573: 
                    574: : '    ( "name" -- xt ) \ core tick
1.31      crook     575:     \g @i{xt} represents @i{name}'s interpretation
                    576:     \g semantics. Perform @code{-14 throw} if the word has no
1.1       pazsan    577:     \g interpretation semantics.
                    578:     (') name?int ;
1.34      jwilke    579: 
                    580: has? compiler 0= [IF]  \ interpreter only version of IS and TO
                    581: 
                    582: : IS ' >body ! ;
                    583: ' IS Alias TO
                    584: 
                    585: [THEN]
1.1       pazsan    586: 
                    587: \ \ the interpreter loop                                 mar92py
                    588: 
                    589: \ interpret                                            10mar92py
                    590: 
1.37      anton     591: Defer parser ( c-addr u -- )
1.100     anton     592: Defer parse-word ( "name" -- c-addr u ) \ gforth
1.55      anton     593: \G Get the next word from the input buffer
1.77      anton     594: ' (name) IS parse-word
                    595: 
                    596: ' parse-word alias name ( -- c-addr u ) \ gforth-obsolete
                    597: \G old name for @code{parse-word}
                    598: 
1.1       pazsan    599: Defer compiler-notfound ( c-addr count -- )
                    600: Defer interpreter-notfound ( c-addr count -- )
                    601: 
                    602: : no.extensions  ( addr u -- )
1.42      anton     603:     2drop -&13 throw ;
1.1       pazsan    604: ' no.extensions IS compiler-notfound
                    605: ' no.extensions IS interpreter-notfound
                    606: 
1.106     anton     607: Defer before-word ( -- ) \ gforth
                    608: \ called before the text interpreter parses the next word
                    609: ' noop IS before-word
                    610: 
1.66      anton     611: : interpret1 ( ... -- ... )
1.33      jwilke    612: [ has? backtrace [IF] ]
1.24      anton     613:     rp@ backtrace-rp0 !
1.33      jwilke    614: [ [THEN] ]
1.1       pazsan    615:     BEGIN
1.106     anton     616:        ?stack before-word name dup
1.1       pazsan    617:     WHILE
                    618:        parser
                    619:     REPEAT
1.66      anton     620:     2drop ;
                    621:     
                    622: : interpret ( ?? -- ?? ) \ gforth
                    623:     \ interpret/compile the (rest of the) input buffer
                    624: [ has? backtrace [IF] ]
                    625:     backtrace-rp0 @ >r 
                    626: [ [THEN] ]
                    627:     ['] interpret1 catch
1.65      anton     628: [ has? backtrace [IF] ]
                    629:     r> backtrace-rp0 !
1.66      anton     630:     [ [THEN] ]
                    631:     throw ;
1.1       pazsan    632: 
                    633: \ interpreter                                  30apr92py
                    634: 
                    635: \ not the most efficient implementations of interpreter and compiler
1.33      jwilke    636: : interpreter ( c-addr u -- ) 
1.1       pazsan    637:     2dup find-name dup
                    638:     if
                    639:        nip nip name>int execute
                    640:     else
                    641:        drop
                    642:        2dup 2>r snumber?
                    643:        IF
                    644:            2rdrop
                    645:        ELSE
                    646:            2r> interpreter-notfound
                    647:        THEN
                    648:     then ;
                    649: 
                    650: ' interpreter  IS  parser
                    651: 
                    652: \ \ Query Evaluate                                     07apr93py
                    653: 
                    654: has? file 0= [IF]
1.12      pazsan    655: : sourceline# ( -- n )  1 ;
1.61      pazsan    656: [ELSE]
1.64      pazsan    657: has? new-input 0= [IF]
1.58      pazsan    658: Variable #fill-bytes
                    659: \G number of bytes read via (read-line) by the last refill
1.61      pazsan    660: [THEN]
1.64      pazsan    661: [THEN]
1.58      pazsan    662: 
1.64      pazsan    663: has? new-input 0= [IF]
1.1       pazsan    664: : refill ( -- flag ) \ core-ext,block-ext,file-ext
1.29      crook     665:     \G Attempt to fill the input buffer from the input source.  When
                    666:     \G the input source is the user input device, attempt to receive
                    667:     \G input into the terminal input device. If successful, make the
                    668:     \G result the input buffer, set @code{>IN} to 0 and return true;
                    669:     \G otherwise return false. When the input source is a block, add 1
                    670:     \G to the value of @code{BLK} to make the next block the input
                    671:     \G source and current input buffer, and set @code{>IN} to 0;
                    672:     \G return true if the new value of @code{BLK} is a valid block
                    673:     \G number, false otherwise. When the input source is a text file,
                    674:     \G attempt to read the next line from the file. If successful,
                    675:     \G make the result the current input buffer, set @code{>IN} to 0
                    676:     \G and return true; otherwise, return false.  A successful result
                    677:     \G includes receipt of a line containing 0 characters.
1.12      pazsan    678:     [ has? file [IF] ]
                    679:        blk @  IF  1 blk +!  true  0 >in !  EXIT  THEN
                    680:        [ [THEN] ]
                    681:     tib /line
                    682:     [ has? file [IF] ]
                    683:        loadfile @ ?dup
1.59      pazsan    684:        IF    (read-line) throw #fill-bytes !
1.12      pazsan    685:        ELSE
                    686:            [ [THEN] ]
                    687:        sourceline# 0< IF 2drop false EXIT THEN
                    688:        accept true
                    689:        [ has? file [IF] ]
                    690:        THEN
                    691:        1 loadline +!
                    692:        [ [THEN] ]
                    693:     swap #tib ! 0 >in ! ;
1.1       pazsan    694: 
                    695: : query   ( -- ) \ core-ext
1.29      crook     696:     \G Make the user input device the input source. Receive input into
                    697:     \G the Terminal Input Buffer. Set @code{>IN} to zero. OBSOLESCENT:
                    698:     \G superceeded by @code{accept}.
1.12      pazsan    699:     [ has? file [IF] ]
                    700:        blk off loadfile off
                    701:        [ [THEN] ]
1.64      pazsan    702:     refill drop ;
                    703: [THEN]
1.1       pazsan    704: 
                    705: \ save-mem extend-mem
                    706: 
                    707: has? os [IF]
                    708: : save-mem     ( addr1 u -- addr2 u ) \ gforth
                    709:     \g copy a memory block into a newly allocated region in the heap
                    710:     swap >r
                    711:     dup allocate throw
                    712:     swap 2dup r> -rot move ;
                    713: 
1.68      anton     714: : free-mem-var ( addr -- )
                    715:     \ addr is the address of a 2variable containing address and size
                    716:     \ of a memory range; frees memory and clears the 2variable.
                    717:     dup 2@ drop dup
                    718:     if ( addr mem-start )
                    719:        free throw
                    720:        0 0 rot 2!
                    721:     else
                    722:        2drop
                    723:     then ;
                    724: 
1.1       pazsan    725: : extend-mem   ( addr1 u1 u -- addr addr2 u2 )
                    726:     \ extend memory block allocated from the heap by u aus
1.105     anton     727:     \ the (possibly reallocated) piece is addr2 u2, the extension is at addr
1.1       pazsan    728:     over >r + dup >r resize throw
                    729:     r> over r> + -rot ;
                    730: [THEN]
                    731: 
                    732: \ EVALUATE                                              17may93jaw
                    733: 
1.64      pazsan    734: has? file 0= has? new-input 0= and [IF]
1.1       pazsan    735: : push-file  ( -- )  r>
1.12      pazsan    736:   tibstack @ >r  >tib @ >r  #tib @ >r
1.1       pazsan    737:   >tib @ tibstack @ = IF  r@ tibstack +!  THEN
                    738:   tibstack @ >tib ! >in @ >r  >r ;
                    739: 
                    740: : pop-file   ( throw-code -- throw-code )
                    741:   r>
1.12      pazsan    742:   r> >in !  r> #tib !  r> >tib !  r> tibstack !  >r ;
1.1       pazsan    743: [THEN]
                    744: 
1.64      pazsan    745: has? new-input 0= [IF]
1.29      crook     746: : evaluate ( c-addr u -- ) \ core,block
1.40      crook     747:     \G Save the current input source specification. Store @code{-1} in
                    748:     \G @code{source-id} and @code{0} in @code{blk}. Set @code{>IN} to
                    749:     \G @code{0} and make the string @i{c-addr u} the input source
                    750:     \G and input buffer. Interpret. When the parse area is empty,
                    751:     \G restore the input source specification.
1.64      pazsan    752: [ has? file [IF] ]
1.92      anton     753:     s" *evaluated string*" loadfilename>r
1.64      pazsan    754: [ [THEN] ]
1.40      crook     755:     push-file #tib ! >tib !
1.29      crook     756:     >in off
                    757:     [ has? file [IF] ]
                    758:        blk off loadfile off -1 loadline !
                    759:        [ [THEN] ]
                    760:     ['] interpret catch
1.56      anton     761:     pop-file
1.64      pazsan    762: [ has? file [IF] ]
1.92      anton     763:     r>loadfilename
1.64      pazsan    764: [ [THEN] ]
1.56      anton     765:     throw ;
1.64      pazsan    766: [THEN]
1.1       pazsan    767: 
                    768: \ \ Quit                                               13feb93py
                    769: 
                    770: Defer 'quit
                    771: 
                    772: Defer .status
                    773: 
                    774: : prompt        state @ IF ."  compiled" EXIT THEN ."  ok" ;
                    775: 
1.39      anton     776: : (quit) ( -- )
                    777:     \ exits only through THROW etc.
                    778:     BEGIN
1.98      anton     779:        .status
                    780:        ['] cr catch if
1.99      anton     781:            >stderr cr ." Can't print to stdout, leaving" cr
1.98      anton     782:            \ if stderr does not work either, already DoError causes a hang
                    783:            2 (bye)
                    784:        endif
                    785:        query interpret prompt
1.39      anton     786:     AGAIN ;
1.1       pazsan    787: 
                    788: ' (quit) IS 'quit
                    789: 
                    790: \ \ DOERROR (DOERROR)                                  13jun93jaw
                    791: 
                    792: 8 Constant max-errors
                    793: Variable error-stack  0 error-stack !
1.64      pazsan    794: max-errors has? file [IF] 6 [ELSE] 4 [THEN] * cells allot
1.1       pazsan    795: \ format of one cell:
                    796: \ source ( addr u )
                    797: \ >in
                    798: \ line-number
                    799: \ Loadfilename ( addr u )
                    800: 
1.64      pazsan    801: : error> ( -- addr u >in line# [addr u] )
                    802:     -1 error-stack +!
                    803:     error-stack dup @
                    804:     [ has? file [IF] 6 [ELSE] 4 [THEN] ] Literal * cells + cell+
                    805:     [ has? file [IF] 6 [ELSE] 4 [THEN] ] Literal cells bounds DO
                    806:        I @
                    807:        cell +LOOP ;
                    808: : >error ( addr u >in line# [addr u] -- )
                    809:     error-stack dup @ dup 1+
                    810:     max-errors 1- min error-stack !
                    811:     [ has? file [IF] 6 [ELSE] 4 [THEN] ] Literal * cells + cell+
                    812:     [ has? file [IF] 6 [ELSE] 4 [THEN] 1- ] Literal cells bounds swap DO
                    813:        I !
                    814:        -1 cells +LOOP ;
                    815: 
1.1       pazsan    816: : dec. ( n -- ) \ gforth
1.40      crook     817:     \G Display @i{n} as a signed decimal number, followed by a space.
                    818:     \ !! not used...
1.1       pazsan    819:     base @ decimal swap . base ! ;
                    820: 
1.23      jwilke    821: : dec.r ( u -- ) \ gforth
1.40      crook     822:     \G Display @i{u} as a unsigned decimal number
1.23      jwilke    823:     base @ decimal swap 0 .r base ! ;
                    824: 
1.1       pazsan    825: : hex. ( u -- ) \ gforth
1.40      crook     826:     \G Display @i{u} as an unsigned hex number, prefixed with a "$" and
1.17      crook     827:     \G followed by a space.
1.40      crook     828:     \ !! not used...
1.33      jwilke    829:     [char] $ emit base @ swap hex u. base ! ;
1.1       pazsan    830: 
1.95      anton     831: : typewhite ( addr n -- ) \ gforth
                    832: \G Like type, but white space is printed instead of the characters.
                    833:     \ bounds u+do
                    834:     0 max bounds ?do
1.1       pazsan    835:        i c@ #tab = if \ check for tab
                    836:            #tab
                    837:        else
                    838:            bl
                    839:        then
                    840:        emit
                    841:     loop ;
                    842: 
1.94      anton     843: : -trailing  ( c_addr u1 -- c_addr u2 ) \ string dash-trailing
                    844: \G Adjust the string specified by @i{c-addr, u1} to remove all
                    845: \G trailing spaces. @i{u2} is the length of the modified string.
                    846:     BEGIN
1.102     pazsan    847:        dup
1.94      anton     848:     WHILE
1.102     pazsan    849:        1- 2dup + c@ bl <>
                    850:     UNTIL  1+  THEN ;
1.94      anton     851: 
1.1       pazsan    852: DEFER DOERROR
1.33      jwilke    853: 
                    854: has? backtrace [IF]
1.15      anton     855: Defer dobacktrace ( -- )
                    856: ' noop IS dobacktrace
1.33      jwilke    857: [THEN]
1.1       pazsan    858: 
1.23      jwilke    859: : .error-string ( throw-code -- )
                    860:   dup -2 = 
                    861:   IF   "error @ ?dup IF count type  THEN drop
                    862:   ELSE .error
                    863:   THEN ;
                    864: 
1.64      pazsan    865: : .error-frame ( throwcode addr1 u1 n1 n2 [addr2 u2] -- throwcode )
                    866: \ addr2 u2:    filename of included file - optional
1.23      jwilke    867: \ n2:          line number
                    868: \ n1:          error position in input line
                    869: \ addr1 u1:    input line
1.1       pazsan    870:   cr error-stack @
                    871:   IF
1.64      pazsan    872: [ has? file [IF] ]
                    873:     ." in file included from "
                    874:     type ." :"
                    875: [ [THEN] ]
                    876:     dec.r  drop 2drop
1.1       pazsan    877:   ELSE
1.64      pazsan    878: [ has? file [IF] ]
                    879:       type ." :"
                    880: [ [THEN] ]
                    881:       dup >r dec.r ." : " 3 pick .error-string
1.57      anton     882:       r> IF \ if line# non-zero, there is a line
                    883:          cr dup 2over type cr drop
                    884:          nip -trailing 1- ( line-start index2 )
                    885:          0 >r  BEGIN
                    886:              2dup + c@ bl >  WHILE
                    887:              r> 1+ >r  1- dup 0<  UNTIL  THEN  1+
                    888:          ( line-start index1 )
                    889:          typewhite
                    890:          r> 1 max 0 ?do \ we want at least one "^", even if the length is 0
                    891:              [char] ^ emit
                    892:          loop
                    893:       ELSE
                    894:          2drop drop
                    895:       THEN
1.23      jwilke    896:   THEN ;
1.1       pazsan    897: 
                    898: : (DoError) ( throw-code -- )
                    899:   [ has? os [IF] ]
1.8       pazsan    900:       >stderr
1.1       pazsan    901:   [ [THEN] ] 
1.64      pazsan    902:   source >in @ sourceline# [ has? file [IF] ]
                    903:       sourcefilename
                    904:   [ [THEN] ] .error-frame
1.1       pazsan    905:   error-stack @ 0 ?DO
1.64      pazsan    906:     error>
1.1       pazsan    907:     .error-frame
                    908:   LOOP
1.33      jwilke    909:   drop 
                    910: [ has? backtrace [IF] ]
                    911:   dobacktrace
                    912: [ [THEN] ]
1.8       pazsan    913:   normal-dp dpp ! ;
1.1       pazsan    914: 
                    915: ' (DoError) IS DoError
                    916: 
                    917: : quit ( ?? -- ?? ) \ core
1.27      crook     918:     \G Empty the return stack, make the user input device
                    919:     \G the input source, enter interpret state and start
                    920:     \G the text interpreter.
1.64      pazsan    921:     rp0 @ rp! handler off clear-tibstack
                    922:     [ has? new-input 0= [IF] ] >tib @ >r [ [THEN] ]
1.1       pazsan    923:     BEGIN
                    924:        [ has? compiler [IF] ]
1.104     anton     925:            [compile] [
1.1       pazsan    926:        [ [THEN] ]
1.104     anton     927:        \ stack depths may be arbitrary here
1.1       pazsan    928:        ['] 'quit CATCH dup
                    929:     WHILE
1.104     anton     930:            <# \ reset hold area, or we may get another error
                    931:            DoError
                    932:            \ stack depths may be arbitrary still (or again), so clear them
                    933:            clearstacks
                    934:            [ has? new-input [IF] ] clear-tibstack
                    935:            [ [ELSE] ] r@ >tib ! r@ tibstack !
                    936:            [ [THEN] ]
1.1       pazsan    937:     REPEAT
1.64      pazsan    938:     drop [ has? new-input [IF] ] clear-tibstack
                    939:     [ [ELSE] ] r> >tib !
                    940:     [ [THEN] ] ;
1.1       pazsan    941: 
                    942: \ \ Cold Boot                                          13feb93py
                    943: 
                    944: : (bootmessage)
1.101     anton     945:     ." Gforth " version-string type 
1.88      pazsan    946:     ." , Copyright (C) 1995-2003 Free Software Foundation, Inc." cr
1.101     anton     947:     ." Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'"
1.1       pazsan    948: [ has? os [IF] ]
                    949:      cr ." Type `bye' to exit"
                    950: [ [THEN] ] ;
                    951: 
                    952: defer bootmessage
                    953: defer process-args
                    954: 
                    955: ' (bootmessage) IS bootmessage
                    956: 
1.10      anton     957: Defer 'cold ( -- ) \ gforth  tick-cold
1.1       pazsan    958: \ hook (deferred word) for things to do right before interpreting the
                    959: \ command-line arguments
                    960: ' noop IS 'cold
                    961: 
                    962: 
1.76      jwilke    963: AVariable init8 NIL init8 !
1.1       pazsan    964: 
                    965: : cold ( -- ) \ gforth
1.44      anton     966: [ has? backtrace [IF] ]
                    967:     rp@ backtrace-rp0 !
                    968: [ [THEN] ]
1.1       pazsan    969: [ has? file [IF] ]
1.78      pazsan    970:     os-cold
1.1       pazsan    971: [ [THEN] ]
                    972:     'cold
                    973:     init8 chainperform
                    974: [ has? file [IF] ]
1.91      anton     975:     s" *the terminal*" loadfilename 2!
1.8       pazsan    976:     process-args
1.12      pazsan    977:     loadline off
1.1       pazsan    978: [ [THEN] ]
                    979:     bootmessage
1.12      pazsan    980:     quit ;
1.1       pazsan    981: 
1.64      pazsan    982: has? new-input 0= [IF]
1.5       anton     983: : clear-tibstack ( -- )
                    984: [ has? glocals [IF] ]
                    985:     lp@ forthstart 7 cells + @ - 
                    986: [ [ELSE] ]
                    987:     [ has? os [IF] ]
1.8       pazsan    988:     r0 @ forthstart 6 cells + @ -
1.5       anton     989:     [ [ELSE] ]
1.16      pazsan    990:     sp@ $10 cells +
1.5       anton     991:     [ [THEN] ]
                    992: [ [THEN] ]
                    993:     dup >tib ! tibstack ! #tib off >in off ;
1.64      pazsan    994: [THEN]
1.5       anton     995: 
1.64      pazsan    996: : boot ( path n **argv argc -- )
1.1       pazsan    997:     main-task up!
                    998: [ has? os [IF] ]
1.78      pazsan    999:     os-boot
1.1       pazsan   1000: [ [THEN] ]
                   1001:     sp@ sp0 !
1.74      pazsan   1002: [ has? peephole [IF] ]
1.87      anton    1003:     \ only needed for greedy static superinstruction selection
                   1004:     \ primtable prepare-peephole-table TO peeptable
1.74      pazsan   1005: [ [THEN] ]
1.64      pazsan   1006: [ has? new-input [IF] ]
                   1007:     current-input off
                   1008: [ [THEN] ]
1.5       anton    1009:     clear-tibstack
1.1       pazsan   1010:     rp@ rp0 !
                   1011: [ has? floating [IF] ]
                   1012:     fp@ fp0 !
                   1013: [ [THEN] ]
1.46      anton    1014:     handler off
1.98      anton    1015:     ['] cold catch dup -&2049 <> if \ broken pipe?
                   1016:        DoError cr
                   1017:     endif
1.1       pazsan   1018: [ has? os [IF] ]
1.35      anton    1019:     1 (bye) \ !! determin exit code from throw code?
1.1       pazsan   1020: [ [THEN] ]
                   1021: ;
                   1022: 
                   1023: has? os [IF]
                   1024: : bye ( -- ) \ tools-ext
                   1025: [ has? file [IF] ]
                   1026:     script? 0= IF  cr  THEN
                   1027: [ [ELSE] ]
                   1028:     cr
                   1029: [ [THEN] ]
                   1030:     0 (bye) ;
                   1031: [THEN]
                   1032: 
                   1033: \ **argv may be scanned by the C starter to get some important
                   1034: \ information, as -display and -geometry for an X client FORTH
                   1035: \ or space and stackspace overrides
                   1036: 
                   1037: \ 0 arg contains, however, the name of the program.
                   1038: 

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