[I7] parser goofiness

I have a new action called querying it about, which works like the built-in consulting action but with objects instead of topics. The problem is, the parser’s attempts to understand partial commands (? I think?) are messing with other, supposedly unrelated commands.

[code]Querying it about is an action applying to one thing and one visible thing.

Understand “look up [any room] in [something]” as querying it about (with nouns reversed).
Understand “look [any room] up in [something]” as querying it about (with nouns reversed).
Understand “consult [something] about [any room]” as querying it about.
Understand “read about [any room] in [something]” as querying it about (with nouns reversed).

Understand “look up [any thing] in [something]” as querying it about (with nouns reversed).
Understand “look [any thing] up in [something]” as querying it about (with nouns reversed).
Understand “consult [something] about [any thing]” as querying it about.
Understand “read about [any thing] in [something]” as querying it about (with nouns reversed).

A thing has some text called the note.
A room has some text called the note.

The note of a thing is usually “‘I have nothing to say about this.’”
The note of a room is usually “‘I have nothing to say about this.’”

Carry out querying the notes about:
say the note of the noun.

Lab is a room.
The notes are a thing in Lab.
The painting is a thing in Lab.

Hall is south of Lab.

Test me with “look behind painting / s / look notes”.[/code]

As far as I can tell, the code is trying to parse “LOOK [something it doesn’t understand/something not in scope for examining]” as “LOOK [thing it doesn’t understand] UP IN SOMETHING”. I have no idea how to go about fixing this, though. Is there a decent way to stop Inform from understanding “LOOK [any thing]” on its own as querying? Alternatively…?

I guess for LOOK BEHIND PAINTING, replacing “That noun did not make sense in this context” with a vague “I didn’t understand what you were trying to do” kind of message would suffice. But with “LOOK [thing that exists but isn’t in scope for examining]”, I’d much rather have it just say “You can’t see any such thing” instead of trying to run the querying action on the noun.

Sorry this question is so vague. I’m just floundering around trying to figure out what my options are!

My guess is any problems stem from the elemental definition ‘Understand “look” as looking’ in the standard rules. Like some horrible army drill sergeant, I’d break this command down then build it back up again. So I’d add:

Understand the command "look" as something new.

to your source, and note that that line has to occur before any new definitions involving the word “look”. This eliminates all of the look grammar. Then add your new ‘looking up’ definitions, and also add back in the regular “look” stuff from the standard rules - except the really elemental one ‘Understand “look” as looking.’ In other words, add back only the following:

Understand "look at [something]" as examining. Understand "look [something]" as examining. Understand "look inside/in/into/through [something]" as searching. Understand "look under [something]" as looking under. Understand "look up [text] in [something]" as consulting it about (with nouns reversed). Understand the command "l" as "look".

You may need to massage things some more after, but I suspect this will fix your main parsing problems.

  • Wade

Except that now there is no actual way to look around at the room. I’m pretty sure I can’t recommend this solution. Also, I don’t think that would be the problem line; it only matches exactly the input string “look” with no object, which Emerald said is not the one causing problems. I’m at work so I can’t test this, but Emerald, try running your test example with “rules all” and maybe even “debug 6” so you can see exactly what Inform is doing in the problem situations.

Zahariel A definition of a verb which has no object specified will prompt more elemental parser reactions from Inform than one which does not. That is why I usually try to solve these kinds of problems by eliminating or making-more-specific the most basic form of the command, especially in cases where the command overlaps more than one action (look/examine) because it’s the only case in which Inform will make guesses about what should come after the verb, and respond before the action even begins. Sure, Emerald’s got no basic look command now, but let’s generously say I consider that part of the massaging I suggested, rather than that I just totally forgot to mention that :wink:

But in this case, you’re right anyway. It turns out we don’t need to eliminate the grammar. The making-more-specific route will help, though.

Emerald, add the following to your example. You’ll find ‘test me’ now produces responses you’d want. That said, you’ve got a lot of alternate phrasings, so watch out that faillooking doesn’t scoop up responses destined for some of them, as I haven’t tested the lot.

[code]faillooking is an action applying to one topic.
Understand “look [text]” as faillooking.
Report faillooking: say “You can’t see that here.”

behindlooking is an action applying to one thing.
Understand “look behind [something]” as behindlooking.
Report behindlooking: say “You don’t need to do that (insert better fob off message here).”[/code]

  • Wade

This is tricky because the parser is right: “look notes” really is a valid partial command for “look notes up in guide”. There’s no built-in way to block the parser from extending partial commands like this.

A cheesy approach would be to drop the “look [any known thing] up in [something]” grammar, and instead have a before-reading regexp rule which replaces “look (.) up in (.)” with “read about \1 in \2”.

Otherwise, I’d go with something like Wade’s code. Slightly refined:

Not-really-looking is an action applying to one visible thing.
Report not-really-looking:
	say "That's not here."
Understand "look [any known thing]" as not-really-looking.
Understand "look at [any known thing]" as not-really-looking.

Here “known” is an adjective from Epistemology or something you roll yourself (“A thing can be known”). You definitely want to use “any known thing” everywhere rather than “any thing”, to avoid dropping the entire game into scope.

Thanks so much, everyone! zarf’s code deals with LOOK [THING NOT HERE] well, and adding a rule for printing a parser error covers the LOOK BEHIND [THING] situation. I think I’m content with that.