[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LPeg debug help
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 9 Dec 2022 12:48:33 -0300
> Then I tried to improve it a bit (noticed return false in "failed"):
>
> [...]
> local failed = lpeg.Cmt(lpeg.P(true), function(s, p)
> local lineno, colno = lpegrex.calcline(s, p)
> io.stderr:write(string.format('FAILED %s (%d:%d)\n', k, lineno,
> colno))
> return false
> end)
>
> Has anyone any idea of a workaround ?
LPeg does not know that 'failed' cannot succeed, but you can try to
include that information:
-- UNTESTED, but it probably will work
local failed = lpeg.P(function(s, p) <as before> end) * false
-- Roberto