[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LPEG: P(fct) seems not to consume input
- From: Albert Chan <albertmcchan@...>
- Date: Wed, 31 Oct 2018 17:15:41 -0400
On Oct 31, 2018, at 3:48 PM, Sean Conner <sean@conman.org> wrote:
>
> Because the pattern, the empty string, is being matched twice by the two
> calls. If you change it to:
>
> patt = lpeg.P(lpeg.P(1) * fct)
>
> it will work.
With this patt, the check for empty string in fct is not needed
Since P(fct) does not capture anything, argument capture is not needed.
patt is just a 1 liner:
patt = 1 * P(function(s, i) return i, s:sub(i-1, i-1) end)