LALR(1) Grammer for C

Roger Hale roger at ll-sst
Thu Oct 24 06:55:12 AEST 1985


[From: datacube!stephen; Date: 21 Oct 85 15:12:00 GMT]
> I have recently been engaged in implementing a yacc grammar based
> on the one provided in Harbison and Steele's _C: A Reference Manual_ and
> have encountered a bug. On page 337 the following productions have been
> provided:
> 
> <key_dcltr> ::= <identifier>
> ...
> <0008> ::= <key_dcltr>
> <0008> ::= <key_dcltr> , <key_dcltr>
> ...
> 
> Neither <key_dcltr> nor <0008> are otherwise referenced in the grammar.

I saw these orphans a while ago, too; here's what they suggest to me:

[enter just so story]

The line
	<p2_dcltr> ::= <p2_dcltr> ( <formals_declaration> )
used to have <keys_dcltr> (or some such name) in place of <formals_declaration>,
and a line group

	<keys_dcltr> ::=
	<keys_dcltr> ::= <0008>
followed the group defining <0008>.  [This being the output of their parser
generator.]  This gives function declarators like
	main(argc, argv) .
To accommodate the new style
	main(int argc, char **argv)
<formals_declaration> was defined and plugged into <p2_dcltr>, and <keys_dcltr>
was garbage collected, but not <0008> or <key_dcltr> (perhaps because <0008>
refers to itself).

[leave just so story]

FIX:	Just flush <key_dcltr> and <0008>.

Anyway, that's my opinion, just going by the text in front of me.
[Standard cover-everything disclaimer]
Flames to me, not the net; I'll warm up some chicken soup with them
if they're nice and toasty.

Yours,			Roger Hale
		Arpa:	roger at ll-sst.arpa
		Uucp:	{ucbvax,...}!roger%ll-sst.arpa might work



More information about the Comp.lang.c mailing list