lua-users home
lua-l archive

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


2015-05-17 12:36 GMT+02:00 Daurnimator <quae@daurnimator.com>:
> Today I was working on an lpeg pattern, and ran into this oddity,
> which I believe to be a bug.
> I've condensed it down as far as I could, if I remove any more the bug
> seems to disappear.
>
> The following script throws in the assert.
> If you uncomment either of the alternate `path_abempty` definitions, it works.
>
>
>
> local lpeg = require "lpeg"
> local P = lpeg.P
> local HEXDIG = lpeg.R("09","af", "AF")
> local pct_encoded = P"%" * lpeg.C ( HEXDIG * HEXDIG ) / function (hex_num)
> return string.char(tonumber(hex_num, 16))
> end
> local pchar         = lpeg.R("az","AZ") + pct_encoded
> local path_abempty  = ( P"/" * pchar^0 )^0
> -- local path_abempty  = ( P"/" * pchar^0 )^0 * ( P"/" * pchar^0 )^0
> -- local path_abempty  = ( P"/" * pchar^0 )^0 * function() return true end
> local path_rootless = pchar^1 * path_abempty
> local path_absolute = P"/" * path_rootless^-1
>
> assert(lpeg.Cs ( path_absolute ):match "/var/log/messages" ==
> "/var/log/messages")
>

Not having succeeded in building the current lpeg rock, I tried your
code using texlua, which runs Lua 5.2 with lpeg 0.10 preloaded in
its binary. No error.