Broken grammar in Inform 6.42

Actually, you modified the grammar of ‘answer’, but didn’t include it in the output, and you didn’t modify the grammar of ‘ask’, but you included it in the output.



My definition of ‘answer’ was pretty stupid, as it meant that you could (say) ANSWER COUCH and it would try to get the couch. I’ve changed it to:

Extend only 'answer' first
  * noun -> Answer;

and added Answer in the before routine. Seems to work.

I also modified the definiton for ‘say’ as follows:

Extend 'say' first
  * topic -> Say;

In other words, I deleted only.

Working out which definitions need only to be deleted is a process of trial and error.

I’ve been recompiling all my old games and work-in-progress for new games and found that this process generally works:

  1. Compile the game.
  2. Double-click on the first error to open PunyInform’s grammar.h and see which line the error is detected on. That tells you which verb is causing the issue. It will normally be a definition with a single verb and no synonyms.
  3. Find the grammar definition of that verb in your own file and delete only.
  4. Repeat as necessary for all the other warnings, then recompile and the warnings should be gone.

There are exceptions. This one has me baffled. Here’s the original grammar definition:

Verb 'turn' 'rotate' 'screw' 'twist' 'unscrew'
  * noun -> Turn
  * noun 'on' -> SwitchOn
  * noun 'off' -> SwitchOff
  * 'on' noun -> SwitchOn
  * 'off' noun -> SwitchOff;

Here’s my extensions:

Extend only 'screw'
  * noun -> Screw
  * noun 'on'/'onto' -> Screw
  * noun 'on'/'onto' noun -> Screw
  * 'on' noun -> Screw
  * 'on' noun 'on'/'onto' noun -> Screw
  * noun 'off' -> Unscrew
  * noun 'off' noun -> Unscrew
  * 'off' noun -> Unscrew
  * 'off' noun 'off' noun -> Unscrew;

Extend only 'turn' 'twist' 'rotate'
  * noun -> Turn;

Extend only 'unscrew'
  * noun -> Unscrew
  * noun 'off'/'from' noun -> Unscrew;

How do I know which only’s to delete, other than trial and error?

EDIT: I just took a guess and deleted only from the last definition and it compiled without any warnings. I have no idea if this is the right thing to do, so it will require extensive testing.

It shouldn’t matter which only you remove. It only impact which one of them that gets to use the already reserved slot, and which ones that gets copied into new slots.

Yeah, but you don’t know which ones they are. FWIW, I tried deleting only from the first and third definitions in turn and it compiled without warning, but deleting the second gave warnings.

Like I said, it’s trial and error and there’s no logic to it…at least no logic that I’ve been able to fathom.

I modify my answer above. You have to consider that Inform6 does the compilation in a single pass. The order you do things can matter. I think that if you, for example, an extend followed by a extend only (without replace), the lines you extended with first will be copied into the verbs you fork out with the second statement. This can be what you desire, or not, but you have to consider the order.

BUT, have in mind that the only difference between 6.41 and 6.42 are that the unreachable lines don’t gets into the file and that you get a warning, the game function is the same. When you change your code, on the other han, you can get different game behaviour.

(This is only theoretical assumptions so far. I have yet to test and look at the dissassembly.)

This is a fascinating discussion and I look forward to trying some of the test cases myself. When I have time. Which might not be this week. :)

Some quick comments:

Deleting only keywords blindly is going to lead you down blind alleys and create bugs in your game. The goal is not to thrash around until the warning disappears.

Compile with --trace verbs to see what the generated grammar really looks like. A grammar table entry that has no verbs left with be listed as Verb '???' – this is the case that generates a warning.

Even when you use only , you may want to specify that the lines you add should come first, or that the existing lines should be scrapped for this verb.

Fredrik is correct here. You can use “Extend only” with “replace”/“first”/“last”.

BUT, have in mind that the only difference between 6.41 and 6.42 are that the unreachable lines don’t gets into the file and that you get a warning, the game function is the same.

Correct. Remember that this warning isn’t telling you about broken grammar, despite the thread title. It’s telling you that your game is wasting space on some unused table entries. You were wasting the same space under 6.41, but the compiler didn’t tell you about it.

