Re: [Inform] Difference between "


26 Nov 1995 18:59:38 GMT

"Sam Hulick" <shulick@kiwi.ucs.indiana.edu> wrote:
> I do know that dictionary words suck because you can't print them.
> What's the purpose, then?

You *can* print dictionary words (use "print (address) 'train';" for
example).

The point of dictionary words is that they are put in the dictionary!
When the Z-machine parses the player's input, then two data structures
are set up; if you use the Inform libraries then these are called
`buffer' and `parse'. The first is an array of the characters the
player typed; the second is an array of pointers to words in the
dictionary. For example, suppose the player types

>take the book

Then we expect that the data structures will look like this:

buffer parse dictionary
.----. .----. .------.
0 | 78 | buffer size 0 | 40 | table size | ... |
1 | 0d | # chrs input 1 | 03 | # words read 3a98 | book |
2 | 74 | 't' 2 | 46 | \ address of | ... |
3 | 61 | 'a' | 50 | / 'take' 4650 | take |
... 4 | 47 | \ address of | ... |
13 | 6f | 'o' | 7c | / 'the' 477c | the |
14 | 6b | 'k' 6 | 3a | \ address of | ... |
... | 98 | / 'book' `------'
119 | 00 | buffer end ...
`----' 63 | 00 | table end
`----'

Each dictionary word is truncated to 6 bytes (typically 9 letters), and
the dictionary is sorted, so tokenisation is quick because words can be
found by binary chop. The dictionary actually contains more information
than shown in the figure; for each word it provides flags, saying
whether the word is a verb or noun or both, and if it is a verb then
there is a pointer to the relevant entry in the grammar table.

-- 
Gareth Rees