MantisBT - I6 Library
View Issue Details
0001890I6 LibraryGeneralpublic2016-04-03 22:102016-04-20 22:49
zarf 
DavidG 
normalmildhave not tried
closedfixed 
6/12 
 
0001890: DM4 exercise 32 fails in Glulx
We 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.]

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;
No tags attached.
Issue History
2016-04-03 22:10zarfNew Issue
2016-04-03 22:12zarfDescription Updatedbug_revision_view_page.php?rev_id=1318#r1318
2016-04-03 22:12zarfSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=1320#r1320
2016-04-03 22:16zarfNote Added: 0004409
2016-04-03 22:23zarfNote Added: 0004410
2016-04-04 02:13DavidGIssue Monitored: DavidG
2016-04-04 02:21DavidGNote Added: 0004411
2016-04-04 02:29DavidGNote Added: 0004412
2016-04-04 02:31DavidGNote Edited: 0004412bug_revision_view_page.php?bugnote_id=0004412#r1322
2016-04-04 02:34DavidGNote Added: 0004413
2016-04-04 22:31DavidGAssigned To => DavidG
2016-04-04 22:31DavidGStatusnew => acknowledged
2016-04-05 08:52zarfNote Added: 0004414
2016-04-17 00:36DavidGNote Added: 0004427
2016-04-17 01:27DavidGNote Added: 0004429
2016-04-17 01:39DavidGNote Edited: 0004429bug_revision_view_page.php?bugnote_id=0004429#r1326
2016-04-17 18:52DavidGNote Deleted: 0004427
2016-04-20 22:49DavidGNote Added: 0004431
2016-04-20 22:49DavidGStatusacknowledged => resolved
2016-04-20 22:49DavidGResolutionopen => fixed
2016-04-20 22:49DavidGStatusresolved => closed

Notes
(0004409)
zarf   
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   
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   
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   
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   
2016-04-04 02:34   
Corresponding issue at Github: https://github.com/DavidGriffith/inform6lib/issues/34 [^]
(0004414)
zarf   
2016-04-05 08:52   
In the given example, the grammar routine changes the value of verb_wordnum (but not j).
(0004429)
DavidG   
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   
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.