Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ucla-cs.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!ittatc!dcdwest!sdcsvax!sdcrdcf!ucla-cs!ekrell From: ekrell@ucla-cs.UUCP Newsgroups: net.lang.c Subject: Re: C not LALR(1) & compiler bugs Message-ID: <8508@ucla-cs.ARPA> Date: Fri, 24-Jan-86 11:47:02 EST Article-I.D.: ucla-cs.8508 Posted: Fri Jan 24 11:47:02 1986 Date-Received: Sun, 26-Jan-86 04:05:25 EST References: <10200035@ada-uts.UUCP> Organization: UCLA Computer Science Department Lines: 21 > C's grammar is CONTEXT SENSITIVE !? Can it be ?! First of all, the term "context sensitive" is incorrect. C's grammar is context free since every production in the grammar has exactly one non-terminal in its left hand side. The problem is the grammar is ambiguous, i.e., some programs have more than one parse tree. This is nothing out of the ordinary. Lots of languages have ambiguous "official" grammars. Even Ada does. For instance, is A(1) a reference to element 1 of an array A or is it a call to function A with 1 being an argument ??. You can't distinguish between the two syntactically. Please note that these two examples are not an indication of the language being ambiguous, only that a particular grammar is ambiguous. You can easily solve these two ambiguities by changing the grammar. In the Ada example, you simply don't distinguish in the grammar between array references and function calls and let the semantic phase do the required checking. -- Eduardo Krell UCLA Computer Science Department ekrell@ucla-locus.arpa ..!{sdcrdcf,ihnp4,trwspp,ucbvax}!ucla-cs!ekrell