Grammar version 1 in Inform Technical Manual

I realise that grammar version 1 is not much in use these day, but I’m trying to write a disassembler of the compiled Z-machine data and code. Anyway…

The Inform Technical Manual, chapter 8 has this to say about the “preactions” and “adjectives” table:

A separate table translates these into routine packed addresses: the "preactions"
table.  (As usual, the term is traditional: Inform has no concept of
preaction, but the Infocom games from which it inherits GV1 do have such a
concept.)  The preactions table is a simple --> array.

(Note that in Infocom's games the preactions table always has the same
length as the actions table: this is not true in either GV1 or GV2 Inform
games.)

Prepositions are also identified by their "adjective number".  (An early
misunderstanding in Z-machine decipherment led to the traditional use of
the word "adjective" for dictionary words explicitly written into grammar
lines, which are mainly prepositions like 'into' or 'against'.)  Adjective
numbers count downwards from 255 in order of first use.  They are translated
back into dictionary words using the "adjectives table".

The adjectives table contains 4-byte entries:

    <dictionary address of word>  00  <adjective number>
    ----2 bytes-----------------  ----2 bytes----------- 

To make life more interesting, these entries are stored in reverse order
(i.e., lowest adjective number first).  The address of this table is
rather difficult to deduce from the file header information, so the constant
#adjectives_table is set up by Inform to refer to it.

But examining a couple of games (Curses! and Chrisminster) that the preactions table is of the same length as the actions table but the packed addresses to the parsing routines are in the start of the table and the table is filled out with zeros.

The adjective table in its turn seems to begin with a word that specifies the number of prepositions the table contains.

Using Curses! as an example, the memory map looks like this:

***** ANALYZING *****

Filename:                                  games\Curses!.z5
Compiled with:                             Inform
Object count:                              502
Word count:                                1348
Unique verbs count:                        134
Grammar table version:                     1
Verb action count:                         146
Unique prepositions count:                 34
Scanning for routines from:                0A31C
Found first routine at address:            0A31C
Highest routine address (immediate call):  2D8CC
Lowest string address (immediate address): 2D9A4
Strings start at address:                  2D9A4

***** MEMORY MAP *****

00000-06632 DYNAMIC MEMORY
   00000-0003F Header table
   00040-000EF Abbreviation strings
   000F0-001AF Abbreviation table
   001B0-0022D Object defaults table
   0022E-01DA1 Object tree table
   01DA2-05B47 Object properties tables
   05B48-05D28 Global variables
   05D29-06632 Data fragment

06633-0A31B STATIC MEMORY
   06633-0673E Grammar table
   0673F-070DC Grammar table data
   070DD-07200 Action table
   07201-07324 Parsing routines (preaction) table
   07325-073AE Adjective (preposition) table
   073AF-0A31B Dictionary

0A31C-3F3DB HIGH MEMORY
   0A31C-2D9A3 Z-code
   2D9A4-3F3DB Static strings

And the bytes for the tables, like this:

***** ACTION TABLE (070DD-07200) *****

070D0                                        9D B8 A9               ...
070E0 D9 9D 44 AB EE 9D 49 9D 4F AB F4 9D 55 9D 60 A0  ..D...I.O...U.`.
070F0 99 A0 95 A0 91 37 F4 9D 6A 9D 6D 38 BE 9D 70 9D  .....7..j.m8..p.
07100 84 9F B5 9D F0 9E 82 9F 8F A1 9B 9F AF 9D DA A1  ................
07110 A6 9E E1 9E A2 9E 6C 9F 4F 9F 51 9F 1E A2 49 9F  ......l.O.Q...I.
07120 7C 9F 6E 9F 8C 9F 7F 9F D4 9F D8 9D D5 9D D1 A0  |.n.............
07130 AC A0 EC A1 08 A1 02 A1 F9 A1 74 A1 2F A1 8D A1  ..........t./...
07140 66 9F D6 A1 C4 A1 C6 AC 2F AC 3A AC 65 A1 EF AE  f......./.:.e...
07150 A3 A1 EB A1 ED A2 05 A2 12 A2 31 A2 1F A1 58 A1  ..........1...X.
07160 42 A2 59 A2 2C A2 69 A2 6E A2 77 A2 7C A1 B9 A1  B.Y.,.i.n.w.|...
07170 F7 A1 F3 A1 F5 A1 F1 A2 43 A1 E3 A1 E5 A1 E7 A1  ........C.......
07180 CA A1 CC A1 CE A2 60 A1 D3 A1 D5 A1 D7 A1 D9 A1  ......`.........
07190 FC A1 E9 A1 DF A1 C8 A1 E1 AE 05 A1 DB AC 0B A1  ................
071A0 DD AD 85 AC D2 AC C5 AC DC 90 1A 90 7A AB 3A AB  ............z.:.
071B0 1C AC EE B0 91 B0 78 B0 7F AD 3E AC 4C AD 7C B0  ......x...>.L.|.
071C0 B7 AE 45 AE 68 AE 8A AE 78 AE F7 AC 70 AF 2E AF  ..E.h...x...p...
071D0 29 AF 3C AF 61 AF 68 AE 3E AE 39 AF 73 AF AA 7D  ).<.a.h.>.9.s..}
071E0 6D AE 6A AE 93 AF AE AC EA AF BF AF F9 B0 01 B0  m.j.............
071F0 4A B0 4D B0 56 B0 65 B0 69 B0 AF B0 B2 B0 B5 B0  J.M.V.e.i.......
07200 CC                                               .


***** PRE-ACTION TABLE (07201-07324) *****

07200    B0 D3 B0 EA B0 D5 B1 05 B1 8A B1 78 B1 91 00   ...........x...
07210 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07220 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07230 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07240 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07250 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07260 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07270 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07280 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07290 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
072A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
072B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
072C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
072D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
072E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
072F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07300 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07310 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
07320 00 00 00 00 00                                   .....


***** 'ADJECTIVE' (PREPOSITION) TABLE (07325-073AE) *****

07320                00 22 95 D9 00 DE 75 9C 00 DF 73       ."....u...s
07330 B6 00 E0 A1 FA 00 E1 76 35 00 E2 7C 5C 00 E3 89  .......v5..|\...
07340 28 00 E4 8C E2 00 E5 8D 33 00 E6 8E C8 00 E7 94  (.......3.......
07350 4D 00 E8 82 44 00 E9 A2 15 00 EA 73 BF 00 EB 9F  M...D......s....
07360 7B 00 EC A1 6A 00 ED 9C BD 00 EE 9D C2 00 EF 8F  {...j...........
07370 A0 00 F0 74 19 00 F1 75 DB 00 F2 9E 37 00 F3 7E  ...t...u....7..~
07380 C9 00 F4 8F 22 00 F5 87 C9 00 F6 87 F6 00 F7 87  ...."...........
07390 E4 00 F8 87 8A 00 F9 82 C2 00 FA 9F D5 00 FB 8F  ................
073A0 85 00 FC 8F 10 00 FD 8E D1 00 FE 96 E7 00 FF     ...............

(note that $22 for the prepositions is consistent with the number of prepositions in the dictionary.)

The data aligns up the same way in Christminster.

Anyone remember how the compiler worked back then and the details of the specification?

The GV1 code is still in the compiler, so that’s the place to look.

(I have looked at it but I don’t remember how it works.)

Thank you, I’ll take a look.

EDIT: Line 565 seems to agree with my take on the adjective table. Line 558-560 on the other hand indicates that current version of Inform will compile more compact and not waste space. The preactions table is only as long as there’s data.