Newsgroups: comp.lang.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: 'C', is it's grammar context sensitive ? Message-ID: <1990Aug24.040932.18047@zoo.toronto.edu> Organization: U of Toronto Zoology References: <1990Aug23.164905.10261@NCoast.ORG> Date: Fri, 24 Aug 90 04:09:32 GMT In article <1990Aug23.164905.10261@NCoast.ORG> ramsey@NCoast.ORG (Cedric Ramsey) writes: >... for declarations the grammar is context sensitive. >Since the 'typedef-name' is an identifier is impossible to determine that >it is a type defintion without looking at the context... Correct. C's grammar has not been truly context-free, in the usual sense, since typedefs were added, over a decade ago. This is Excedrin Headache Number 3.14159 of writing a C parser. The standard answer is to have some sort of ugly feedback path between symbol table and scanner, so that the scanner can distinguish typedef names from other identifiers and tell the parser "this one's a typedef name". You can't easily do this with a pre-pass because typedefs obey the block-structured scope rules: you need nearly a full parse just to classify identifiers. -- Committees do harm merely by existing. | Henry Spencer at U of Toronto Zoology -Freeman Dyson | henry@zoo.toronto.edu utzoo!henry