lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> 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