1 USING: help.markup help.syntax strings words compiler.units ;
4 ARTICLE: "vocabularies" "Vocabularies"
5 "A " { $emphasis "vocabulary" } " is a named collection of " { $link "words" } ". Vocabularies are defined in the " { $vocab-link "vocabs" } " vocabulary."
7 "Vocabularies are stored in a global hashtable:"
8 { $subsections dictionary }
9 "Vocabularies form a class."
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 } ":"
19 "Looking up vocabularies by name:"
20 { $subsections vocab }
21 "Accessors for various vocabulary attributes:"
27 "Looking up existing vocabularies and creating new vocabularies:"
33 "Getting words from a vocabulary:"
40 "Removing a vocabulary:"
41 { $subsections forget-vocab }
42 { $see-also "words" "vocabs.loader" "word-search" } ;
47 { $var-description "Holds a hashtable mapping vocabulary names to vocabularies." } ;
50 { $values { "seq" "a sequence of strings" } }
51 { $description "Outputs a sequence of all defined vocabulary names." } ;
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." } ;
59 { $values { "vocab-spec" "a vocabulary specifier" } { "name" string } }
60 { $description "Outputs the name of a vocabulary." } ;
63 { $values { "vocab-spec" "a vocabulary specifier" } { "words" "an assoc mapping strings to words" } }
64 { $description "Outputs the words defined in a vocabulary." } ;
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." } ;
71 { $values { "seq" "a sequence of words" } }
72 { $description "Outputs a sequence of all words in the dictionary." } ;
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 } "." } ;
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" } "." } ;
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." } ;
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." } ;
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." }
95 "\"io.streams\" child-vocabs ."
96 "{ \"io.streams.c\" \"io.streams.duplex\" \"io.streams.lines\" \"io.streams.nested\" \"io.streams.plain\" \"io.streams.string\" }"
101 { $class-description "Instances of this class identify vocabularies which are potentially not loaded. The " { $link vocab-name } " slot is the vocabulary name."
103 "Vocabulary links are created by calling " { $link >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 } "." } ;
111 { $class-description "The class of vocabularies with a " { $slot "main" } " word." } ;