Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!sun-barr!texsun!texbell!bellcore!krazykat.ctt.bellcore.com!quasar From: quasar@krazykat.ctt.bellcore.com (Laurence R. Brothers) Newsgroups: comp.lang.c Subject: LL(k) grammar for c? Message-ID: <16013@bellcore.bellcore.com> Date: 9 May 89 13:31:01 GMT Sender: news@bellcore.bellcore.com Reply-To: quasar@krazykat.ctt.bellcore.com (Laurence R. Brothers) Organization: Bell Communications Research, Piscataway, NJ Lines: 54 First: Please reply via email, since I don't read this group. I want a program that produces parse trees of c programs. In the absence of one, I'll take a good grammar and write the program myself. Since I want the parse tree to at least vaguely resemble the intuitive structure of the code, I'd prefer a LL grammar that would allow a recursive-descent parser to be easily written. I realize that you can't have a true LL(k) grammar for C, but I'd like one that's close, at least. Alternatively, I'd like a yacc style LR grammar, but one with reaonable rules for things like expressions. I currently have a yacc grammar, but about 64 rules fire just to parse a literal expression. For an example of what I don't want, this is the parse of the c statement "Return y;" in the yacc grammar I have now. decl_or_stmt stmt bal_stmt basic_stmt return_stmt Return list_exp exp assign_exp cond_exp or_oper_exp and_oper_exp bitor_oper_exp bitxor_oper_exp bitand_oper_exp equ_oper_exp rel_oper_exp shift_oper_exp add_oper_exp mult_oper_exp unary_oper_exp cast_exp prefix_exp postfix_exp primary_exp primary_p2_exp primary_p1_exp identifier ; Laurence R. Brothers (quasar@ctt.bellcore.com) Bellcore -- Computer Technology Transfer -- Knowledge-Based Systems Development "...to seek the helpless future...."