C declaration syntax

Niket K. Patwardhan lcc.niket at UCLA-LOCUS.ARPA
Mon Jul 22 00:29:18 AEST 1985


According to the declaration syntax specified in the standards document
(Page 41, Section C.5) the storage-specifier and type-specifiers can be
added in any arbitrary order. Further, if you look at the pseudo-BNF more
than one of each can be specified. I have never heard of anybody placing
the storage-specifier AFTER any of the type specifiers and would like to
see the pseudo-BNF changed. For example,

declaration:
	storage-specifier type-specifier-list init-declarator-list ;
	type-specifier-list init-declarator-list ;

I cannot put subcripts on this mail, so I specify what is optional here.
In the first line, type-specifier-list and init-declarator-list is optional.
In the second line, only the init-declarator-list is optional.

With such a BNF it becomes quite clear that the storage specifier occurs
only once. Of course, it also restricts the storage specifier to be the
first thing in the declaration. If anybody has used it in another place,
or knows of a compiler that allows it later in the declaration, I would
like to know about it.

A lot of people are going to use the pseudo-BNF in the document and feed it
to yacc and it would be a great help if it were as LR(1) as possible.



More information about the Comp.lang.c mailing list