diff --git a/basis/help/lint/lint.factor b/basis/help/lint/lint.factor index 08cf4b2cd4..4ead01159a 100755 --- a/basis/help/lint/lint.factor +++ b/basis/help/lint/lint.factor @@ -3,7 +3,7 @@ USING: assocs continuations fry help help.lint.checks help.topics io kernel namespaces parser sequences source-files.errors vocabs.hierarchy vocabs words classes -locals tools.errors ; +locals tools.errors listener ; FROM: help.lint.checks => all-vocabs ; IN: help.lint diff --git a/basis/listener/listener-docs.factor b/basis/listener/listener-docs.factor index 0f13b6dd86..7470ef9daa 100644 --- a/basis/listener/listener-docs.factor +++ b/basis/listener/listener-docs.factor @@ -13,6 +13,10 @@ ARTICLE: "listener-watch" "Watching variables in the listener" "Hiding all visible variables:" { $subsection hide-all-vars } ; +HELP: only-use-vocabs +{ $values { "vocabs" "a sequence of vocabulary specifiers" } } +{ $description "Replaces the current manifest's vocabulary search path with the given set of vocabularies." } ; + HELP: show-var { $values { "var" "a variable name" } } { $description "Adds a variable to the watch list; its value will be printed by the listener after every expression." } ; diff --git a/basis/listener/listener.factor b/basis/listener/listener.factor index 4563f61ab7..34d9eac121 100644 --- a/basis/listener/listener.factor +++ b/basis/listener/listener.factor @@ -4,7 +4,7 @@ USING: arrays hashtables io kernel math math.parser memory namespaces parser lexer sequences strings io.styles vectors words generic system combinators continuations debugger definitions compiler.units accessors colors prettyprint fry -sets vocabs.parser source-files.errors locals ; +sets vocabs.parser source-files.errors locals vocabs vocabs.loader ; IN: listener GENERIC: stream-read-quot ( stream -- quot/f ) @@ -124,6 +124,78 @@ t error-summary? set-global PRIVATE> +SYMBOL: interactive-vocabs + +{ + "accessors" + "arrays" + "assocs" + "combinators" + "compiler" + "compiler.errors" + "compiler.units" + "continuations" + "debugger" + "definitions" + "editors" + "help" + "help.apropos" + "help.lint" + "help.vocabs" + "inspector" + "io" + "io.files" + "io.pathnames" + "kernel" + "listener" + "math" + "math.order" + "memory" + "namespaces" + "parser" + "prettyprint" + "see" + "sequences" + "slicing" + "sorting" + "stack-checker" + "strings" + "syntax" + "tools.annotations" + "tools.crossref" + "tools.disassembler" + "tools.errors" + "tools.memory" + "tools.profiler" + "tools.test" + "tools.threads" + "tools.time" + "vocabs" + "vocabs.loader" + "vocabs.refresh" + "vocabs.hierarchy" + "words" + "scratchpad" +} interactive-vocabs set-global + +: only-use-vocabs ( vocabs -- ) + clear-manifest + [ vocab ] filter + [ + vocab + [ find-vocab-root not ] + [ source-loaded?>> +done+ eq? ] bi or + ] filter + [ use-vocab ] each ; + +: with-interactive-vocabs ( quot -- ) + [ + manifest set + "scratchpad" set-current-vocab + interactive-vocabs get only-use-vocabs + call + ] with-scope ; inline + : listener ( -- ) [ [ { } (listener) ] with-interactive-vocabs ] with-return ; diff --git a/basis/prettyprint/prettyprint-tests.factor b/basis/prettyprint/prettyprint-tests.factor index cd10278760..a2696b1263 100644 --- a/basis/prettyprint/prettyprint-tests.factor +++ b/basis/prettyprint/prettyprint-tests.factor @@ -3,7 +3,8 @@ kernel math namespaces parser prettyprint prettyprint.config prettyprint.sections sequences tools.test vectors words effects splitting generic.standard prettyprint.private continuations generic compiler.units tools.continuations -tools.continuations.private eval accessors make vocabs.parser see ; +tools.continuations.private eval accessors make vocabs.parser see +listener ; IN: prettyprint.tests [ "4" ] [ 4 unparse ] unit-test diff --git a/core/parser/parser.factor b/core/parser/parser.factor index 8d52dcaa2c..94eb0a865c 100644 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -112,68 +112,6 @@ SYMBOL: bootstrap-syntax call ] with-scope ; inline -SYMBOL: interactive-vocabs - -{ - "accessors" - "arrays" - "assocs" - "combinators" - "compiler" - "compiler.errors" - "compiler.units" - "continuations" - "debugger" - "definitions" - "editors" - "help" - "help.apropos" - "help.lint" - "help.vocabs" - "inspector" - "io" - "io.files" - "io.pathnames" - "kernel" - "listener" - "math" - "math.order" - "memory" - "namespaces" - "parser" - "prettyprint" - "see" - "sequences" - "slicing" - "sorting" - "stack-checker" - "strings" - "syntax" - "tools.annotations" - "tools.crossref" - "tools.disassembler" - "tools.errors" - "tools.memory" - "tools.profiler" - "tools.test" - "tools.threads" - "tools.time" - "vocabs" - "vocabs.loader" - "vocabs.refresh" - "vocabs.hierarchy" - "words" - "scratchpad" -} interactive-vocabs set-global - -: with-interactive-vocabs ( quot -- ) - [ - manifest set - "scratchpad" set-current-vocab - interactive-vocabs get only-use-vocabs - call - ] with-scope ; inline - SYMBOL: print-use-hook print-use-hook [ [ ] ] initialize diff --git a/core/vocabs/parser/parser-docs.factor b/core/vocabs/parser/parser-docs.factor index e54993b6eb..96619a7114 100644 --- a/core/vocabs/parser/parser-docs.factor +++ b/core/vocabs/parser/parser-docs.factor @@ -65,7 +65,6 @@ $nl "Words for working with the current manifest:" { $subsection use-vocab } { $subsection unuse-vocab } -{ $subsection only-use-vocabs } { $subsection add-qualified } { $subsection add-words-from } { $subsection add-words-excluding } @@ -117,10 +116,6 @@ HELP: unuse-vocab { $description "Removes a vocabulary from the current manifest." } { $notes "This word is used to implement " { $link POSTPONE: UNUSE: } "." } ; -HELP: only-use-vocabs -{ $values { "vocabs" "a sequence of vocabulary specifiers" } } -{ $description "Replaces the current manifest's vocabulary search path with the given set of vocabularies." } ; - HELP: add-qualified { $values { "vocab" "a vocabulary specifier" } { "prefix" string } } { $description "Adds the vocabulary's words, prefixed with the given string, to the current manifest." } diff --git a/core/vocabs/parser/parser.factor b/core/vocabs/parser/parser.factor index 5f393ed65d..0bfb607a52 100644 --- a/core/vocabs/parser/parser.factor +++ b/core/vocabs/parser/parser.factor @@ -52,8 +52,6 @@ M: extra-words equal? C: extra-words -> clear-assoc ] @@ -61,6 +59,8 @@ C: extra-words [ qualified-vocabs>> delete-all ] tri ; +> push ; @@ -126,12 +126,6 @@ TUPLE: no-current-vocab ; 2bi ] [ drop ] if ; -: only-use-vocabs ( vocabs -- ) - clear-manifest - [ vocab ] filter - [ vocab source-loaded?>> +done+ eq? ] filter - [ use-vocab ] each ; - TUPLE: qualified vocab prefix words ; : ( vocab prefix -- qualified )