Fix issues with newline handling in long strings

This commit is contained in:
SoniEx2 2019-04-08 14:54:07 -03:00
parent 772e7a9755
commit 893ca6ca0d
2 changed files with 8 additions and 3 deletions

View File

@ -386,7 +386,8 @@ end
do local tlongstring = {}
defs.longstring = tlongstring
do local tllongstring_proper = selfify({[""] = "self", ["]"] = function(state, token) state.longstring_close = 0 return "maybe_end" end})
tllongstring_proper[1] = collect_fallback
tllongstring_proper[1] = false -- placeholder for newline handling
tllongstring_proper[2] = collect_fallback
do local tllmaybe_end = selfify({defs = defs}, "maybe_end")
tllongstring_proper.maybe_end = tllmaybe_end

View File

@ -260,7 +260,7 @@ end -- long string
do -- long string edge cases
local luatokens = require "luatokens"
local tokens = luatokens.defs
local state, err, etoken, estate = parser.parse(tokens, "[==[]=]==][==[]]==][=[] ]=]")
local state, err, etoken, estate = parser.parse(tokens, "[==[]=]==][==[]]==][=[] ]=][[\n]][[\n ]]")
local case = case()
if not state then
print(case, "---- IN TOKENS ----")
@ -276,8 +276,12 @@ do -- long string edge cases
assert(table.remove(state, 1) == "]")
assert(table.remove(state, 1) == luatokens.tokens.TK_STRING)
assert(table.remove(state, 1) == "] ")
assert(table.remove(state, 1) == luatokens.tokens.TK_STRING)
assert(table.remove(state, 1) == "")
assert(table.remove(state, 1) == luatokens.tokens.TK_STRING)
assert(table.remove(state, 1) == " ")
assert(table.remove(state, 1) == nil)
assert(state.line == 1 or not state.line)
assert(state.line == 3 or not state.line)
end
end -- long string