Path: utzoo!attcan!uunet!lll-winken!lll-tis!mordor!joyce!sri-unix!garth!smryan From: smryan@garth.UUCP (Steven Ryan) Newsgroups: comp.lang.c Subject: Re: Is right recursive C grammar necessary? Message-ID: <734@garth.UUCP> Date: 15 Jun 88 20:57:27 GMT References: <428@erc3ba.UUCP> Reply-To: smryan@garth.UUCP (Steven Ryan) Organization: INTERGRAPH (APD) -- Palo Alto, CA Lines: 25 Church: Our Lady of Reluctant Software In article <428@erc3ba.UUCP> rsc@erc3ba.UUCP (Rich Chomiczewski) writes: >Is this right recursive grammar required by the ANSI C committee? >Can the above rule be written left recursive and still conform >to the ANSI C standard? A left recursive grammar can be automatically transformed into right recursive grammar and vice versa--the defined language remains context-free or regular. Right recursive or Griebach form is useful for writing a recursive-descent parser or using an LL(k) parse generator. Left or right recursive can be used for xxLR(k). The production was probably right recursive to ensure storage-class-specifiers precede the type-specifier (I don't know what the entire grammar is). A left recursive rule would require two productions. A -> xA | y would produce the same language as A -> A' y A' -> A'x | null sm ryan april come she will/may she will stay/june she'll change her tune/ july she will fly/august die she must/september i'll remember.