YACC grammer for c

Jeff Lee jeff at gatech.EDU
Fri Dec 5 04:36:09 AEST 1986


>Harbison and Steele's book (the exact name I'm not sure of now; I've lent
>mine to a friend, but it's something like "C: A Reference Manual") contains
>an appendix with a full LR(1) grammar for C.  I've never tried YACCing it,
>so I don't know if it works.

The grammar in the back of Harbison and Steele is a real LALR(1) grammar
and it YACC's just fine. They have even gone to the trouble of using "open"
and "close" statements to remove the 1 shift/reduce error you normally
get when compiling if-then-else statements.

As a sideline, does anyone know what tool that they used to generate their
grammar? The grammar contains all the split states that one would expect
to come from an LALR(1) grammar that has been translated from an extended
BNF. The split states were named strange things with numbers in them, also.
(I haven't had a copy of H&S for over a year now so this is from memory).
-- 
Jeff Lee
CSNet:	Jeff @ GATech		ARPA:	Jeff%GATech.CSNet @ CSNet-Relay.ARPA
uucp:	...!{akgua,allegra,hplabs,ihnp4,linus,seismo,ulysses}!gatech!jeff



More information about the Comp.lang.c mailing list