Xref: utzoo comp.lang.c:19561 comp.unix.questions:14460 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!rpi!batcomputer!cornell!rochester!pt.cs.cmu.edu!andrew.cmu.edu!bobg+ From: bobg+@andrew.cmu.edu (Robert Steven Glickstein) Newsgroups: comp.lang.c,comp.unix.questions Subject: Solved! (Re: Yacc probs w/ANSI-C) Message-ID: Date: 23 Jun 89 16:56:10 GMT References: Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA Lines: 30 In-Reply-To: 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