Re: Problem with infinite left-recursion...

tophat!mauney@uunet.uu.net (Jon Mauney)
Wed, 14 Dec 1994 21:38:28 GMT

          From comp.compilers

Related articles
Problem with infinite left-recursion... cbs@ascinc.com (1994-12-12)
Re: Problem with infinite left-recursion... jjan@cs.rug.nl (1994-12-14)
Re: Problem with infinite left-recursion... tophat!mauney@uunet.uu.net (1994-12-14)
Re: Problem with infinite left-recursion... davidm@Rational.COM (1994-12-19)
| List of all articles for this month |

Newsgroups: comp.compilers
From: tophat!mauney@uunet.uu.net (Jon Mauney)
Keywords: parse
Organization: Mauney Computer Consulting
References: 94-12-086
Date: Wed, 14 Dec 1994 21:38:28 GMT

cbs@ascinc.com (Casper B. Stoel) writes:


>I have a problem with left-recursion in my grammar. I am wondering if
>there is a 'standard' way of breaking the recursion? Is there an easy
>way of breaking up the rule into multiple rules?


Most left and right recursion in grammars follows a standard idiom.
To describe a list of A's left-recursively, we typically write
      list ::= list A
| A
To describe a list of A's right-recursively, we typically write
      list ::= A more-A
      more-A ::= A
| empty
Separators go in fairly obvious places, if needed.
Expressions are just lists of operands separated by operators.
If you have a lot of left-recursive rules it is tedious to
change them all, but not difficult.
--
Jon Mauney jon@mauney.com
Mauney Computer Consulting (919) 828-8053
Raleigh NC
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.