Creating a token that works like a thing

Once again I’ve run into the annoyance that a bracketed description of objects can’t be used in a token.

That in itself isn’t such a problem in this case, as the token will never be encountered as an actual object. But unfortunately, the rules for parsing actual things are more flexible than the rules for parsing tokens:

[code]Chapel is a room.

Praying is an action applying to one visible thing. Understand “pray [any thing]” as praying.

Report praying: say “You say [the noun].”

Understand “blessed”, “virgin”, “mary”, “lady”, “our lady” as “[BVM]”.

the Hail Mary prayer is a thing. Understand “to [BVM]” as Hail Mary.

test me with “pray hail mary/pray to our lady/pray to blessed virgin mary”[/code]
The last test command stops parsing at the word “blessed,” and then tells me “I only understood you as far as wanting to pray the Hail Mary prayer.”

Is there some way to avoid manually writing out every single possible combination of words in the token as separate Understand lines?

Could the problem be that the last command isn’t actually “Pray to [BVM]” but “Pray to [BVM] [BVM]”? When I add

Understand "to [BVM] [BVM]" as Hail Mary.

it behaves as desired, but obviously you’d need to add a few more similar lines to catch all the cases.

Anyway, I know that if you have a bunch of words all of which are understood as a noun (like “take hat hat brown stetson hat stetson brown”) then the parser is supposed to understand them as the noun, but I’m not sure that it’s even desirable to have similar behavior for tokens.

If I were very worried about this and didn’t like my previous hack, I’d probably write an understand line for “pray to [something]”, maybe even define the BVM as a separate object, and redirect praying to our lady to saying the Hail Mary. I guess this would reject “pray hail mary to our blessed virgin lady,” but that doesn’t seem too bad. (May depend on what you’re actually trying to do, if this isn’t it.)

I think I might add a “praying to” verb, but there’s also a “pray for mercy” syntax, so it gets complicated.

I think you’re right that tokens should be stricter than nouns in most cases, but it would be nice if there were a way to disable that. More and more I want to see a “no memory” noun matching token. Sort of the equivalent of (?: … ) in Perl regexps.

Actually, a repetition operator would probably work even better in this case:

Understand "to [BVM]+" as Hail Mary.

Sadly, but unsuprsingly, this:

Understand "[BVM] [BVM]" as "[BVM]".

doesn’t compile.