Yeah, what I’d really like, if I could have whatever I wanted, is something where parsing and disambiguation happen together. (And I understand that this is not remotely plausible for Inform! I’m talking blue-sky thinking here.)
So you might have something like, with the initial numbers just meant as comments:
[1] Understand "bop [x] with [y]" as bopping x with y when y is a weapon held by the player (100%).
[2] Understand "with [x]" as y when y is a person and y carries x (100%).
[3] Understand "bop [x]" as bopping x (90%).
[4] Understand "bop [x] with [y]" as bopping x with y when y is a weapon (60%).
[5] Understand "bop [x] with [y]" as bopping x with y (50%).
And then the parser goes through a possible parsing, takes the percentages that are assigned to all the Understand lines it has to use to get that parsing, multiplies them, and picks the one with the best percentage. So:
“Bop Bob with sword” goes to line 1, “bop [Bob = x] with [sword = y; weapon held by the player]” and gets understood as bopping Bob with the sword as a 100% match.
“Bop man with lance” can’t go to line 1, because the thing after “with” isn’t a weapon held by the player. But according to line 2, “with lance” can be understood as a 100% match for Bob, which lets us plug Bob into line 3, which is a 90% match for bopping Bob. So overall we have a 90% match for bopping Bob here.
We also can match line 4, with x as Bob (or Jim) and y as the lance. But since line 4 is only a 60% match, we only have a 60% match for bopping Bob with the lance or Jim with the lance, and this is dispreferred to construing it as bopping Bob.
Then if we try “bop Jim with lance,” since line 2 isn’t at all a match for Jim, the only available line is 4 (or 5), so we get a 60% match for bopping Jim with the lance as our best match, and it gets sent to whatever will tell the player they haven’t got the lance.
(Unfortunately in this particular case, “Bop Bob with lance” winds up getting construed as bopping Bob, which is less desirable.)
There are probably flaws with the percentage system that I haven’t thought of–it’s just a brainstorm.
Another idea might just be to have fallback parser errors for when an object could be understood but didn’t match the grammar line, along the lines of Inform’s “You can only do that to something animate” error.