1 ! Broken by recent changes
3 USING: kernel vocabs words combinators math
4 namespaces arrays sequences assocs sorting
9 ! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11 ! : word-restarts ( string -- restarts )
12 ! words-named natural-sort
13 ! [ [ "Use the word " swap summary append ] keep 2array ] map
14 ! { "Define this word as a symbol" 0 } add
15 ! { "Defer this word in the 'scratchpad' vocabulary" f } add ;
17 ! : no-word-option ( obj -- word )
18 ! { { [ dup f = ] [ drop in get create ] }
19 ! { [ dup 0 = ] [ drop in get create dup define-symbol ] }
20 ! { [ t ] [ nip dup word-vocabulary use+ ] }
23 VAR: new-symbol-action ! ( str -- word )
25 ! [ dup no-word no-word-option ] new-symbol-action set-global
29 ! ! [ in get create dup define-symbol ] >new-symbol-action
31 ! : search ( str -- word )
32 ! { { [ dup use get assoc-stack ]
33 ! [ use get assoc-stack ] }
34 ! { [ dup words-named empty? ]
35 ! [ new-symbol-action> call ] }
36 ! { [ dup words-named length 0 > ]
37 ! [ dup no-word no-word-option ] }