more cleanup.

db4
John Benediktsson 2015-08-17 20:48:48 -07:00
parent e8cc383388
commit ac5da311f7
1 changed files with 8 additions and 7 deletions

View File

@ -10,12 +10,13 @@ IN: vocabs.parser
ERROR: no-word-error name ; ERROR: no-word-error name ;
: word-restarts ( possibilities -- restarts ) : word-restarts ( possibilities -- restarts )
natural-sort natural-sort [
[ [ vocabulary>> "Use the " " vocabulary" surround ] keep ] { } map>assoc ; [ vocabulary>> "Use the " " vocabulary" surround ] keep
] { } map>assoc ;
: word-restarts-with-defer ( name possibilities -- restarts ) : word-restarts-with-defer ( name possibilities -- restarts )
word-restarts word-restarts
swap "Defer word in current vocabulary" swap 2array "Defer word in current vocabulary" rot 2array
suffix ; suffix ;
: <no-word-error> ( name possibilities -- error restarts ) : <no-word-error> ( name possibilities -- error restarts )
@ -110,8 +111,9 @@ ERROR: unbalanced-private-declaration vocab ;
vocab-name manifest get search-vocab-names>> in? ; vocab-name manifest get search-vocab-names>> in? ;
: use-vocab ( vocab -- ) : use-vocab ( vocab -- )
dup using-vocab? dup using-vocab? [
[ vocab-name "Already using ``" "'' vocabulary" surround note. ] [ vocab-name "Already using ``" "'' vocabulary" surround note.
] [
manifest get manifest get
[ [ load-vocab ] dip search-vocabs>> push ] [ [ load-vocab ] dip search-vocabs>> push ]
[ [ vocab-name ] dip search-vocab-names>> adjoin ] [ [ vocab-name ] dip search-vocab-names>> adjoin ]
@ -184,8 +186,7 @@ TUPLE: ambiguous-use-error words ;
[ words>> (lookup) ] with map sift dup length ; [ words>> (lookup) ] with map sift dup length ;
: vocab-search ( name manifest -- word/f ) : vocab-search ( name manifest -- word/f )
search-vocabs>> search-vocabs>> (vocab-search) {
(vocab-search) {
{ 0 [ drop f ] } { 0 [ drop f ] }
{ 1 [ first ] } { 1 [ first ] }
[ [