DavidKinder / Inform6

The latest version of the Inform 6 compiler, used for generating interactive fiction games.
http://inform-fiction.org/
Other
199 stars 32 forks source link

Orphan grammar-lines #205

Closed heasm66 closed 1 year ago

heasm66 commented 1 year ago

I noticed in the newly released "Dorm Game" that it have two sets of grammar-lines that don't have any verb connected to them.

Output from Infodump:

227. 6 entries, verb =  no-verb
    [00 4f 42 3f e9 01 00 09 0f] "no-verb about topic"
    [00 4f 01 00 09 42 49 dd 01 00 01 0f] "no-verb topic in held"
    [00 4f 42 4d db 01 00 09 0f] "no-verb page topic"
    [00 10 01 00 00 0f]       "no-verb noun"
    [04 2b 42 3f e9 01 00 09 42 49 dd 01 00 00 0f] "no-verb about topic in noun" REVERSE
    [00 2b 01 00 09 42 49 dd 01 00 00 0f] "no-verb topic in noun"

Verb 187 looks the same and there are no word in the dictionary with verb-number 187 or 227.

Apparently it's extend only that's the culprit for this state. The code below produces it :

verb 'verb-1' 
  *         -> Action-1;

extend only 'verb-1'
  * noun    -> Action-2;

When the last of the verb gets extended to a new verb, the old is left in place. One solution could be that, when the last verb is in the process of being removed, just drop the only token and extend the verb in-place instead.

But there are some edge caes to consider when two or more verbs are emptied, or some verbs gets emptied but some not.

Extend only 'listen' 'jump'
  * 'hello' -> Inv;

Both "listen" and "jump" are emptied --> both could be changed in place, but also combined into one and the other removed.

Extend only 'sit' 'stand'
  * 'hello' -> Inv;

"sit" isn't emptied but "stand" is --> "sit" should move to "stand".

An alternative solution could be to let the only token run its course and then have a post-process that removes empty slots, renumbers and compacts the table.

This isn't game-breaking, the verbs and grammar-lines are correctly formatted, but at least there could be a warning when the last verb is removed from its grammar-lines.

erkyrath commented 1 year ago

A warning seems sensible.

These cases can also be detected with the --trace VERBS option:

Grammar table: 2 verbs
Verb '???'
  * -> Action1
Verb 'verb-1'
  * -> Action1
  * noun -> Action2
erkyrath commented 1 year ago

I think it suffices to write out zero grammar lines (in tables.c) in the warning case ('???', no dict word with this verb number).

heasm66 commented 1 year ago

I agree that a warning is sensible. The file isn't corrupt but you get alerted that you can do some cleaning up in your verb-extensions.

erkyrath commented 1 year ago

Fixed in pull request https://github.com/DavidKinder/Inform6/pull/206 . This both displays a warning and saves the memory wasted in the grammar table.

I changed my mind a couple of times about whether a warning is appropriate. After all, an author can use Extend only to remove verbs from the standard library. Should we tell them not to? I decided it's cleaner to use Extend replace. The warning is a hint to this effect.