Per the Internal Secrets document (page 22), ZIL links vocab words[1] to verb, adjective, noun, preposition, and direction IDs in a truly arcane way. My understanding is:
- Each word in the dictionary has one byte indicating what type(s) of word it is (“type byte”), and two bytes indicating its ID in each of those types (“primary ID byte” and “secondary ID byte”).
- The type byte assigns a word any number of “primary” types and exactly one “secondary” type.
- Possible primary types are noun, verb, adjective, direction, preposition, and other. (A word can have any subset of these, including all or none.)
- Possible secondary types are noun, verb, adjective, and direction. (A word always has exactly one of these, never zero, never multiple.)
- The primary ID byte is the word’s ID number in its primary type(s), which can be zero to mean “same as the secondary ID byte”.
- The secondary ID byte is the word’s ID number in its secondary type, which cannot be zero.
- The routine to check a word’s type is
WT?. This can be called in two ways. WT?(Word, X)returns TRUE if Word has X among its primary types, and FALSE otherwise.WT?(Word, X, Y)returns the secondary ID byte if Word has secondary type Y, and the primary ID byte otherwise. X is ignored.
My question is: how is this useful? How do you effectively use this system to check something like “is this word a verb, and if so, what’s its ID” or “is this word a preposition, and if so, what’s its ID”—both things that the parser needs to do?
It seems like I’m not the only one to find this confusing, but if ZILF works in the same way, surely ZILF maintainers and programmers must have a good understanding of this. Is there a better way to explain it that will make more sense? (Because my explanation here doesn’t even make sense to myself…)
Since these routines operate on bytes, “word” in this post always means “dictionary entry”, not “16-bit value”. ↩︎