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
"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." } ;
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 )
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> manifest set
+ "scratchpad" set-current-vocab
+ interactive-vocabs get only-use-vocabs
+ call
+ ] with-scope ; inline
+
: listener ( -- )
[ [ { } (listener) ] with-interactive-vocabs ] with-return ;
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
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> manifest set
- "scratchpad" set-current-vocab
- interactive-vocabs get only-use-vocabs
- call
- ] with-scope ; inline
-
SYMBOL: print-use-hook
print-use-hook [ [ ] ] initialize
"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 }
{ $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." }
C: <extra-words> extra-words
-<PRIVATE
-
: clear-manifest ( -- )
manifest get
[ search-vocab-names>> clear-assoc ]
[ qualified-vocabs>> delete-all ]
tri ;
+<PRIVATE
+
: (add-qualified) ( qualified -- )
manifest get qualified-vocabs>> push ;
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 ;
: <qualified> ( vocab prefix -- qualified )