Advertisement
CapsAdmin

Untitled

May 24th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.66 KB | None | 0 0
  1. local function preprocess_string(script)
  2.        
  3.     local pos
  4.     local literal
  5.     local temp_string
  6.    
  7.     local i = 1
  8.     local strings = {} 
  9.    
  10.     for char in script:gmatch("(.)") do
  11.            
  12.         -- literal string start
  13.         if char == "[" and not literal then
  14.             local spos, epos, matched = script:find("(%[?=-%[)", i)
  15.             if matched then
  16.                 literal = matched
  17.                 pos = spos
  18.             end
  19.         end
  20.        
  21.         -- literal string end
  22.         if char == "]" and literal then
  23.             local spos, epos, matched = script:find("(%]?=-%])", i)
  24.             if matched and #literal == #matched then
  25.                 literal = nil
  26.                
  27.                 strings[pos-1] = epos+1
  28.                 pos = nil
  29.             end
  30.         end
  31.        
  32.         if not literal and (char == [["]] or char == [[']]) then
  33.        
  34.             -- double or single quote start
  35.             if not pos then
  36.                 pos = i
  37.             else -- double or single quote end
  38.                 strings[pos-1] = i+1
  39.                 pos = nil
  40.             end
  41.         end
  42.            
  43.         i = i + 1
  44.     end
  45.        
  46.     for start, stop in pairs(strings) do
  47.         script = script .. script:sub(0, start) .. "(__STRINGCTOR(" .. script:sub(start, stop) .. "))" .. script:sub(stop)
  48.     end
  49.    
  50.     return script
  51. end
  52.  
  53. local function preprocess(script, config)
  54.     if config.string_constructor then
  55.         script = preprocess_string(script)
  56.     end
  57.    
  58.     return script
  59. end
  60.  
  61. local function compile(script, config)
  62.     script = preprocess(script, config)
  63.     epoe.Print(script)
  64. end
  65.  
  66. local script = [===[
  67.  
  68. local lol = ""
  69.  
  70. lOL[["""]]
  71.  
  72. asdassd[==[[LOL]]==]
  73.  
  74. abc("asdasd", "LOL", "laasdasd")
  75.  
  76. wayo'le-le-le-le-let me hear you say wayo'
  77. 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']] ')"]====]
  78.  
  79. ]===]
  80.  
  81. compile(script, {string_constructor = function() end})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement