local tBlacklist = {
["{"] = true,
["}"] = true,
}
local function stripwords(str, words)
local w = {};
return str:gsub("([^%s.,!?]+)%s*", function(word)
if words[word] then return "" end
w[#w+1] = word
end), w;
end
function replacetext(source, find, replace, wholeword)
if wholeword then
find = '%f[%a]'..find..'%f[%A]'
end
return (source:gsub(find,replace))
end
function parse( _S )
if fs.exists( _S ) then
_F = fs.open( _S, "r" )
local _CONTENTS = _F.readAll()
_TMP = fs.open( "tmp.LPT", "w" )
local _returnedFile = stripwords( _CONTENTS, tBlacklist )
local s = _returnedFile
_returnedFile = replacetext( s, "super", "printError", true )
_returnedFile = replacetext( s, "constructor", "--[[ Constructor not used... Sorry! ]]--", true )
_returnedFile = replacetext( s, "void", "function", true )
_returnedFile = replacetext( s, "class", "--[[ LuaPlus Class ]]--", true )
_TMP.write( returnedFile )
_TMP.close()
_F.close()
--shell.run( "tmp.LPT" )
print( _returnedFile )
fs.delete( "tmp.LPT" )
end
end
function openEditor( _FILEFOREDIT )
shell.run( "/.luaplus/Editor.lua " .. _FILEFOREDIT)
end
-- , "{" = true, "}" = true,
I don't get why line 16 errors. Can someone help? EDIT: Copy-Paste didn't copy linebreaks.