Summary: 'C', is it's grammar context sensitive ?

Michael Meissner meissner at osf.org
Sat Sep 1 00:39:45 AEST 1990


In article <11508 at crdgw1.crd.ge.com> volpe at underdog.crd.ge.com
(Christopher R Volpe) writes:

	...

| It's illegal because typedef names are in the same name space as
| objects according to section A11.1 of K&R2. Therefore, an identifier
| cannot be declared as both a typedef name and an object in the
| same scope. The typedef name can be redeclared in an inner block, however.

Providing a type is specified in the declaration (this is where the
classic quote 'the ice is thin here' in K&R-I is used).

| |>
| |>In lue of the above speculations, the compiler wouldn't have to make 
| |>multiple passes to collect typedef names. I hope this is true or 
| |>the grammar at back of K&R2 would not be acceptable to yacc, as claimed,
| |>without a rewrite, I could be wrong though.  
| 
| The grammar is not claimed to be acceptable to yacc as-is. Section
| A13 says that the grammar is acceptable to yacc if the production
| "typedef_name: identifier" is removed and typedef_name is made a 
| terminal symbol.

The classic case that cannot be handled without knowing whether you
have an identifier or typedef name is:

	func( (ident1) * ident2 );

If ident1 is a typedef name, then the argument to func casts the result of
dereferencing pointer ident2 to ident1.  If ident1 is an identifer,
than the argument is the multiplication between ident1 and ident2.
--
Michael Meissner	email: meissner at osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

Do apple growers tell their kids money doesn't grow on bushes?



More information about the Comp.lang.c mailing list