Newsgroups: comp.lang.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: LL(1) C grammar Message-ID: <1991Jun18.155743.2444@zoo.toronto.edu> Date: Tue, 18 Jun 1991 15:57:43 GMT References: <91-06-021@comp.compilers> Organization: U of Toronto Zoology In article <91-06-021@comp.compilers> jos@and.nl (J. Horsmeier) writes: >anyone out there having (knowing of) a LL(1) grammar for `C'... Parsing C using LL(1) is tricky. (Actually the same is true of LR(1)...) C is pretty intractable without some special-purpose fudges in the scanner, which don't fit cleanly into a normal LL(1)/LR(1) skeleton. Although I would not call it definitely impossible, I would be very surprised to see a workable LL(1) grammar for C without such help. If you want an example of why, consider the following legal C program: typedef int t; main(){ t i = sizeof(t); t: i = (t)(i+sizeof(i)); } C is *almost* LL(1), but typedefs, labels, casts, and sizeof make for some interesting parsing problems. It's doable, but it tends to require ad-hoc mechanisms rather than just machine-processed grammars. -- "We're thinking about upgrading from | Henry Spencer @ U of Toronto Zoology SunOS 4.1.1 to SunOS 3.5." | henry@zoo.toronto.edu utzoo!henry