lua-users home
lua-l archive

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

LPeg crashes with the following code in Lua 5.2:

local lpeg = require "lpeg"

local P = lpeg.P
local R = lpeg.R
local op_multiply = P "*" + "\195\151" + "\194\183"
local op_divide = P "/" + "\226\136\149"
local result = R"09" * ( op_multiply + op_divide ) * R"09"

result:match( "6/2" )

What I'm trying to do is encode UTF-8 characters as possible matches using this syntax.
Yes, this is probably a terrible abuse of Unicode and WRONG and etc, but the point is that LPeg crashes. I'd expect it to simply not match if I'm doing encodings wrong. On the other hand, maybe the problem has nothing to do with the raw byte encodings.