[LEPL] error with Delayed

15 views
Skip to first unread message

jazg

unread,
May 3, 2010, 3:48:46 AM5/3/10
to lepl
Here's the problem as simplified as possible:


c = Delayed()

a = Literal("a") + c
b = Literal("b")
c += a | b

print c.parse("ab")


The error is:
lepl\matchers\core.py", line 215, in _match
AttributeError: 'RegexpContainer' object has no attribute '_match'


Is that a bug or am I doing something wrong? What can be done about it?

--
You received this message because you are subscribed to the Google Groups "lepl" group.
To post to this group, send email to le...@googlegroups.com.
To unsubscribe from this group, send email to lepl+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/lepl?hl=en.

andrew cooke

unread,
May 5, 2010, 8:17:57 PM5/5/10
to lepl

Whoa. Yes, that is very much a bug. Do you know what version of Lepl
you have installed? Also, it might be useful to know what Python
version and OS (but to be honest it's such a bad bug I suspect it's
going to be easy to reproduce). I'll look at it now (need to switch
computers...) and get back to you with a fix or work-around ASAP.

Thanks,
Andrew

jazg

unread,
May 5, 2010, 8:27:00 PM5/5/10
to lepl
lepl 4.1, same error in python 2.7 and 3.1, windows xp

andrew cooke

unread,
May 5, 2010, 8:38:09 PM5/5/10
to lepl
Thanks (and thanks for the nice simple test case).

OK, so my initial attempts to reproduce this on 4.2.1 failed. If you
used easy_install, then

easy_install -U lepl

should update you to that.

What's happening is that the internal representation used while
rewriting a parser to a regular expression is "escaping". My guess is
that it didn't show up in tests for that release because once a parser
is "complex enough", the rewriting is no longer possible and the
internal representation is converted into a matcher.

So a work around would be to force that (make the parser "complex
enough") and the simplest way to do that is to add a function. The
following change (which basically does nothing, but calls the 'list'
function/constructor to do it) might avoid the problem (if you have
the time I'd be interested to know if it does):

c = Delayed()

a = Literal("a") + c
b = Literal("b")
c += (a | b) >= list

Anyway, I'll continue looking at this to make sure it really is fixed
now (I don't understand what has changed to fix this in 4.2.1 - it may
be a platform thing as I am using Linux). if either of the above
don't help, please say...

Cheers,
Andrew

andrew cooke

unread,
May 5, 2010, 8:57:11 PM5/5/10
to lepl
Just to confirm that I can see it with (something close to) 4.1 on
Linux, so the fix I gave should work for you (it's not a platform
issue).

Also, the ">= list" fix works, too. :o)

Andrew

jazg

unread,
May 5, 2010, 8:57:29 PM5/5/10
to lepl
Both of those (using a function and upgrading) fixed the problem for
me.

andrew cooke

unread,
May 5, 2010, 8:58:21 PM5/5/10
to lepl
Excellent, thanks (our emails must have crossed on the wire!).

Andrew
Reply all
Reply to author
Forward
0 new messages