I’ve been wrangling with a weird parser issue and the example called “Misadventure” (#295) from the documentation is a pretty good test case for the problem. In Misadventure, it’s possible to use numbers to trick the parser into assuming you want to fast travel to your current location. Consider this:
You’re in a small chamber lit by an eerie green light. An extremely narrow tunnel exits to the west. A dark corridor leads northeast.
That noun did not make sense in this context. <-- Makes sense
That noun did not make sense in this context. <-- Also fine
You can’t use multiple objects with that verb. <-- Strange
You’re already in Plover Room. <-- Really unexpected
I’ve managed to track the misbehaviour down to line 1666 of Parser.i6t. If I change the offending line from:
allow_plurals = true; desc_wn = wn;
allow_plurals = verb_wordnum > 0; desc_wn = wn;
That’s an adequate “fix” for the problem. I’m basically telling it to NOT swallow up any numbers as descriptors and instead parse them as nouns if there was no verb (verb_wordnum). It makes sense to me as it seems very unlikely someone would want to “no verb” a quantity of a noun action. e.g.
3 Plover Room
I spent a while tracking this down and I really want to make sure I’m not doing something dumb, so a few questions:
Is there a better variable than verb_wordnum to use here? Like, is this incompatible with some obscure command syntax I haven’t tried?
Can anyone see any odd side effects I might introduce by patching this for my game?
Most important, I don’t really want to actually modify the i6t file. Is there a way for me to patch this one line as an include in my game, rather than replicating a modified version of the entire ParseToken function?
Thanks, Zarf. This is probably the neatest and most comprehensive solution to the problem. As Felix mentioned, it’s still possible to confuse the parser in other situations if I modify the initialisation of allow_plurals. With the patch suggested in bug 835, those situations go away too (at least as far as I’ve tested).
I only ran into this parser bug because I have a verbless action for a person “[any person]” and a separate verbless action for a number “[number]”.
I did try searching the bug database for this problem before posting here. It seems tough to find a bug with such systems unless you know what you’re looking for.
Yeah, the bug system can take some digging through. I wound up searching for “allow_plurals” and “numbers” (the latter only turned up fifty results, but I knew the bug was in there because I filed it. )