1 USING: help.markup help.syntax strings words compiler.units ;
4 ARTICLE: "vocabularies" "Vocabularies"
5 "A " { $emphasis "vocabulary" } " is a named collection of words. Vocabularies are defined in the " { $vocab-link "vocabs" } " vocabulary."
7 "Vocabularies are stored in a global hashtable:"
8 { $subsection dictionary }
9 "Vocabularies form a class."
11 { $subsection vocab? }
12 "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 } ":"
13 { $subsection vocab-link }
14 { $subsection >vocab-link }
15 "Looking up vocabularies by name:"
17 "Accessors for various vocabulary attributes:"
18 { $subsection vocab-name }
19 { $subsection vocab-main }
20 { $subsection vocab-help }
21 "Looking up existing vocabularies and creating new vocabularies:"
23 { $subsection child-vocabs }
24 { $subsection create-vocab }
25 "Getting words from a vocabulary:"
26 { $subsection vocab-words }
28 { $subsection all-words }
29 { $subsection words-named }
30 "Removing a vocabulary:"
31 { $subsection forget-vocab }
32 { $see-also "words" "vocabs.loader" } ;
37 { $var-description "Holds a hashtable mapping vocabulary names to vocabularies." } ;
40 { $values { "seq" "a sequence of strings" } }
41 { $description "Outputs a sequence of all defined vocabulary names." } ;
44 { $values { "vocab-spec" "a vocabulary specifier" } { "vocab" vocab } }
45 { $description "Outputs a named vocabulary, or " { $link f } " if no vocabulary with this name exists." }
46 { $class-description "Instances represent vocabularies." } ;
49 { $values { "vocab-spec" "a vocabulary specifier" } { "name" string } }
50 { $description "Outputs the name of a vocabulary." } ;
53 { $values { "vocab-spec" "a vocabulary specifier" } { "words" "an assoc mapping strings to words" } }
54 { $description "Outputs the words defined in a vocabulary." } ;
57 { $values { "vocab" string } { "seq" "a sequence of words" } }
58 { $description "Outputs a sequence of words defined in the vocabulary, or " { $link f } " if no vocabulary with this name exists." } ;
61 { $values { "seq" "a sequence of words" } }
62 { $description "Outputs a sequence of all words in the dictionary." } ;
65 { $values { "vocab" string } }
66 { $description "Removes a vocabulary. All words in the vocabulary are forgotten." }
67 { $notes "This word must be called from inside " { $link with-compilation-unit } "." } ;
70 { $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 functinality 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" } "." } ;
73 { $values { "str" string } { "seq" "a sequence of words" } }
74 { $description "Outputs a sequence of all words named " { $snippet "str" } " from the set of currently-loaded vocabularies." } ;
77 { $values { "name" string } { "vocab" vocab } }
78 { $description "Creates a new vocabulary if one does not exist with the given name, otherwise outputs an existing vocabulary." } ;
81 { $values { "vocab" "a vocabulary specifier" } { "seq" "a sequence of strings" } }
82 { $description "Outputs all vocabularies which are conceptually under " { $snippet "vocab" } " in the hierarchy." }
85 "\"io.streams\" child-vocabs ."
86 "{\n \"io.streams.c\"\n \"io.streams.duplex\"\n \"io.streams.lines\"\n \"io.streams.nested\"\n \"io.streams.plain\"\n \"io.streams.string\"\n}"
91 { $class-description "Instances of this class identify vocabularies which are potentially not loaded. The " { $link vocab-name } " slot is the vocabulary name."
93 "Vocabulary links are created by calling " { $link >vocab-link } "."
97 { $values { "name" string } { "vocab" "a vocabulary specifier" } }
98 { $description "If the vocabulary is loaded, outputs the corresponding " { $link vocab } " instance, otherwise creates a new " { $link vocab-link } "." } ;