Fix Lua 5.1/Lua 5.2/LuaJIT compat
This commit is contained in:
parent
282dbabb7e
commit
fd48534de3
12
parser.lua
12
parser.lua
|
@ -71,9 +71,15 @@ local function get_next_common(state, in_pos, token)
|
||||||
recheck = true
|
recheck = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i, hook in ipairs(st) do
|
do -- post-hooks CANNOT USE ipairs HERE BECAUSE Lua 5.1/5.2
|
||||||
if hook then -- allow overriding/disabling hooks
|
local pos = 1
|
||||||
hook(state, token, rule)
|
local hook = st[pos]
|
||||||
|
while hook ~= nil do
|
||||||
|
if hook then
|
||||||
|
hook(state, token, rule)
|
||||||
|
end
|
||||||
|
pos = pos + 1
|
||||||
|
hook = st[pos]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
state[STATE] = transition -- may be nil or false
|
state[STATE] = transition -- may be nil or false
|
||||||
|
|
2
test.lua
2
test.lua
|
@ -315,7 +315,7 @@ end -- keywords
|
||||||
|
|
||||||
do -- FUCK
|
do -- FUCK
|
||||||
local luatokens = require "luatokens"
|
local luatokens = require "luatokens"
|
||||||
local luatokens_file = io.open("./luatokens.lua", "r"):read((_VERSION == "5.1" or _VERSION == "5.2") and "*a" or "a")
|
local luatokens_file = io.open("./luatokens.lua", "r"):read((_VERSION == "Lua 5.1" or _VERSION == "Lua 5.2") and "*a" or "a")
|
||||||
local tokens = luatokens.defs
|
local tokens = luatokens.defs
|
||||||
local state, err, etoken, estate = parser.parse(tokens, luatokens_file)
|
local state, err, etoken, estate = parser.parse(tokens, luatokens_file)
|
||||||
local case = case()
|
local case = case()
|
||||||
|
|
Loading…
Reference in New Issue