Exercise 109 in the DM4 defines a 'swedishnoun' token to make nouns and adjectives agree with the article (definite or indefinite) applied to them.

When targetting Glulx, this works only if 'swedish_definite_form' and 'swedish_indefinite_form' are defined as common properties; the Glulxe interpreter crashes if they're defined as individual properties. Both forms are accepted by the Z-machine.

I believe this is the fault of the Refer() function, which tests "(parser_inflection >= 256)" to distinguish property values from function values. In Glulx, individual property constants start at 256 (and could conceivably start even higher in a future release).

You could test against a higher value under Glulx, but this is risky. There's no guarantee that the range of valid function addresses won't overlap the range of valid property constants. You really want to store a separate flag to indicate whether parser_inflection is a property or a function.

(Note that INDIV_PROP_START is defined as an I6 constant in Z-code, but not in Glulx.)

For values between the end of the header and the end of memory, ZRegion/metaclass looks at the tag byte (val->0) to decide whether something is a function. If you throw in property constants, you'll get false positives, which will translate to crashes.

As I said, the ranges can overlap. It is easy to create a large Glulx game where 60 is both the address of a function and a valid common property constant. (Admittedly, 60 is usually the address of Main__(), which can safely be ignored for this purpose. Functions that might legitimately be used for grammar parsing would appear quite a bit later in memory, so you can probably approximate your way out of this. It's just not guaranteed to be correct.)

The problem is the library wants the "parser_inflection" global to store either a property value and a function value, and distinguish them solely by the value. This is impossible in Glulx.

The easiest fix is to have two globals, "parser_inflection" and "parser_inflection_func". Set the latter to false when "parser_inflection" is a property value, true when "parser_inflection" is a function.

It is impossible in Glulx to distinguish a property value from a function based solely on the value. You would have to set "parser_inflection_func" correctly at the same time that you set "parser_inflection".

I see... It should be up to the programmer to correctly set parser_inflection_func to true. I see where to add the check for this. I suppose it should be initialized at the beginning of Parser__parse(). Where should it be reset back to false?