Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function preprocess_string(script)
- local pos
- local literal
- local temp_string
- local i = 1
- local strings = {}
- for char in script:gmatch("(.)") do
- -- literal string start
- if char == "[" and not literal then
- local spos, epos, matched = script:find("(%[?=-%[)", i)
- if matched then
- literal = matched
- pos = spos
- end
- end
- -- literal string end
- if char == "]" and literal then
- local spos, epos, matched = script:find("(%]?=-%])", i)
- if matched and #literal == #matched then
- literal = nil
- strings[pos-1] = epos+1
- pos = nil
- end
- end
- if not literal and (char == [["]] or char == [[']]) then
- -- double or single quote start
- if not pos then
- pos = i
- else -- double or single quote end
- strings[pos-1] = i+1
- pos = nil
- end
- end
- i = i + 1
- end
- for start, stop in pairs(strings) do
- script = script .. script:sub(0, start) .. "(__STRINGCTOR(" .. script:sub(start, stop) .. "))" .. script:sub(stop)
- end
- return script
- end
- local function preprocess(script, config)
- if config.string_constructor then
- script = preprocess_string(script)
- end
- return script
- end
- local function compile(script, config)
- script = preprocess(script, config)
- epoe.Print(script)
- end
- local script = [===[
- local lol = ""
- lOL[["""]]
- asdassd[==[[LOL]]==]
- abc("asdasd", "LOL", "laasdasd")
- wayo'le-le-le-le-let me hear you say wayo'
- comeon[====[boom bom boom now let me hear you say "wayo ('wayo [[i say boom bom bom now let me hear you say wayo 'wayo']] ')"]====]
- ]===]
- compile(script, {string_constructor = function() end})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement