Skip to content
Permalink
Browse files
fix grammar so that it works with lpeg 0.12
fix proposed by Roberto Ierusalimschy on lua-l
  • Loading branch information
catwell committed Sep 19, 2013
1 parent 9a1a6d1 commit 65f9aaf
Showing 1 changed file with 4 additions and 6 deletions.
@@ -37,12 +37,10 @@ local longstring1 = lpeg.P{
longstring = lpeg.P"[[" * (lpeg.V"longstring" + (lpeg.P(1) - lpeg.P"]]"))^0 * lpeg.P"]]"
}

local longstring2 = lpeg.P(function (s, i)
local l = lpeg.match(start, s, i)
if not l then return nil end
local p = lpeg.P("]" .. string.rep("=", l - i - 2) .. "]")
p = (1 - p)^0 * p
return lpeg.match(p, s, l)
local longstring2 = lpeg.Cmt(start, function (s, i, start)
local p = string.gsub(start, "%[", "]")
local _, e = string.find(s, p, i)
return (e and e + 1)
end)

local longstring = #("[" * lpeg.S"[=") * (longstring1 + longstring2)

0 comments on commit 65f9aaf

Please sign in to comment.