Commit 8843c965 authored by Jamie A. Jennings's avatar Jamie A. Jennings

FIXED bug in insert_seq

parent 256eeb34
Pipeline #63564882 passed with stage
in 1 minute and 36 seconds
......@@ -104,19 +104,30 @@ end
local function insert_seq_operators(exps)
if exps==nil then return nil end
local result = {}
for i, item in ipairs(exps) do
table.insert(result, item)
local succ = exps[i+1]
if item.type=="operator" or is_atmosphere(item) then
-- no op
elseif succ and (succ.type~="operator" and not is_atmosphere(succ)) then
table.insert(result,
{type = "operator",
s = item.e,
e = succ.s-1,
data = "SEQUENCE"})
local item, last_seen
local i = 1
while i <= #exps do
item = exps[i]
if is_atmosphere(item) then
-- no op, just enqueue it into the result list
elseif item.type=="operator" then
assert( last_seen )
last_seen = "OP"
-- enqueue it into the result list
else
-- rpl expression
if last_seen and (last_seen == "EXP") then
table.insert(result,
{type = "operator",
s = result[#result].e,
e = item.s - 1,
data = "SEQUENCE"})
end -- if need to insert operator
last_seen = "EXP"
end
end -- for
table.insert(result, item)
i = i + 1
end -- while
return result
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