Re: how to eliminate this left recursion
- From: "Oliver Wong" <owong@xxxxxxxxxxxxxx>
- Date: 26 Jul 2005 13:21:57 -0400
"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
.
- References:
- how to eliminate this left recursion
- From: Mike
- how to eliminate this left recursion
- Prev by Date: Re: Implementing a stack-based interpreter
- Next by Date: Re: Machine language and assembler translators?
- Previous by thread: Re: how to eliminate this left recursion
- Next by thread: Gene Generator
- Index(es):
Relevant Pages
|
|