1 USING: help.markup help.syntax strings words compiler.units
5 ARTICLE: "vocabularies" "Vocabularies"
6 "A " { $emphasis "vocabulary" } " is a named collection of " { $link "words" } ". Vocabularies are defined in the " { $vocab-link "vocabs" } " vocabulary."
8 "Vocabularies are stored in a global hashtable:"
9 { $subsections dictionary }
10 "Vocabularies form a class."
15 "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 } ":"
20 "Looking up vocabularies by name:"
21 { $subsections vocab }
22 "Accessors for various vocabulary attributes:"
28 "Looking up existing vocabularies and creating new vocabularies:"
31 loaded-child-vocab-names
34 "Getting words from a vocabulary:"
41 "Removing a vocabulary:"
42 { $subsections forget-vocab }
43 { $see-also "words" "vocabs.loader" "word-search" } ;
48 { $var-description "Holds a hashtable mapping vocabulary names to vocabularies." } ;
50 HELP: loaded-vocab-names
51 { $values { "seq" { $sequence string } } }
52 { $description "Outputs a sequence of all defined vocabulary names." } ;
55 { $values { "vocab-spec" "a vocabulary specifier" } { "vocab" vocab } }
56 { $description "Outputs a named vocabulary, or " { $link f } " if no vocabulary with this name exists." } ;
59 { $class-description "Instances represent vocabularies." } ;
62 { $values { "vocab-spec" "a vocabulary specifier" } { "name" string } }
63 { $description "Outputs the name of a vocabulary." } ;
65 HELP: vocab-words-assoc
66 { $values { "vocab-spec" "a vocabulary specifier" } { "assoc/f" { $maybe assoc } } }
67 { $description "Outputs the words defined in a vocabulary." } ;
70 { $values { "vocab-spec" vocab-spec } { "seq" { $sequence word } } }
71 { $description "Outputs a sequence of words defined in the vocabulary, or " { $link f } " if no vocabulary with this name exists." } ;
74 { $values { "seq" { $sequence word } } }
75 { $description "Outputs a sequence of all words in the dictionary." } ;
78 { $values { "vocab" string } }
79 { $description "Removes a vocabulary. All words in the vocabulary are forgotten." }
80 { $notes "This word must be called from inside " { $link with-compilation-unit } "." } ;
83 { $var-description { $quotation ( name -- ) } " which loads a vocabulary. This quotation is called by " { $link require } ". 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" } "." } ;
86 { $values { "object" "a vocabulary specifier" } }
87 { $description "Loads a vocabulary if it has not already been loaded. Throws an error if the vocabulary does not exist on disk or in the dictionary." }
88 { $notes "To unconditionally reload a vocabulary, use " { $link reload } ". To reload changed source files only, use the words in " { $link "vocabs.refresh" } "." } ;
91 { $values { "str" string } { "seq" { $sequence word } } }
92 { $description "Outputs a sequence of all words named " { $snippet "str" } " from the set of currently-loaded vocabularies." } ;
95 { $values { "name" string } { "vocab" vocab } }
96 { $description "Creates a new vocabulary if one does not exist with the given name, otherwise outputs an existing vocabulary." } ;
98 HELP: loaded-child-vocab-names
99 { $values { "vocab-spec" "a vocabulary specifier" } { "seq" { $sequence string } } }
100 { $description "Outputs all vocabularies which are conceptually under " { $snippet "vocab" } " in the hierarchy." }
103 "\"io.streams\" loaded-child-vocab-names ."
104 "{ \"io.streams.c\" \"io.streams.duplex\" \"io.streams.lines\" \"io.streams.nested\" \"io.streams.plain\" \"io.streams.string\" }"
109 { $class-description "Instances of this class identify vocabularies which are potentially not loaded. The " { $link vocab-name } " slot is the vocabulary name."
111 "Vocabulary links are created by calling " { $link >vocab-link } "."
115 { $values { "name" string } { "vocab" "a vocabulary specifier" } }
116 { $description "If the vocabulary is loaded, outputs the corresponding " { $link vocab } " instance, otherwise creates a new " { $link vocab-link } "." } ;
119 { $class-description "The class of vocabularies with a " { $slot "main" } " word." } ;