From: John Benediktsson Date: Tue, 29 Mar 2016 16:59:58 +0000 (-0700) Subject: vocabs.parser: all USE: vocabs are also QUALIFIED:. X-Git-Tag: unmaintained~1377 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=b1be11f39c296591dfa6c151deec858d8d057872 vocabs.parser: all USE: vocabs are also QUALIFIED:. --- diff --git a/basis/debugger/debugger.factor b/basis/debugger/debugger.factor index 866a5685d3..3621132a13 100755 --- a/basis/debugger/debugger.factor +++ b/basis/debugger/debugger.factor @@ -310,8 +310,8 @@ M: no-word-in-vocab summary M: no-word-in-vocab error. summary print ; M: ambiguous-use-error summary - words>> first name>> - "More than one vocabulary defines a word named “" "”" surround ; + name>> + "The name “" "” resolves to more than one word." surround ; M: ambiguous-use-error error. summary print ; diff --git a/core/vocabs/parser/parser.factor b/core/vocabs/parser/parser.factor index 91827f9f56..4249fe3c27 100644 --- a/core/vocabs/parser/parser.factor +++ b/core/vocabs/parser/parser.factor @@ -175,20 +175,26 @@ TUPLE: rename word vocab words ; : unuse-words ( assoc -- ) qualified-vocabs remove! drop ; -TUPLE: ambiguous-use-error words ; +TUPLE: ambiguous-use-error name words ; -: ( words -- error restarts ) +: ( name words -- error restarts ) [ ambiguous-use-error boa ] [ word-restarts ] bi ; > (lookup) ] with map sift dup length ; +: (vocab-search) ( name assocs -- words ) + [ words>> (lookup) ] with map sift ; + +: (vocab-search-qualified) ( name assocs -- words ) + [ ":" split1 swap ] dip [ name>> = ] with filter (vocab-search) ; + +: (vocab-search-full) ( name assocs -- words ) + [ (vocab-search-qualified) ] [ (vocab-search) ] 2bi append ; : vocab-search ( name manifest -- word/f ) - search-vocabs>> (vocab-search) { - { 0 [ drop f ] } - { 1 [ first ] } + dupd search-vocabs>> (vocab-search-full) dup length { + { 0 [ 2drop f ] } + { 1 [ first nip ] } [ drop throw-restarts dup [ vocabulary>> ] [ name>> 1array ] bi add-words-from @@ -196,8 +202,7 @@ TUPLE: ambiguous-use-error words ; } case ; : qualified-search ( name manifest -- word/f ) - qualified-vocabs>> - (vocab-search) 0 = [ drop f ] [ last ] if ; + qualified-vocabs>> (vocab-search) ?last ; PRIVATE>