Add notes
authorMiguel de Icaza <miguel@gnome.org>
Thu, 12 Dec 2002 00:22:16 +0000 (00:22 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Thu, 12 Dec 2002 00:22:16 +0000 (00:22 -0000)
svn path=/trunk/mcs/; revision=9579

mcs/mcs/NOTES [new file with mode: 0644]

diff --git a/mcs/mcs/NOTES b/mcs/mcs/NOTES
new file mode 100644 (file)
index 0000000..ccae274
--- /dev/null
@@ -0,0 +1,38 @@
+* Notes on improving error handling in MCS
+  (from Axel Schreiner <ats@cs.rit.edu>)
+
+
+I included the 'recover' example with C# as well. Currently the package 
+is at <http://www.cs.rit.edu/~ats/projects/jay/>. I did change some 
+names and the embedding that the user does somewhat, i.e., it is not 
+directly compatible with what you did.
+
+Here is the important part about error recovery. To make the typical 
+iterations bullet-proof, code them as follows:
+
+opt     : // null
+        | opt WORD              { yyErrorFlag = 0; }
+        | opt error
+
+seq     : WORD
+        | seq WORD              { yyErrorFlag = 0; }
+        | error
+        | seq error
+
+list    : WORD
+        | list ',' WORD         { yyErrorFlag = 0; }
+        | error
+        | list error
+        | list error WORD       { yyErrorFlag = 0; }
+        | list ',' error
+
+i.e., throw in 'error' wherever a token can be. 'yyErrorFlag' need not 
+be set to zero, but if it is done this way, second errors are caught 
+earlier. This may introduce s/r conflicts, but they tend to be harmless.
+
+In your case -- the comment concerning error recovery at the beginning 
+of your compiler jay file -- just adding 'error' to the different 
+global things won't work. Your example will already have started to 
+advance in one of the rules and 'error' is then not in the lookahead of 
+wherever the parse then is. You need to put 'error' into the iteration 
+above those global things.
\ No newline at end of file