Inform - Support - Patches

About Patches  

Compiler  
Library  

DM4 Errata  

Issue L61023

name property includes 'the'
Submitted by: Noel Taylor     Appeared in: Library 6/10 or before     Fixed in: Library 6/11
Problem

Here are two objects, a box and and a book which I have called "book of the ages" entirely so its "name" property can contain the word 'the'. This 'the' is the first of two components which combine to cause the problem.

  Object  -> book "book of the ages"
    with  name 'book' 'of' 'the' 'ages',
          description
              "The book of the ages is
               capped with blotches.",
    has   supporter;

  Object  -> box "box"
    with  name 'box',
          description "This is one awesome box.",
    has   container open;

Interestingly, if you TAKE BOOK and then DROP BOOK IN THE BOX or DROP BOOK INTO THE BOX, everything is fine. However, if you DROP BOOK DOWN THE BOX you get "You can't see any such thing."

Now this is a very silly thing to type, but according to Grammar.h you should be able to and get the same result as in the first two examples. The second of the two components which cause the problem is the placement of the preposition 'down' in line 2 of the grammar for 'drop'. The fact that it is the last alternative preposition listed is for some reason significant.

If you go into line 2 of the grammar and switch the positions of 'into' and 'down' so that it now reads:

  * multiexcept 'in'/'down'/'into' noun -> Insert

suddenly you're able to DROP BOOK DOWN THE BOX but not DROP BOOK INTO THE BOX

Interestingly, if you just type DROP BOOK INTO BOX (instead of THE BOX) everything works fine again.

Solution (by Neil Cerutti)

Adding 'the' to the name property of the book causes the library to misbehave as discovered by Noel, and in addition, creates the following strange situation: it allows 'the', by itself, to mean the book, though it shouldn't mean anything.

Fortunately, you can solve both problems at once using a parse_name routine which restricts the use of 'the'. This routine also restricts the word 'of' since 'of' suffers from similar problems (though as far as I know 'of' doesn't cause the library to malfunction).

This parse_name routine is based on a template provided by Andrew Plotkin's Inform Tricks page (www.eblong.com/zarf/inftricks/):

  name 'the' 'book' 'of' 'ages',
  ! Restrict the words 'the' and 'of'.
  parse_name [ wd num the_num;
      the_num = -1; ! so there will be no match with num for num == 0.
      wd = NextWord();
      while (WordInProperty(wd, self, name)) {
        num++;
        if (wd == 'the' or 'of') the_num = num;
        wd = NextWord();
      }
      if (the_num == num) {
        ! If 'the' or 'of' was the last matched word, parse to just before
        ! the last 'the' or 'of' encountered. This generates a better error
        ! message than just returning 0.
        return the_num-1;
      }
      else return num;
  ],

  >EXAMINE THE BOOK
  You see nothing special about The Book of the Ages.

  >EXAMINE THE BOOK OF THE AGES
  You see nothing special about The Book of the Ages.

  >EXAMINE THE BOOK OF THE
  I only understood you as far as wanting to examine The Book of the Ages.

At this point, I'm not sure if Noel has exposed a library bug and I'm merely providing a workaround, or if using a direct article in a name property is indeed a programming error.

Update (by Cedric Knight)

The code in question is section (F) of Parser__parse, which deals with looking ahead to the indirect object in cases like PUT ALL INTO BAG (a MULTIEXCEPT token) and TAKE ALL FROM BAG (a MULTIINSIDE token). In either case the code seems intended to set the advance_warning global (to BAG) which is useful when making a list for the first object.

Here is a further example. Suppose we are impersonating a guard, like this:

  You are carrying
    the guard's clothes (being worn)
    a bag
    your clothes

(Imagine 'clothes' has 'my' in the name property to distinguish it from the guard's clothes). If we PUT MY CLOTHES INTO MY BAG where we are using the second MY (in the usual Inform way) to specify the bag we are holding, the parser first thinks this second 'MY' refers to the clothes and sets advance_warning to clothes. This item is then excluded from the list of items the direct object 'CLOTHES' could refer to, and we have an empty list and an error message.

I also notice that TAKE ALL FROM THE TABLE (as opposed to TAKE ALL FROM TABLE) doesn't work in many situations (e.g. opening scene, Moments OOT; kitchen table, Reality's End).

Ideally the lookahead code should parse 'descriptors' such as 'THE' or 'MY'. To do this requires inserting two lines inside the preposition test immediately before calling NounDomain. Replace the following lines in parserm (around 1100-1200):

   {   if (NextWord() == line_tdata-->(pcount-1))
       {   l = NounDomain(actors_location, actor,
                    NOUN_TOKEN);

with:

   {   if ( (NextWord()->#dict_par1) &8 ) ! --if IS a preposition
       {
           l = Descriptors(false);  ! skip past THE etc
           if (l~=0) etype=l;  ! don't allow multiple objects

           l = NounDomain(actors_location, actor,
                   NOUN_TOKEN);

The amendment to the first line also fixes the problem with two prepositions after multiinside.


Last updated 17 April 2013. This site is no longer supported; information may be out of date.
Maintained as a historical archive by the Interactive Fiction Technology Foundation. Copyright 1993-2018 IFTF, CC-BY-SA unless otherwise noted.
This page was originally managed by Roger Firth.