jeff@gatech.UUCP (Jeff Lee) (12/04/84)
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. The book might be good for someone who doesn't currently have access to the proposed standard. It was just published this last June ('84) so it might be hard to get, but one of the local B. Daltons (Lenox in Atlanta) seemed to have more than their share of copies. -- Jeff Lee CSNet: Jeff @ GATech ARPA: Jeff.GATech @ CSNet-Relay uucp: ...!{akgua,allegra,rlgvax,sb1,unmvax,ulysses,ut-sally}!gatech!jeff
draves@harvard.ARPA (Richard Draves) (12/07/84)
> 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