BSD 3 development
[unix-history] / usr / src / cmd / yacc / yaccdiffs
CommitLineData
42d6e430
BJ
1
2
3
4
5
6
7
8
9
10 Yacc Differences
11
12
13
14
15
16This document gives a short list of differences between the
17new Yacc and earlier Yaccs.
18
19_\bB_\bu_\bg_\bs _\bF_\bi_\bx_\be_\bd
20
211. There was a bug which caused Yacc to silently steal
22 away in the night if an action had mismatched '' in it;
23 this is fixed.
24
252. A number of table size overflow conditions used to be
26 checked incorrectly or not at all; this is now better.
27
283. A bug which suppressed the printing of some rules with
29 empty RHS's on the y.output file has been fixed.
30
31_\bS_\bp_\be_\be_\bd_\bu_\bp_\bs, _\bS_\bh_\br_\bi_\bn_\bk_\bs, _\ba_\bn_\bd _\bD_\bi_\bd_\bd_\bl_\be_\bs
32
331. The old optimizer (-o) flag is now the default in Yacc.
34 At the same time, the Yacc process itself has been sped
35 up; the result is that Yacc takes about the same or
36 slightly longer on short inputs, but is much faster on
37 long inputs.
38
392. The optimized parsers produced by Yacc are likely to be
40 2-3 times faster and 1-2k bytes smaller than the old
41 ones, for medium/large grammars. The time to parse is
42 now essentially independent of the grammar size; it
43 used to grow as the size of the grammar did.
44
453. The y.output file has been considerably reformatted, to
46 make it easier to read. The old "goto" table is gone;
47 the goto's for nonterminal symbols are now printed in
48 the states where they occur. Rules which can be
49 reduced in a state have their rule number printed after
50 them, in (). This makes it much easier to interpret
51 the "reduce n" actions. The message "same as n" has
52 been removed; duplicate states are in fact duplicated,
53 saving shuffling and cross-referencing.
54
554. Various table sizes are somewhat bigger.
56
575. The form feed character, and the construction '\f', are
58 now recognized; form feed is ignored (=whitespace) on
59 input.
60
61
62
63
64 January 14, 1977
65
66
67
68
69
70 - 2 -
71
72
73
746. The arrays "yysterm" and "yysnter" are no longer pro-
75 duced on output; they were little used, and took up a
76 surprising amount of space in the parser.
77
787. Rules in the input which are not reduced are now com-
79 plained about; they may represent unreachable parts of
80 the grammar, botched precedence, or duplicate rules.
81 As with conflicts, a summary complaint, "n rules not
82 reduced", appears at the terminal; more information is
83 on the y.output file.
84
85_\bN_\be_\bw _\bF_\be_\ba_\bt_\bu_\br_\be_\bs
86
871. The actions are now copied into the middle of the
88 parser, rather than being gathered into a separate rou-
89 tine. It's faster. Also, you can return a value from
90 yyparse (and stop parsing...) by saying `return(x);' in
91 an action. There are macros which simulate various
92 interesting parsing actions:
93
94 YYERROR causes the parser to behave as if a syntax
95 error had been encountered (i.e., do error recovery)
96 YYACCEPT causes a return from yyparse with a value of 0
97 YYABORT causes a return from yyparse with a value of 1
98
99
1002. The repositioning of the actions may cause scope prob-
101 lems for some people who include lexical analyzers in
102 funny places. This can probably be avoided by using
103 another new feature: the `-d' option. Invoking Yacc
104 with the -d option causes the #defines generated by
105 Yacc to be written out onto a file called "y.tab.h",
106 (as well as on the "y.tab.c" file). This can then be
107 included as desired in lexical analyzers, etc.
108
1093. Actions are now permitted within rules; for such
110 actions, $$, $1, $2, etc. continue to have their usual
111 meanings. An error message is returned if any $n
112 refers to a value lying to the right of the action in
113 the rule. These internal actions are assumed to return
114 a value, which is accessed through the $n mechanism.
115 In the y.output file, the actions are referred to by
116 created nonterminal names of the form $$nnn. All
117 actions within rules are assumed to be distinct. If
118 some actions are the same, Yacc might report
119 reduce/reduce conflicts which could be resolved by
120 explicitly identifying identical actions; does anyone
121 have a good idea for a syntax to do this? The = sign
122 may now be omitted in action constructions of the form
123 ={ ... }.
124
125
126
127
128
129
130 January 14, 1977
131
132
133
134
135
136 - 3 -
137
138
139
1404. As a result of the rearrangement of rules, people who
141 thought they knew what $1 really turned into, and wrote
142 programs which referred to yypv[1], etc., are in trou-
143 ble. See Steve Johnson if you are really suffering.
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196 January 14, 1977
197
198