Inform - Support - Patches

About Patches  

Compiler  
Library  

DM4 Errata  

Issue L61109     [previous patch]

Problem with 'Give reverse' grammar
Submitted by: Cedric Knight     Appeared in: Library 6/11 or before     Fixed in: -
Problem

The line in the standard Grammar:

  * creature held -> Give reverse

gives rise to an inappropriate parser message when failing to match this line:

  * held 'to' creature -> Give

>SHOW 9 OF HEARTS TO AUDIENCE
You can only do that to something animate.
Solution

This is quite a deep-seated problem, requiring a general solution. At the moment, each grammar line is checked until it fails, and the error given is the least serious and most specific. The appropriateness of error messages can be improved by continuing to scan the line to find the worst, most general error, and base the error on the line with the 'best worst problem'. The general philosophy is to first guess which sense of a command is most likely to be intended, then see why it doesn't make sense, rather than just look at the first few words.

This change it fairly radical; it may need some refinement with the plural errors, and can affect some hacks that assume that scope or GPR routines are not called if a previous token has failed. The bailout condition is also slightly arbitrary.

Apply the following patch:

diff -u libbeta2\parserm.h lib\parserm.h
--- libbeta2\parserm.h	Fri Jan 16 06:11:00 2004
+++ lib\parserm.h	Mon Jan 26 12:15:34 2004
@@ -1241,7 +1241,7 @@
 ! ----------------------------------------------------------------------------

 [ Parser__parse  results   syntax line num_lines line_address i j k
-                           token l m;
+                           token l m line_etype;

     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     !
@@ -1738,7 +1738,7 @@
         parameters = 0;
         nsns = 0; special_word = 0; special_number = 0;
         multiple_object-->0 = 0;
-        etype = STUCK_PE;
+        etype = STUCK_PE; line_etype = 100;
         wn = verb_wordnum+1;

     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -1811,7 +1811,11 @@
                 #Endif; ! DEBUG

                 if (l == REPARSE_CODE) jump ReParse;
-                if (l == false) break;
+                if (l == false) {
+                    if (etype < line_etype) line_etype = etype;
+                    if (etype == STUCK_PE || wn >= num_words) break;
+                }
+
             }
             else {

@@ -1823,6 +1827,8 @@
                 ! However, if the superfluous text begins with a comma or "then" then
                 ! take that to be the start of another instruction

+                if (line_etype < 100) break;
+
                 if (wn <= num_words) {
                     l = NextWord();
                     if (l == THEN1__WD or THEN2__WD or THEN3__WD or comma_word) {
@@ -1936,6 +1942,7 @@
         ! The line has failed to match.
         ! We continue the outer "for" loop, trying the next line in the grammar.

+        if (line_etype < 100) etype = line_etype;
         if (etype > best_etype) best_etype = etype;
         if (etype ~= ASKSCOPE_PE && etype > nextbest_etype) nextbest_etype = etype;

@@ -2484,8 +2491,7 @@
                 wn = desc_wn;
                 jump TryAgain2;
             }
-            if (etype == MULTI_PE or TOOFEW_PE && multiflag) etype = STUCK_PE;
-            etype=CantSee();
+            etype = CantSee();
             jump FailToken;
         } ! Choose best error

@@ -3580,7 +3586,6 @@
         if (i has visited && Refers(i,wn) == 1) e = SCENERY_PE;
     }
     wn++;
-    if (etype > e) return etype;
     return e;
 ]


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.