[net.lang.c] C declaration syntax

lcc.niket@UCLA-LOCUS.ARPA (Niket K. Patwardhan) (07/21/85)

Sorry guys, I goofed. I should have changed declaration-specifiers not
declaration.
It should look like this instead.

declaration-specifiers:
		storage-specifier type-specifier-list
		type-specifier-list

where type-specifier-list is optional in the first line.

lcc.niket@UCLA-LOCUS.ARPA (Niket K. Patwardhan) (07/21/85)

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.

chris@umcp-cs.UUCP (Chris Torek) (07/21/85)

The standard is correct.  The portable C compiler allows (e.g.)

	f() {
		int static a;
		char register *b;
	}

I'll admit it *looks* odd....
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland