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

Grammar option #280

Closed erkyrath closed 3 months ago

erkyrath commented 3 months ago

Adds a $GRAMMAR_VERSION compiler option. Same as setting the Grammar__Version constant in-game, but it's a command-line (or !%) option.

Internal improvements:

We validate the grammar version when setting it, instead of allowing an illegal value to persist until construct_storyfile() time. This avoids various potential bugs when creating grammar table entries. (See the new set_grammar_version() routine.)

I rearranged the Constant directive handler (directs.c) to be clearer and to check more conditions.

Added a check to prevent changing the grammar version after an action or fake-action is defined. (Previously it only checked for fake-actions.) In theory this could cause old code to throw an error, but I don't know what would happen if you changed grammar version after defining some verb grammar. It's certainly not supported. And the standard library sets the grammar version first thing, anyhow, so real games won't have any problem.

Error messages about "Library 6/3 or later" now say "grammar version 2 or later".

Test case: https://github.com/erkyrath/Inform6-Testing/blob/grammar-option/src/grammar-version-test.inf , compiled with either a Constant directive or the command-line option. (Produces the same result.)

Handles https://github.com/DavidKinder/Inform6/issues/273 .