Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001890I6 LibraryGeneralpublic2016-04-03 22:102016-04-20 22:49
Reporterzarf 
Assigned ToDavidG 
PrioritynormalSeveritymildReproducibilityhave not tried
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version6/12 
Target VersionFixed in Version 
Summary0001890: DM4 exercise 32 fails in Glulx
DescriptionWe should get:

>dan, x pie
"What," says Dan, "you want me to examine the cow pie?"

>dan, x conscience
"That I can do," says Dan. "I'm empty-handed."

>dan, x
(the cow pie)
"What," says Dan, "you want me to examine the cow pie?"


...but in fact we get:

>dan, x pie
"Don't know how," says Dan.

>dan, x conscience
Dyslexic Dan is carrying nothing.

>dan, x
[...interpreter hangs! Parser is stuck in a loop.]

Minimal Source Text To Reproduce
Constant Story "Example 32";
Constant Headline "^";

Include "Parser";
Include "VerbLib";

Object Field "Field"
  with description "This is the field.",
  has  light;


Object -> Dan "Dyslexic Dan"
  with name 'dan' 'dyslexic',
       grammar [;
           if (verb_word == 'examine' or 'x//') {
               verb_wordnum++; return -'danx';
           }
       ],
       orders [;
           Examine: "~What,~ says Dan, ~you want me to examine ",
                        (the) noun, "?~";
           Inv: "~That I can do,~ says Dan. ~I'm empty-handed.~";
           default: "~Don't know how,~ says Dan.";
       ],
       initial "Dyslexic Dan is here.",
  has  animate proper;

Object -> "cow pie"
  with name 'cow' 'pie',
       description "That's one healthy cow.",
       before [;
           Examine: ;
           default: "Nope.";
       ];

[ Initialise;
  location = Field;
];

Include "Grammar";

Verb 'danx' * 'conscience' -> Inv;
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0004409)
zarf (developer)
2016-04-03 22:16

The main bug is a mismatch in behavior between the Glulx and Zcode versions of the grammar property. In parserm.h, I believe the line

        if (i < 0) { usual_grammar_after = verb_wordnum; i=-i; }

should be

        if (i < 0) { usual_grammar_after = j; i=-i; }

...matching the TARGET_ZCODE case above. This fixes the hang and the incorrect "dan, x pie" response.

I don't know what's going on with the wrong response to "dan, x conscience". This is new in 6/12, so it's either a separate bug or the semantics of orders have shifted.
(0004410)
zarf (developer)
2016-04-03 22:23

I have a feeling that this was a bug fixed in the 6/11 libraries for Zcode but not for Glulx. I don't have a citation for that though.
(0004411)
DavidG (developer)
2016-04-04 02:21

Let's add some more context:

    if (usual_grammar_after == 0) {
        j = verb_wordnum;
        i = RunRoutines(actor, grammar);
        #Ifdef DEBUG;
        if (parser_trace >= 2 && actor.grammar ~= 0 or NULL)
            print " [Grammar property returned ", i, "]^";
        #Endif; ! DEBUG

        #Ifdef TARGET_ZCODE;
        if ((i ~= 0 or 1) &&
            (UnsignedCompare(i, dict_start) < 0 ||
             UnsignedCompare(i, dict_end) >= 0 ||
             (i - dict_start) % dict_entry_size ~= 0)) {
            usual_grammar_after = j;
            i=-i;
        }

        #Ifnot; ! TARGET_GLULX
        if (i < 0) { usual_grammar_after = verb_wordnum; i=-i; }
        #Endif;

        if (i == 1) {
            results-->0 = action;
            results-->1 = 2;            ! Number of parameters
            results-->2 = noun;
            results-->3 = second;
            rtrue;
        }
        if (i ~= 0) { verb_word = i; wn--; verb_wordnum--; }
        else { wn = verb_wordnum; verb_word = NextWord(); }
    }
    else usual_grammar_after = 0;
(0004412)
DavidG (developer)
2016-04-04 02:29
edited on: 2016-04-04 02:31

The suggestion to change "verb_wordnum" to "j" within the #Ifnot; section has me a bit confused. As I look at the code, verb_wordnum should hold the same content as j. But it does fix two-thirds of the problems, as you state.

I think the problem with DAN, X CONSCIENCE may be related to 0001813 or 0001885.

(0004413)
DavidG (developer)
2016-04-04 02:34

Corresponding issue at Github: https://github.com/DavidGriffith/inform6lib/issues/34 [^]
(0004414)
zarf (developer)
2016-04-05 08:52

In the given example, the grammar routine changes the value of verb_wordnum (but not j).
(0004429)
DavidG (developer)
2016-04-17 01:27
edited on: 2016-04-17 01:39

As part of the solution to 0001885, I attempted to consolidate Roger's code back into actor_act(). Evidently I didn't fully understand what he was doing there. I've rolled back that chunk of parserm.h to fix this problem and then have another go at optimizing the code.

I'm going to hold this issue open until I finish the optimization CORRECTLY.

(0004431)
DavidG (developer)
2016-04-20 22:49

Since taking a fresh look at the solution to 0001813, I've come to the conclusion that this bug was caused by subsequent wrong turns, now rectified.

- Issue History
Date Modified Username Field Change
2016-04-03 22:10 zarf New Issue
2016-04-03 22:12 zarf Description Updated View Revisions
2016-04-03 22:12 zarf Steps to Reproduce Updated View Revisions
2016-04-03 22:16 zarf Note Added: 0004409
2016-04-03 22:23 zarf Note Added: 0004410
2016-04-04 02:13 DavidG Issue Monitored: DavidG
2016-04-04 02:21 DavidG Note Added: 0004411
2016-04-04 02:29 DavidG Note Added: 0004412
2016-04-04 02:31 DavidG Note Edited: 0004412 View Revisions
2016-04-04 02:34 DavidG Note Added: 0004413
2016-04-04 22:31 DavidG Assigned To => DavidG
2016-04-04 22:31 DavidG Status new => acknowledged
2016-04-05 08:52 zarf Note Added: 0004414
2016-04-17 00:36 DavidG Note Added: 0004427
2016-04-17 01:27 DavidG Note Added: 0004429
2016-04-17 01:39 DavidG Note Edited: 0004429 View Revisions
2016-04-17 18:52 DavidG Note Deleted: 0004427
2016-04-20 22:49 DavidG Note Added: 0004431
2016-04-20 22:49 DavidG Status acknowledged => resolved
2016-04-20 22:49 DavidG Resolution open => fixed
2016-04-20 22:49 DavidG Status resolved => closed


Copyright © 2000 - 2010 MantisBT Group
Powered by Mantis Bugtracker