[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / compiler / yaccParser / MAIL.byacc
1 Return-Path: mattson@dcs.gla.ac.uk
2 Return-Path: <mattson@dcs.gla.ac.uk>
3 Received: from starbuck.dcs.gla.ac.uk by goggins.dcs.gla.ac.uk 
4           with LOCAL SMTP (PP) id <02535-0@goggins.dcs.gla.ac.uk>;
5           Thu, 18 Nov 1993 09:59:57 +0000
6 To: Robert.Corbett@Eng.Sun.COM
7 cc: partain@dcs.gla.ac.uk
8 Subject: Re: [Robert.Corbett@Eng.Sun.COM: Re: possible bug, byacc 1.9]
9 In-reply-to: Your message from 9:46 AM GMT
10 Date: Thu, 18 Nov 93 09:59:53 +0000
11 From: Jim Mattson <mattson@dcs.gla.ac.uk>
12
13 It's clear that this feature improves error detection, but it's not
14 clear to me how it improves the scope of possible error recoveries.
15
16 If I understand your explanation, it sounds like the only alternative 
17 (short of changing the byacc source) is to add tens or hundreds of
18 error productions sprinkled throughout the code anywhere that an
19 unexpected symbol may appear, since no intervening reductions are
20 allowed.  
21
22 Although the addition of all of these error productions increases the
23 scope of possible error recoveries, the same functionality (with, in fact,
24 the same approach) is provided by other versions of yacc.  The apparent
25 advantage of other versions of yacc is that they provide a facility by
26 which a single _default_ error production can handle a number of
27 possibilities (after some possibly illegal reductions have been performed).
28
29 Am I missing something?
30
31 --jim
32 --------
33 In reply to the following message:
34 --------
35
36 ------- Forwarded Message
37
38 Date: Wed, 17 Nov 93 22:33:44 PST
39 From: Robert.Corbett@Eng.Sun.COM (Robert Corbett)
40 Message-Id: <9311180633.AA07545@lupa.Eng.Sun.COM>
41 To: partain@dcs.gla.ac.uk
42 Subject: Re: possible bug, byacc 1.9
43
44 It is a feature.  One difference between Berkeley Yacc and its
45 predecessors is that the parsers Berkeley Yacc produces detect
46 errors as soon as possible.  That will lead to different behavior.
47
48 In this particular case, the token "IN" is not a permitted
49 lookahead symbol in state 390.  AT&T Yacc parsers will not detect
50 the error until after doing more reductions than Berkeley Yacc
51 parsers.  Doing reductions in illegal contexts limits the scope of
52 recoveries that are possible (unless backtracking is possible).
53
54 I am sorry that my attempt to provide better error detection is
55 causing you trouble.  You can get the AT&T Yacc behavior by
56 replacing the routine sole_reduction in mkpar.c with a routine
57 that returns the most frequently occurring reduction.
58
59                                         Yours truly,
60                                         Bob Corbett
61
62 - ----- Begin Included Message -----
63
64 >From partain@dcs.gla.ac.uk Wed Nov 17 05:03:44 1993
65 To: robert.corbett@Eng
66 Subject: possible bug, byacc 1.9
67 Date: Wed, 17 Nov 93 12:33:42 +0000
68 From: Will Partain <partain@dcs.gla.ac.uk>
69
70 Sadly, it's in a *HUGE* grammar, which I will send you if you have the
71 stomach for it.
72
73 The problem occurs where {Sun's /usr/lang/yacc, bison} say:
74
75     state 390
76
77         aexp  ->  var .   (rule 356)
78         aexp  ->  var . AT aexp   (rule 366)
79
80         AT      shift, and go to state 508
81         $default        reduce using rule 356 (aexp)
82
83 but byacc says
84
85     state 396
86         aexp : var .  (356)
87         aexp : var . AT aexp  (366)
88
89         AT  shift 511
90         error  reduce 356
91         VARID  reduce 356
92         CONID  reduce 356
93         VARSYM  reduce 356
94         CONSYM  reduce 356
95         MINUS  reduce 356
96         INTEGER  reduce 356
97         FLOAT  reduce 356
98         CHAR  reduce 356
99         STRING  reduce 356
100         CHARPRIM  reduce 356
101         INTPRIM  reduce 356
102         FLOATPRIM  reduce 356
103         DOUBLEPRIM  reduce 356
104         CLITLIT  reduce 356
105         VOIDPRIM  reduce 356
106         CCURLY  reduce 356
107         VCCURLY  reduce 356
108         SEMI  reduce 356
109         OBRACK  reduce 356
110         CBRACK  reduce 356
111         OPAREN  reduce 356
112         CPAREN  reduce 356
113         COMMA  reduce 356
114         BQUOTE  reduce 356
115         RARROW  reduce 356
116         VBAR  reduce 356
117         EQUAL  reduce 356
118         DOTDOT  reduce 356
119         DCOLON  reduce 356
120         LARROW  reduce 356
121         WILDCARD  reduce 356
122         LAZY  reduce 356
123         WHERE  reduce 356
124         OF  reduce 356
125         THEN  reduce 356
126         ELSE  reduce 356
127         PLUS  reduce 356
128
129 The token that comes in is "IN"; bison/sun-yacc-generated parser
130 tickles the default, reduces to "aexp", but byacc-generated tickles
131 "error" and the rest is history.
132
133 Maybe this is enough for you to exclaim, "Oh yes, that's a feature."
134
135 As I say, more info if you want it.
136
137 Will Partain
138
139
140 - ----- End Included Message -----
141
142
143
144 ------- End of Forwarded Message
145
146 --------