[pypy-dev] rlb.parsing left recursion support ?

Gustavo Kuerten rubycoder at gmail.com
Sun May 8 14:53:40 CEST 2011


Armin,

My example is not equivalent to the actual test.
But here is the snippet from test_pypackrat.py

    def test_leftrecursion(self):
        class parser(PackratParser):
            """
            b: b 'a' | 'b';
            """
        print parser._code
        p = parser("b")
        res = p.b()
        assert res == "b"
        p = parser("bac")
        res = p.b()
        assert p._pos == 2
        assert res == "a"
        p = parser("baaaaaaaaaaaaaac")
        res = p.b()
        assert p._pos == 15
        assert res == "a"

This seems to indicate that it does support left recursion.

2011/5/8 Armin Rigo <arigo at tunes.org>
>
> Hi Gustavo,
>
> On Sun, May 8, 2011 at 9:39 AM, Gustavo Kuerten <rubycoder at gmail.com> wrote:
> > I noticed that there is a test in test_pypackrat.py which seems to suggest
> > that the parser supports left recursion.
> >
> > a: a ":" | "b";
>
> I cannot find this test anywhere.  Can you tell more precisely where
> it is from?  I looked in pypy/rlib/parsing/test/test_pypackrat.py.
>
> > So, does it or does it not support left recursion ?
>
> It does not, as far as I know.
>
>
> Armin



--
Regards,

G



More information about the pypy-dev mailing list