It’s quite possible that there’s a compiler bug in this area! As I said, I don’t have time right now to test the examples in this thread.

(One problem I see is that --trace verbs doesn’t show verb synonyms, so it’s not as useful as it could be.)


I figured out what I was doing wrong. I was using

	if (noun == LightStickOff) rtrue;

Extend only 'throw' first
	* noun = IsCylinder 'at'/'against'/'on'/'onto' 'wall'/'floor'/'ground' -> ThrowCylinder;

Extend only 'throw' first
	* noun = IsCylinder -> ThrowCylinder;

But I should have been combining the two grammar statements like this.

Extend only 'throw' first
	* noun = IsCylinder 'at'/'against'/'on'/'onto' 'wall'/'floor'/'ground' -> ThrowCylinder
	* noun = IsCylinder -> ThrowCylinder;

Although to be fair I figured this out by trial and error, my lack of understanding of the warning message didn’t help much.

I make no claim that what I’m doing is sensible, but it seems to work OK.


1 Like

You could also just have dropped only from your second extend statement.

I don’t know how to rephrase this:

Warning: Verb declaration no longer has any verbs associated. 
Use "Extend replace" instead of "Extend only"?


Warning: Verb declaration no longer has any verbs associated. 
Use "Extend" instead of "Extend only"?

be clearer?

Other suggestions?

1 Like

That is certainly clearer. However, after giving this a lot of thought, I think there is a bug in the compiler. The compiler should not obliterate any verb definitions or the verb name. The keyword ‘only’ is quite valid irrespective of the number of verbs in the definition. In fact, there is nothing that allows you to delete a verb, only extend it (by adding stuff to it) or replace it (by replacing the exisiting definitions with new ones).

I don’t think I understand Inform grammar enough to comment intelligently. It’s probably best if I discontinue posting here.

1 Like

Not at all. Your experience is invaluable in identifying the problem. I think we can leave it in @zarf’s capable hands to determine if there is a problem or if it’s just a documentation issue that needs to be clarified.

1 Like

The compiler don’t remove any verb name, it copies the grammar definitions to a new location (on your request in the code).

Every verb in the dictionary have a number, this number then points into a jump table to the grammar definitions for this verb (synonyms to a verb all have the same verb-number in the dictionary). A verb can’t have two, or more numbers, that points to more than one position in the jump table.

What happens when you use extend only is that you extract a couple of verbs and give them a new verb-number that points to a new set of grammar definitions for this new verb-number. If all verbs and its synonyms are given new verb-numbers you are left with a slot in the jump table that no longer have any verb in the dictionary pointing to it, all verbs have been moved to new numbers and you are left with some dead grammar definitions.

The warning is only there to make you aware that you have grammar definitions that are unreachable in your game. They are unreachable in 6.41 and they still are unreachable in 6.42. Nothing is obliterated.

Not recommended, but try:

extend 'take' replace;

(This will remove all definitions from a verb.)

1 Like

My only action item right now is to fix --trace verbs to show all verb synonyms. (I have a PR for this now.)

It doesn’t. It leaves the definitions in place, and warns you that they’re unreachable.

“Extend only” removes a verb word from an existing grammar table. If you use it on every verb word in the table, the table is left with no verb words. Thus it cannot be used.

An alternative would be to silently delete the verb table when the last verb word is removed. But that’s the opposite of what you just asked for!

1 Like

This is kind of a problem, although it’s a very old problem and I don’t remember any real agitation to fix it.

As Henrik said, you can write Extend 'take' replace. This leaves you in an annoying state where the verb is effectively gone, but the failure message is “I didn’t understand that sentence” rather than “That’s not a verb I recognize”. The fix is just to edit the library, which is normal practice for I6.

1 Like

Thank you both for the explanation. I think it makes sense now. This is probably something that should have been explained in the DM4. What it means is that you have to be intimately familiar with the library’s original definitions in order to determine whether these dead definitions are left behind. The new warning now warns you, but it does it in such a way that you have to do a bit of detective work to track down the cause.

I rarely need to do this, but when I have, I’ve replaced it with a dummy verb that effectively gives the same message as a verb that’s not understood. I think I picked up this trick from Roger Firth’s Inform FAQ.

1 Like