Inform - Support - Patches

About Patches  


DM4 Errata  

Issue L61123     [previous patch]

Minor problem with parse_name
Submitted by: Martin Oehm     Appeared in: Library 6/11 or before     Fixed in: -

I think I have found a (rather minor) error with the parse_name routine. On page 209, the DM4 states:

"It [parse_name] should return:
  0  if the text didn't make any sense at all,
  k  if k words in a row of the text seem to refer to the object, or
  -1 to tell the parser it doesn't want to decide after all.

The word marker wn can be left anywhere afterwards."

But the word marker's position is not reset after returning -1 as it should. In TryGivenObject (parserm.h), the local variable j is used to keep track of the start of parsing with parse_name and is only used to recalculate wn after a match. In my opinion, a line should be inserted here after line 4032:

  4004     if (obj.parse_name ~= 0) {
  4005         parser_action = NULL; j=wn;
  4006         k = RunRoutines(obj, parse_name);

  ...              ! ... handle parse_name result

  4029             MakeMatch(obj, k);
  4030             return k;
  4031         }
  4032         if (k == 0) jump NoWordsMatch;
  >>>>         wn = j;
  4033     }

This might not be an issue -- none of the parse_names in the DM4 exercises that return -1 move the word marker, and usually, as in Zarf's parse_name variants, all the parsing is done in parse_name and the return value is zero.

But in my case I have read a word with NextWord() which I want to process further. The routine looks a bit like that:

  parse_name [;
      if (NextWord() == 'schild') {
          ! handle special case
          if (CheckArticle(male)) return 1;
          return 0;
      }               ! wn has moved by 1
      return -1;      ! look at the unambigous synonyms
                      ! given in the name property
  ], ...

Here, CheckArticle is a way of checking whether an article was used and if so, assure that it matches a certain gender. If there is no article or a correct one, match. If there's an article but it doesn't match the gender, fail. In all other cases, look at the other synonyms*. Of course I could move the word marker back by one, but wouldn't it be more consistent to reset wn after returning -1 anyway?

*  As a brief explanation: "Schild" as a male noun means shield, as a neuter noun it means sign, so if the player refers to "das Schild" I don't want the disambiguation question to come up, since using the correct article, the object is already uniquely described.


As described above.

Last updated 17 April 2013. This web site has not been fully supported since April 2008. Information may be out of date. This page was originally managed by Roger Firth.