[LEPL] Drop(...)[1] doesn't drop?

14 views
Skip to first unread message

jazg

unread,
May 19, 2010, 4:56:22 PM5/19/10
to lepl
>>> xy = "x" & Drop("y")
>>> xy[1].parse("xy")
['xy']
>>> xy[:1].parse("xy")
['xy']
>>> xy[1:].parse("xy")
['x']
>>> xy[:2].parse("xyxy")
['x', 'x']

Why are the first 2 results ["xy"] and not ["x"]? It seems Drop is
ignored with [1] or [0:1] but works with any other type of repeat.

--
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 19, 2010, 5:26:32 PM5/19/10
to le...@googlegroups.com

That's a bug! Just playing around it seems to be in the Repeat matcher (ie
it's not a rewrite problem, which is where you'd expect most bugs).
Unfortunately that means there's no obvious workaround.

Hmmm. However, this appears to work OK?

xy = ('x' & Drop('y')) & Empty()

which might be enough to keep you going?

Sorry - I'll fix it, but I'm afraid it will likely be tomorrow (going out
tonight).

Thanks,
Andrew

andrew cooke

unread,
May 19, 2010, 9:03:34 PM5/19/10
to le...@googlegroups.com

I was wrong - this *is* a rewriter bug (which makes much more sense).

So you can fix it by using .config.no_compile_to_regexp():

>>> xy = ('x' & Drop('y'))[1]
>>> xy.parse('xy')
[u'xy']
>>> xy = ('x' & Drop('y'))[1]
>>> xy.config.no_compile_to_regexp()
<lepl.core.config.ConfigBuilder object at 0xbc9c90>
>>> xy.parse('xy')
['x']

Andrew


On Wed, May 19, 2010 at 01:56:22PM -0700, jazg wrote:

andrew cooke

unread,
May 20, 2010, 7:59:35 PM5/20/10
to le...@googlegroups.com

There's a fix now in hg:

hg clone -r 6929d709a6 https://lepl.googlecode.com/hg/ lepl

should get you the right code.

I'll do a minor release very soon (probably tomorrow).

Thanks again for the bug report,
Andrew

andrew cooke

unread,
May 20, 2010, 8:50:26 PM5/20/10
to le...@googlegroups.com

Released as 4.2.2 Andrew
Reply all
Reply to author
Forward
0 new messages