Path: utzoo!utgpu!watserv1!watmath!att!pacbell!pacbell.com!mips!swrinde!zaphod.mps.ohio-state.edu!usc!snorkelwacker!paperboy!meissner From: meissner@osf.org (Michael Meissner) Newsgroups: comp.lang.c Subject: Re: Summary: 'C', is it's grammar context sensitive ? Message-ID: Date: 31 Aug 90 14:39:45 GMT References: <1990Aug30.223440.7377@NCoast.ORG> <11508@crdgw1.crd.ge.com> Sender: news@OSF.ORG Organization: Open Software Foundation Lines: 37 In-reply-to: volpe@underdog.crd.ge.com's message of 31 Aug 90 12:07:23 GMT In article <11508@crdgw1.crd.ge.com> volpe@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@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?