`ItemReferenceArg` needs to accept different following arguments depending on its value

Enhancement Request

Explanation

Currently, everywhere ItemReferenceArg is used, it is followed by MaterialTokenArg, as this seems to be what is accepted: https://dwarffortresswiki.org/index.php/DF2014:Item_token

However, as can be seen on a closer look at the page, it's not always MaterialTokenArg. REMAINS, MEAT, FISH, FISH_RAW, VERMIN, PET, and EGG all accept a creature ID followed by a caste instead, and while I've not investigated it, I'd guess something similar applies with PLANT, PLANT_GROWTH, SEED and CORPSE.

Currently this results in an error whenever using anything other than a MaterialTokenArg (including nothing in some cases, such as [ITEMCORPSE:NONE:NONE]). See for example ITEM_REACTION_PRODUCT or ITEMCORPSE. If you were to use [ITEMCORPSE:EGG:NONE:CHICKEN:FEMALE] in a creature, this would be valid, but the LS would falsely mark it as an error as it's expecting a MaterialTokenArg.

So this token arg needs to be able to parse that all properly without errors.

NOTE: See comment lower down for more details.

Impact of enhancement

It's difficult to decide what to do because when there is a secondary argument after an item token, it's definitely dependent on what the first argument was, but it seems like sometimes other arguments are accepted as well, or sometimes even none at all (see BUTCHER_SPECIAL), so simply subsuming MaterialTokenArg into ItemReferenceArg and manually parsing the other options isn't likely to work, because in some tokens it needs to simply not accept anything after the item type and subtype.

Everywhere ItemReferenceArg is used will have to be edited appropriately once this change is made.

Edited by Ralph Bisschops