Path: utzoo!attcan!uunet!lll-winken!ames!haven!uflorida!gatech!mcnc!rti!xyzzy!meissner From: meissner@xyzzy.UUCP (Michael Meissner) Newsgroups: comp.lang.c Subject: Re: YACC grammar for C language Keywords: YACC grammar for C language Message-ID: <2773@xyzzy.UUCP> Date: 12 Jan 89 03:57:42 GMT References: <175@calmasd.GE.COM> Reply-To: meissner@tiktok.UUCP (Michael Meissner) Organization: Data General (Languages @ Research Triangle Park, NC.) Lines: 43 In article <175@calmasd.GE.COM> jhh@calmasd.GE.COM (Jung Hamel) writes: | | Does anybody have or know of YACC grammar for C that does | not require the lexical analyser to differentiate typedef | names from other identifier names. We have tried to "fix" a | grammar with this but always get an illegal grammar for YACC. | Our lexical analyser does not have access to the full set of | typedef names. In short, it can't be done without a context sensitive parser (ie, without things like the lexical analyser knowing about the symbol table). Among other things, the following fragment: (identifer) * expression can be parsed either as a cast of dereferncing a pointer expression (if identifier is a typedef name) or multiplication (if identifier is a variable). This "feature" has probably been cursed by all C implementators ever afterward (I know I sure did). IMHO it is one of four things I would change if I could have my way and have all the extant source code change overnight. In case you are wondering, the other three are: 1) Change operator priorities, so that: x & mask == result, would be evaluated as (x & mask) == value; 2) Remove macro procedures and add inline capability as a mandated feature (including deletion of the inline function if there are no callers); 3) Fix the overloading of "extern" and "static", and mandate one global memory model (ie, the fact that UNIX supports a relaxed REF/DEF scheme, wheras K&R and ANSI mandate the more strict single DEF, multiple references model). Sigh, these won't get changed because the time for such changes has long since past. -- Michael Meissner, Data General. Uucp: ...!mcnc!rti!xyzzy!meissner Arpa: meissner@dg-rtp.DG.COM (or) meissner%dg-rtp.DG.COM@relay.cs.net