Looking at DM4’s Exercise 77 (about using “#” as a “wildcard” for “any single object”), and using the example solution provided along with a simple world:
Constant Story "DM4 Exercise 077";
Constant Headline "^from p. 210^";
! EXERCISE 77
! How could the word "#" be made a wild-card, meaning
! "match any single object"?
Include "Parser";
Include "VerbLib";
[ ParseNoun;
if (NextWord() == '#//')
return 1;
wn--;
return -1;
];
Include "Grammar";
Class Room
has light;
Room Start "Starting Point"
with description
"An uninteresting room.";
Object -> pebble "pebble"
with name 'pebble';
Object -> rock "rock"
with name 'rock';
[ Initialise ;
location = Start;
];
This is what happens under Inform 6.31:
Starting Point
An uninteresting room.
You can see a pebble and a rock here.
>get #
Which do you mean, the north, the south, the east, the west, the northeast,
the northwest, the southeast, the southwest, the up above, the ground,
the inside, the outside, yourself, the pebble or the rock?
>rock
I only understood you as far as wanting to get the rock.
What doesn’t the parser understand here? Per DM4 p. 242, the parser
should be attempting to reparse “>GET ROCK #” at this point, so I
suppose that the word 2 in the trace output is “rock”. I would expect
that the rock object scores 2 for parsing now (1 for ‘rock’ and 1
for ‘#’) and therefore wins against the pebble (scoring 1 for ‘#’),
but this doesn’t seem to be the case.
I note that with “trace 3” set, the following block is included in
the debug output after choosing “rock”:
[line 1 * multi -> Take]
[line 1 token 1 word 2 : multi]
[Object list from word 2]
[Calling NounDomain on location and actor]
[ND returned the rock]
[token resulted in success]
[line 1 token 2 word 3 : END]
The noun token succeeds, but perhaps the grammar line doesn’t? Does
“[line 1 token 2 word 3 : END]” mean that wn is left at 3 after the
noun token is completed, so the grammar line fails because no more
words are allowed? The exact same behavior occurs if the command
is originally entered as “>GET ROCK #”, so that’s at least consistent.
Is there something special going on with ParseNoun() being involved
here? I note that, if ParseNoun() is removed and both pebble and rock
include ‘#//’ in their name properties, then the issue doesn’t occur.