2005-02-08 22:02:44 -05:00
|
|
|
! Copyright (C) 2003, 2005 Slava Pestov.
|
|
|
|
! See http://factor.sf.net/license.txt for BSD license.
|
2004-08-16 19:29:07 -04:00
|
|
|
IN: words
|
2005-02-08 22:02:44 -05:00
|
|
|
USING: files generic inspector lists kernel namespaces
|
|
|
|
prettyprint stdio streams strings unparser math hashtables
|
|
|
|
parser ;
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2005-03-26 20:12:14 -05:00
|
|
|
: usages. ( word -- )
|
|
|
|
#! List all usages of a word.
|
|
|
|
usages word-sort [.] ;
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2005-03-26 20:12:14 -05:00
|
|
|
: usage ( word -- list )
|
|
|
|
crossref get hash dup [ hash-keys ] when ;
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2005-03-26 20:12:14 -05:00
|
|
|
: usage. ( word -- )
|
|
|
|
#! List all direct usages of a word.
|
|
|
|
usage word-sort [.] ;
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2004-07-19 17:36:20 -04:00
|
|
|
: vocab-apropos ( substring vocab -- list )
|
2004-07-16 02:26:21 -04:00
|
|
|
#! Push a list of all words in a vocabulary whose names
|
|
|
|
#! contain a string.
|
2005-03-05 16:33:40 -05:00
|
|
|
words [ word-name dupd string-contains? ] subset nip ;
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2004-07-19 17:36:20 -04:00
|
|
|
: vocab-apropos. ( substring vocab -- )
|
2004-07-16 02:26:21 -04:00
|
|
|
#! List all words in a vocabulary that contain a string.
|
2004-07-19 17:36:20 -04:00
|
|
|
tuck vocab-apropos dup [
|
2004-07-16 02:26:21 -04:00
|
|
|
"IN: " write swap print [.]
|
|
|
|
] [
|
|
|
|
2drop
|
|
|
|
] ifte ;
|
|
|
|
|
2004-11-24 21:45:30 -05:00
|
|
|
: vocab-completions ( substring vocab -- list )
|
|
|
|
#! Used by jEdit plugin. Like vocab-apropos, but only
|
|
|
|
#! matches at the start of a word name are considered.
|
2005-03-05 16:33:40 -05:00
|
|
|
words [ word-name over ?string-head nip ] subset nip ;
|
2004-11-24 21:45:30 -05:00
|
|
|
|
2004-07-19 17:36:20 -04:00
|
|
|
: apropos. ( substring -- )
|
2004-07-16 02:26:21 -04:00
|
|
|
#! List all words that contain a string.
|
2005-01-01 17:20:48 -05:00
|
|
|
vocabs [ vocab-apropos. ] each-with ;
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2004-07-30 16:22:20 -04:00
|
|
|
: vocabs. ( -- )
|
|
|
|
vocabs . ;
|
|
|
|
|
|
|
|
: words. ( vocab -- )
|
|
|
|
words . ;
|
2005-02-08 22:02:44 -05:00
|
|
|
|
|
|
|
: word-file ( word -- file )
|
2005-03-05 14:45:23 -05:00
|
|
|
"file" word-prop dup [
|
2005-03-05 16:33:40 -05:00
|
|
|
"resource:/" ?string-head [
|
2005-02-08 22:02:44 -05:00
|
|
|
resource-path swap path+
|
|
|
|
] when
|
|
|
|
] when ;
|
|
|
|
|
|
|
|
: reload ( word -- )
|
|
|
|
#! Reload the source file the word originated from.
|
2005-02-14 21:58:07 -05:00
|
|
|
word-file run-file ;
|