Solved! (Re: Yacc probs w/ANSI-C)
Robert Steven Glickstein
bobg+ at andrew.cmu.edu
Sat Jun 24 02:56:10 AEST 1989
In: 21-Jun-89 Yacc probs w/ANSI-C, I wrote
> I've written a parser for ANSI-C using YACC (adhering strictly to the
> grammar given in K&R, second edition) that doesn't work. Despite the
> claim in section A13 that "this grammar is acceptable to the YACC
> parser-generator"(modulo some changes, which I've made), it in fact is
not; it's not even LR(1).
My profuse apologies to Messrs. Kernighan and Ritchie. I had failed to
follow the advice given in section A13 that tells the Yacc user to write
all rules containing optional subrules twice. That is to say, I had
written
foo: bar opt_baz bletch
;
opt_baz:
| baz
;
when I should have written
foo: bar bletch
| bar baz bletch
;
Converting everything to the latter form fixed my problems. Thanks to
everyone who responded!
Bob Glickstein
More information about the Comp.unix.questions
mailing list