[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: LPEG > 0.10 regression: 'B' (pattern may not have fixed length)
- From: Daurnimator <quae@...>
- Date: Sun, 17 Apr 2016 04:51:56 +1000
On 16 April 2016 at 02:53, Roberto Ierusalimschy <email@example.com> wrote:
> This whole story goes back to these messages:
> https://github.com/xolox/lua-lxsh/issues/5 (the problem)
> http://lua-users.org/lists/lua-l/2015-07/msg00356.html (the "fix")
> The issue is that I "fixed" the wrong problem, because of a bad
> error message. The original problem was the one that appeared in the
>> lpeg = require"lpeg"
>> D = lpeg.R'09'
>> BB = lpeg.B(-D, 1)
> stdin:1: bad argument #1 to 'B' (pattern may not have fixed length)
> But of course 'B' has a fixed length, and so the "obvious fix" for that
> message was to allow fixed lengths equal to zero. But look behind with
> zero lengths may be correct from a formal point of view, but they are
> useless (as it means "go back zero positions") and probably not doing
> what the programmer expects. The correct fix should be to rephrase the
> error message, not to allow look behind with zero-length patterns.
> -- Roberto
btw, I just had this lpeg.B issue come up in a totally separate context.
I was updating lunamark to work with 5.3, and wrote this:
Interestingly, they were passing a fixed-length pattern of length 1 to
lpeg.B, but passing a second argument of 2.
i.e. checking which single character was 2 before the current position.