Commit 5a0e28c3 authored by François Perrad's avatar François Perrad

refactor compile

parent fbaaedc5
Pipeline #177155 passed with stages
in 22 seconds
......@@ -81,21 +81,19 @@ local function compile (patt)
local j = i
while i <= #s do
c = sub(s, i, i)
if not smatch(c, '[%d%a_]') then
if c == ',' then
op[#op+1] = uniq(sub(s, j, i - 1))
j = i + 1
elseif c == '%' then
c = sub(s, i+1, i+2)
if not smatch(c, '%x%x') then
error("invalid triplet found at position " .. tostring(start + i), 3)
end
i = i + 2
elseif c == ':' or c == '*' then
error("modifier (level 4) found at position " .. tostring(start + i), 3)
else
error("invalid character found at position " .. tostring(start + i), 3)
if c == ',' then
op[#op+1] = uniq(sub(s, j, i - 1))
j = i + 1
elseif c == '%' then
c = sub(s, i+1, i+2)
if not smatch(c, '%x%x') then
error("invalid triplet found at position " .. tostring(start + i), 3)
end
i = i + 2
elseif c == ':' or c == '*' then
error("modifier (level 4) found at position " .. tostring(start + i), 3)
elseif not smatch(c, '[%d%a_]') then
error("invalid character found at position " .. tostring(start + i), 3)
end
i = i + 1
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment