]> gitweb.factorcode.org Git - factor.git/blob - core/vocabs/vocabs-docs.factor
Rename vocab to lookup-vocab
[factor.git] / core / vocabs / vocabs-docs.factor
1 USING: help.markup help.syntax strings words compiler.units ;
2 IN: vocabs
3
4 ARTICLE: "vocabularies" "Vocabularies"
5 "A " { $emphasis "vocabulary" } " is a named collection of " { $link "words" } ". Vocabularies are defined in the " { $vocab-link "vocabs" } " vocabulary."
6 $nl
7 "Vocabularies are stored in a global hashtable:"
8 { $subsections dictionary }
9 "Vocabularies form a class."
10 { $subsections
11     vocab
12     vocab?
13 }
14 "Various vocabulary words are overloaded to accept a " { $emphasis "vocabulary specifier" } ", which is a string naming the vocabulary, the " { $link vocab } " instance itself, or a " { $link vocab-link } ":"
15 { $subsections
16     vocab-link
17     >vocab-link
18 }
19 "Looking up vocabularies by name:"
20 { $subsections vocab }
21 "Accessors for various vocabulary attributes:"
22 { $subsections
23     vocab-name
24     vocab-main
25     vocab-help
26 }
27 "Looking up existing vocabularies and creating new vocabularies:"
28 { $subsections
29     lookup-vocab
30     child-vocabs
31     create-vocab
32 }
33 "Getting words from a vocabulary:"
34 { $subsections
35     vocab-words
36     words
37     all-words
38     words-named
39 }
40 "Removing a vocabulary:"
41 { $subsections forget-vocab }
42 { $see-also "words" "vocabs.loader" "word-search" } ;
43
44 ABOUT: "vocabularies"
45
46 HELP: dictionary
47 { $var-description "Holds a hashtable mapping vocabulary names to vocabularies." } ;
48
49 HELP: vocabs
50 { $values { "seq" "a sequence of strings" } }
51 { $description "Outputs a sequence of all defined vocabulary names." } ;
52
53 HELP: lookup-vocab
54 { $values { "vocab-spec" "a vocabulary specifier" } { "vocab" vocab } }
55 { $description "Outputs a named vocabulary, or " { $link f } " if no vocabulary with this name exists." }
56 { $class-description "Instances represent vocabularies." } ;
57
58 HELP: vocab-name
59 { $values { "vocab-spec" "a vocabulary specifier" } { "name" string } }
60 { $description "Outputs the name of a vocabulary." } ;
61
62 HELP: vocab-words
63 { $values { "vocab-spec" "a vocabulary specifier" } { "words" "an assoc mapping strings to words" } }
64 { $description "Outputs the words defined in a vocabulary." } ;
65
66 HELP: words
67 { $values { "vocab" string } { "seq" "a sequence of words" } }
68 { $description "Outputs a sequence of words defined in the vocabulary, or " { $link f } " if no vocabulary with this name exists." } ;
69
70 HELP: all-words
71 { $values { "seq" "a sequence of words" } }
72 { $description "Outputs a sequence of all words in the dictionary." } ;
73
74 HELP: forget-vocab
75 { $values { "vocab" string } }
76 { $description "Removes a vocabulary. All words in the vocabulary are forgotten." }
77 { $notes "This word must be called from inside " { $link with-compilation-unit } "." } ;
78
79 HELP: load-vocab-hook
80 { $var-description { $quotation "( name -- vocab )" } " which loads a vocabulary. This quotation is called by " { $link load-vocab } ". The default value should not need to be changed; this functionality is implemented via a hook stored in a variable to break a circular dependency which would otherwise exist from " { $vocab-link "vocabs" } " to " { $vocab-link "vocabs.loader" } " to " { $vocab-link "parser" } " back to " { $vocab-link "vocabs" } "." } ;
81
82 HELP: words-named
83 { $values { "str" string } { "seq" "a sequence of words" } }
84 { $description "Outputs a sequence of all words named " { $snippet "str" } " from the set of currently-loaded vocabularies." } ;
85
86 HELP: create-vocab
87 { $values { "name" string } { "vocab" vocab } }
88 { $description "Creates a new vocabulary if one does not exist with the given name, otherwise outputs an existing vocabulary." } ;
89
90 HELP: child-vocabs
91 { $values { "vocab" "a vocabulary specifier" } { "seq" "a sequence of strings" } }
92 { $description "Outputs all vocabularies which are conceptually under " { $snippet "vocab" } " in the hierarchy." }
93 { $examples
94     { $unchecked-example
95         "\"io.streams\" child-vocabs ."
96         "{ \"io.streams.c\" \"io.streams.duplex\" \"io.streams.lines\" \"io.streams.nested\" \"io.streams.plain\" \"io.streams.string\" }"
97     }
98 } ;
99
100 HELP: vocab-link
101 { $class-description "Instances of this class identify vocabularies which are potentially not loaded. The " { $link vocab-name } " slot is the vocabulary name."
102 $nl
103 "Vocabulary links are created by calling " { $link >vocab-link } "."
104 } ;
105
106 HELP: >vocab-link
107 { $values { "name" string } { "vocab" "a vocabulary specifier" } }
108 { $description "If the vocabulary is loaded, outputs the corresponding " { $link vocab } " instance, otherwise creates a new " { $link vocab-link } "." } ;
109
110 HELP: runnable-vocab
111 { $class-description "The class of vocabularies with a " { $slot "main" } " word." } ;