Imported Upstream version 21
[debian/pforth] / wordslik.fth
1 \ @(#) wordslik.fth 98/01/26 1.2
2 \
3 \ WORDS.LIKE  ( <string> -- , search for words that contain string )
4 \
5 \ Enter:   WORDS.LIKE +
6 \ Enter:   WORDS.LIKE EMIT
7 \
8 \ Author: Phil Burk
9 \ Copyright 1994 3DO, Phil Burk, Larry Polansky, Devid Rosenboom
10 \
11 \ The pForth software code is dedicated to the public domain,
12 \ and any third party may reproduce, distribute and modify
13 \ the pForth software code or any derivative works thereof
14 \ without any compensation or license.  The pForth software
15 \ code is provided on an "as is" basis without any warranty
16 \ of any kind, including, without limitation, the implied
17 \ warranties of merchantability and fitness for a particular
18 \ purpose and their equivalents under the laws of any jurisdiction.
19
20 anew task-wordslik.fth
21 decimal
22
23
24 : PARTIAL.MATCH.NAME  ( $str1 nfa  -- flag , is $str1 in nfa ??? )
25         count $ 1F and
26         rot count
27         search
28         >r 2drop r>
29 ;
30
31 : WORDS.LIKE  ( <name> -- , print all words containing substring )
32         BL word latest
33         >newline
34         BEGIN
35                 prevname dup 0<> \ get previous name in dictionary
36         WHILE
37                 2dup partial.match.name
38                 IF
39                         dup id. tab
40                         cr?
41                 THEN
42         REPEAT 2drop
43         >newline
44 ;