Hi Claudio,

I was dealing with a left-recursion problem myself recently, and although I 
didn't find a way to support it directly (I was using PEG though, not META), 
I did find an algorithm to remove left-recursion from a rule. It goes as 
follows:

For each rule of the form
A -> A a_1  |  ...   |   A a_n  |   b_1  | ...  | b_m 

Where :
A is a left-recursive nonterminal
a_i is a sequence of nonterminals and terminals that is not empty
b_i is a sequence of nonterminals and terminals that does not start with A.

Replace the A rule by the production :

A -> b_1 A'  | ...  |  b_m A'

And create a new nonterminal

A' -> empty  | a_1 A'  |  ... | a_n  A'

Semantically, these rules are equivalent to the original A rule, yet they do 
not contain left-recursion.
Also, if (like in PEG), the grammar does not support "empty" rules, you can 
make the A' non-terminals in the A rule optional. This has the same effect.

I'm not sure what you're trying to accomplish, but if you're just facing 
practical problems, this algorithm should be of some help...

Cheers,

Hans


On Thursday 20 September 2007, Claudio Campos wrote:
> VPRI Folks,
>
> Are there any version or update of OMeta (Meta for Squeak) that support
> left recursion (as describe in paper: "pakrat parser can support left
> recursion" with memoization table)
>
> Thanks,
>
> Claudio Campos
> Santa Fe, Argentina
>
>
> _______________________________________________
> fonc mailing list
> [email protected]
> http://vpri.org/mailman/listinfo/fonc



-- 
If we cannot live so as to be happy, let us at least live so as to deserve it
 -- Immanuel Hermann Fichte

A liberal is a person whose interests aren't at stake at the moment
 -- Willis Player

Ark Linux - Linux for the Masses (http://arklinux.org)

Hans Schippers
Aspirant FWO - Vlaanderen
Formal Techniques in Software Engineering (FoTS)
University of Antwerp
Middelheimlaan 1
2020 Antwerpen - Belgium
Phone: +32 3 265 38 71
Fax: +32 3 265 37 77

_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc

Reply via email to