lua-users home
lua-l archive

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


I started with the example in the LPeg manual for CSV parsing and tried adding support to have it parse an entire buffer of multiple CSV lines:

local field = '"' * lpeg.Cs(((lpeg.P(1) - '"') + lpeg.P'""' / '"')^0) * '"' +
                   lpeg.C((1 - lpeg.S',\r\n"')^0)

local record = lpeg.Ct(field * (',' * field)^0) * (lpeg.P'\r\n' + lpeg.P'\n' + -1)
local all = lpeg.Ct(record^0)

This fails, of course, with a "loop body may accept empty string" error.

What is the proper solution for making that error go away?

Thanks.

Josh