Re: how to eliminate this left recursion



"Mike" <hammeron56@xxxxxxxxx> wrote in message

> I understand how to eliminate left-recursion when a grammar rule
> looks like this: a->ab | c
>
> but how do you do it when it looks only like this: a->ab

If the expansion of "a" is "ab" with no other alternative, then you have an
infinite recursion that you can never get out of.

> Such a grammar rule exists in the following regular expressions grammar
> (see rule ERE_expression)
[snip]
> ERE_expression : one_character_ERE
> | '^'
> | '$'
> | '(' extended_reg_exp ')'
> | ERE_expression ERE_dupl_symbol
> ;
[snip]

Seems to me, this could be rewritten as:

ERE_expression : ( one_character_ERE
| '^'
| '$'
| '(' extended_reg_exp ')'
)
( ERE_dupl_symbol )*;

- Oliver
.



Relevant Pages

  • Re: how to eliminate this left recursion
    ... Mike wrote: ... > I understand how to eliminate left-recursion when a grammar rule ... Prev by Date: ...
    (comp.compilers)
  • how to eliminate this left recursion
    ... I understand how to eliminate left-recursion when a grammar rule ... Such a grammar rule exists in the following regular expressions grammar ... Prev by Date: ...
    (comp.compilers)