Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site harvard.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!draves From: draves@harvard.ARPA (Richard Draves) Newsgroups: net.unix,net.lang.c Subject: Re: Anybody have any experience with (Vax) Tartan C compiler? Message-ID: <184@harvard.ARPA> Date: Thu, 6-Dec-84 23:19:50 EST Article-I.D.: harvard.184 Posted: Thu Dec 6 23:19:50 1984 Date-Received: Sat, 8-Dec-84 07:04:25 EST References: <505@astrovax.UUCP> <5805@seismo.UUCP> <11135@gatech.UUCP> Organization: Aiken Computation Laboratory, Harvard Lines: 16 Xref: watmath net.unix:3050 net.lang.c:3429 > Just for general information, the Tartan Labs people have a book out > (C: A Reference Manual by Samuel Harbison and Guy Steele) that goes > fairly in depth about the implementation details of implementing a C > compiler. It also has a true LALR(1) grammar in appendix C for C. I haven't looked at their grammar, but I doubt if what I would call a true LR(k) grammar for C is possible. The problem is typedefs. The expression "(a) * b" may be either a cast or a multiplication, depending on whether "a" is a variable or a typedef. Parsing this requires a symbol table lookup. The grammars I have seen all have their lexxer make this check, contingent on a flag that is set by the parser. This is because declarations like "int a" in a function, after "a" has been typedef'ed, are legal, so sometimes "a" must be recognized as a vanilla identifier, and sometimes as a type. Rich