2006-03-25 01:06:52 -05:00
|
|
|
! Copyright (C) 2005, 2006 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2005-03-10 17:57:22 -05:00
|
|
|
IN: words
|
2006-05-15 01:01:47 -04:00
|
|
|
USING: inspector io kernel math namespaces prettyprint
|
2005-12-24 18:29:31 -05:00
|
|
|
sequences strings walker ;
|
2005-03-10 17:57:22 -05:00
|
|
|
|
2006-06-12 02:41:19 -04:00
|
|
|
: usage. ( word -- )
|
|
|
|
usage natural-sort [
|
|
|
|
[ synopsis ] keep dup [ usage. ] curry
|
|
|
|
simple-outliner terpri
|
|
|
|
] each ;
|
|
|
|
|
|
|
|
: apropos ( substring -- )
|
|
|
|
"Word names containing ``" write dup write "'':" print
|
|
|
|
all-words completions
|
|
|
|
[
|
|
|
|
[
|
|
|
|
dup word-name % " (" % dup word-vocabulary % ")" %
|
|
|
|
] "" make swap simple-object terpri
|
|
|
|
] each ;
|
|
|
|
|
2005-04-14 19:37:13 -04:00
|
|
|
: annotate ( word quot -- | quot: word def -- def )
|
2005-08-23 15:50:32 -04:00
|
|
|
over >r >r dup word-def r> call r> swap define-compound ;
|
2005-04-01 12:42:14 -05:00
|
|
|
inline
|
2005-03-10 17:57:22 -05:00
|
|
|
|
2006-03-18 01:57:57 -05:00
|
|
|
: watch-msg ( word prefix -- ) write word-name print .s flush ;
|
2005-09-14 00:37:50 -04:00
|
|
|
|
2005-04-14 19:37:13 -04:00
|
|
|
: (watch) ( word def -- def )
|
2005-08-08 15:21:14 -04:00
|
|
|
[
|
2005-09-14 00:37:50 -04:00
|
|
|
swap literalize
|
|
|
|
dup , "===> Entering: " , \ watch-msg ,
|
|
|
|
swap %
|
|
|
|
, "===> Leaving: " , \ watch-msg ,
|
2005-08-25 15:27:38 -04:00
|
|
|
] [ ] make ;
|
2005-03-10 17:57:22 -05:00
|
|
|
|
2006-03-25 01:06:52 -05:00
|
|
|
: watch ( word -- ) [ (watch) ] annotate ;
|
2005-03-10 17:57:22 -05:00
|
|
|
|
2006-03-25 01:06:52 -05:00
|
|
|
: break ( word -- ) [ nip [ walk ] curry ] annotate ;
|
2006-03-06 19:19:32 -05:00
|
|
|
|
|
|
|
: break-on ( word test -- | test: -- ? )
|
|
|
|
swap [
|
|
|
|
nip [ swap % dup [ walk ] curry , , \ if , ] [ ] make
|
|
|
|
] annotate ;
|
2005-03-28 23:45:13 -05:00
|
|
|
|
2005-08-24 21:52:10 -04:00
|
|
|
: profile ( word -- )
|
2006-05-10 20:32:04 -04:00
|
|
|
[ swap [ global [ inc ] bind ] curry swap append ] annotate ;
|