net_4_0 bug
[mcs.git] / mcs / NOTES
blobccae274939a7ddf9c2709dfcf3f261b99f966a47
1 * Notes on improving error handling in MCS
2   (from Axel Schreiner <ats@cs.rit.edu>)
5 I included the 'recover' example with C# as well. Currently the package 
6 is at <http://www.cs.rit.edu/~ats/projects/jay/>. I did change some 
7 names and the embedding that the user does somewhat, i.e., it is not 
8 directly compatible with what you did.
10 Here is the important part about error recovery. To make the typical 
11 iterations bullet-proof, code them as follows:
13 opt     : // null
14         | opt WORD              { yyErrorFlag = 0; }
15         | opt error
17 seq     : WORD
18         | seq WORD              { yyErrorFlag = 0; }
19         | error
20         | seq error
22 list    : WORD
23         | list ',' WORD         { yyErrorFlag = 0; }
24         | error
25         | list error
26         | list error WORD       { yyErrorFlag = 0; }
27         | list ',' error
29 i.e., throw in 'error' wherever a token can be. 'yyErrorFlag' need not 
30 be set to zero, but if it is done this way, second errors are caught 
31 earlier. This may introduce s/r conflicts, but they tend to be harmless.
33 In your case -- the comment concerning error recovery at the beginning 
34 of your compiler jay file -- just adding 'error' to the different 
35 global things won't work. Your example will already have started to 
36 advance in one of the rules and 'error' is then not in the lookahead of 
37 wherever the parse then is. You need to put 'error' into the iteration 
38 above those global things.