I was helping someone else with a project of theirs, and they ran into an issue that seems worth sharing. They had specified two actions and their associated grammars:
Understand "where is" or "which way is/to" or "which way is it to" or "how do/can I get to" or "which way do/can I go to get to" or "which way is it to get to" or "how do/can I get/go from here to" or "how do/can I get/go to" or "i want to go to" or "how to get to" as "[direction-asking preamble]".
Asking which way is an action applying to one thing. Understand "[direction-asking preamble] [room]" or "[direction-asking preamble] [room] from here" as asking which way.
...
Asking what rooms is an action applying to nothing. Understand "rooms" or "places" or "where can I go" as asking what rooms.
The issue being experienced was that >WHERE IS LIBRARY (for example) would respond with a didn’t understand parser error, despite the fact that this wording was covered by the “[direction-asking preamble]”. Use of >TRACE showed that only the grammar line for the asking what rooms
action was being evaluated.
Looking at the generated I6 code, the following could be seen:
Verb 'no.verb'
* GPR_Line_94 noun=Noun_Filter_4 -> A78_asking_which_way
* GPR_Line_94 noun=Noun_Filter_5 'from' 'here' -> A78_asking_which_way
;
Verb 'where'
* 'can' 'i//' 'go' -> A80_asking_what_rooms
;
GPR_Line_94
is the routine token generated for the direction-asking preamble
topic. What’s going on is that the parser is treating 'where'
as a verb word but the I7 compiler didn’t take note that 'where'
is also used by the direction-asking preamble
topic, so when the one grammar line associated with that verb word fails, the parser decides that parsing has failed.
The short-term fix is to separate out the use of “where” for the asking which way action:
Understand "which way is/to" or ... as "[direction-asking preamble]".
Understand "where is [room]" as asking which way.
This way the I6 layer includes a grammar line for the asking which way
action associated with 'where'
:
Verb 'where'
* 'is' noun=Noun_Filter_6 -> A78_asking_which_way
* 'can' 'i//' 'go' -> A80_asking_what_rooms
;
However, it occurs to me that perhaps the parser behavior should be to try any grammar lines that begin with a routine token after running out of lines tied to specific verb words, since there is no way for the parser to know what words might be recognized by any particular GPR token.
Perhaps this issue has already been flagged – it’s the kind of thing that I would historically have researched on the Mantis site. I’m posting here so that it doesn’t get lost (or so that someone can explain why current parser behavior is preferable).