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

Accept two Verb declarations for the same verb, with a warning #289

Closed erkyrath closed 2 months ago

erkyrath commented 2 months ago

This change is a big wodge of code in the "Two different verb definitions refer to..." part of make_verb(). We arrive at this case if we see:

Verb "foo" [...]

...where "foo" is already known as a verb.

Before printing that error, we check to see if this is valid to treat as "Extend last".

If there's just one verb (which is the I7-generated case), it's easy. The trick is if there's multiple verb words, which is legal in the Verb directive. (Though not in the Extend directive.)

Verb "foo" "bar" "baz" [...]

We accept this as a valid extend if all the verbs are known and refer to the same Inform verb. Otherwise, we fall back to the old "Two different verb definitions refer to..." error.

If it's a valid extend, we print a warning:

This verb definition refers to "foo", which has already been defined. Use "Extend last" instead.

But we allow it, and therefore jump into the Extend machinery. Note that the end of the extend_verb() function has been factored out so that we can call it from two places.


Other changes:

I renamed find_verb() to find_verb_entry(); it now returns the English_verbs[] index number rather than the verbnum of that entry. Made some other stuff easier.

As noted on the forum, I've adjusted the check for this error:

Once an action has been defined it is too late to change the grammar version.

It's okay if actions names have been defined (like ##Take). The problem arises if action grammar has been defined. So we check for that more specifically.

(This tweaks https://github.com/DavidKinder/Inform6/commit/6a4de5b391379737831ac8ce2081a811c861b9a3 .)

erkyrath commented 2 months ago

Handles https://github.com/DavidKinder/Inform6/issues/288 and https://github.com/DavidKinder/Inform6/issues/285 .