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