version 1.29, 2007/07/06 12:54:56
|
version 1.33, 2011/11/17 17:52:14
|
Line 1
|
Line 1
|
\ search order wordset 14may93py |
\ search order wordset 14may93py |
|
|
\ Copyright (C) 1995,1996,1997,1998,2000,2003,2005 Free Software Foundation, Inc. |
\ Copyright (C) 1995,1996,1997,1998,2000,2003,2005,2007 Free Software Foundation, Inc. |
|
|
\ This file is part of Gforth. |
\ This file is part of Gforth. |
|
|
\ Gforth is free software; you can redistribute it and/or |
\ Gforth is free software; you can redistribute it and/or |
\ modify it under the terms of the GNU General Public License |
\ modify it under the terms of the GNU General Public License |
\ as published by the Free Software Foundation; either version 2 |
\ as published by the Free Software Foundation, either version 3 |
\ of the License, or (at your option) any later version. |
\ of the License, or (at your option) any later version. |
|
|
\ This program is distributed in the hope that it will be useful, |
\ This program is distributed in the hope that it will be useful, |
Line 15
|
Line 15
|
\ GNU General Public License for more details. |
\ GNU General Public License for more details. |
|
|
\ You should have received a copy of the GNU General Public License |
\ You should have received a copy of the GNU General Public License |
\ along with this program; if not, write to the Free Software |
\ along with this program. If not, see http://www.gnu.org/licenses/. |
\ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. |
|
|
|
require struct.fs |
require struct.fs |
|
|
$10 Value maxvp \ current size of search order stack |
$10 Value maxvp \ current size of search order stack |
$400 Value maxvp-limit \ upper limit for resizing search order stack |
$400 Value maxvp-limit \ upper limit for resizing search order stack |
0 AValue vp \ will be initialized later (dynamic) |
0 AValue vp \ will be initialized later (dynamic) |
|
\ the first cell at vp contains the search order depth, the others |
|
\ contain the wordlists, starting with the last-searched one. |
|
|
: get-current ( -- wid ) \ search |
: get-current ( -- wid ) \ search |
\G @i{wid} is the identifier of the current compilation word list. |
\G @i{wid} is the identifier of the current compilation word list. |
Line 96 Variable slowvoc 0 slowvoc !
|
Line 97 Variable slowvoc 0 slowvoc !
|
|
|
: (vocfind) ( addr count wid -- nfa|false ) |
: (vocfind) ( addr count wid -- nfa|false ) |
\ !! generalize this to be independent of vp |
\ !! generalize this to be independent of vp |
drop vp dup @ 1- cells over + |
drop 0 vp @ -DO ( addr count ) \ note that the loop does not reach 0 |
DO 2dup I 2@ over <> |
2dup vp i cells + @ (search-wordlist) dup if ( addr count nt ) |
IF (search-wordlist) dup |
nip nip unloop exit then |
IF nip nip UNLOOP EXIT |
drop 1 -loop |
THEN drop |
|
ELSE drop 2drop THEN |
|
[ -1 cells ] Literal +LOOP |
|
2drop false ; |
2drop false ; |
|
|
0 value locals-wordlist |
0 value locals-wordlist |
Line 203 lookup ! \ our dictionary search order b
|
Line 201 lookup ! \ our dictionary search order b
|
THEN |
THEN |
dup check-maxvp |
dup check-maxvp |
dup vp! |
dup vp! |
?dup IF 1- FOR vp cell+ I cells + ! NEXT THEN ; |
0 swap -DO ( wid1 ... widi ) |
|
vp i cells + ! \ note that the loop does not reach 0 |
|
1 -loop ; |
|
|
: seal ( -- ) \ gforth |
: seal ( -- ) \ gforth |
\G Remove all word lists from the search order stack other than the word |
\G Remove all word lists from the search order stack other than the word |
Line 228 lookup ! \ our dictionary search order b
|
Line 228 lookup ! \ our dictionary search order b
|
\G print the name of the wordlist represented by @var{wid}. Can |
\G print the name of the wordlist represented by @var{wid}. Can |
\G only print names defined with @code{vocabulary} or |
\G only print names defined with @code{vocabulary} or |
\G @code{wordlist constant}, otherwise prints @samp{???}. |
\G @code{wordlist constant}, otherwise prints @samp{???}. |
dup >r wordlist-struct %size + dup head? if ( wid nt ) |
dup >r wordlist-struct %size + dup head? true = if ( wid nt ) |
dup name>int dup >code-address docon: = swap >body @ r@ = and if |
dup name>int dup >code-address docon: = swap >body @ r@ = and if |
id. rdrop exit |
id. rdrop exit |
endif |
endif |