mirror of
https://github.com/XeonSquared/OC-Copper.git
synced 2024-11-14 22:08:05 +11:00
b26a48165d
The light node system should only be used where necessary, as light nodes contribute absolutely nothing to network messaging. Maybe a minified full port of culib could be made for a "medium node", which would be (protocol behavior-wise) exactly like normal nodes, but minified and with interfaces cut down internally.
38 lines
851 B
Lua
38 lines
851 B
Lua
-- Postprocessor
|
|
local lastchar = " "
|
|
local text = io.read("*a")
|
|
|
|
text = "\n" .. text
|
|
|
|
-- the most important step: everything assumes \n
|
|
text = text:gsub("\r", "")
|
|
|
|
-- tabs are always useless.
|
|
-- get rid of them *before* removing comments so indented comments also get scrubbed.
|
|
text = text:gsub("\t", "")
|
|
|
|
text = text:gsub("\n%-%-[^\n]+", "")
|
|
|
|
-- This is run after comment removal so that comments can be re-added.
|
|
text = text:gsub("\n%%[^\n]+", function(s)
|
|
return "\n" .. s:sub(3)
|
|
end)
|
|
local otext = text
|
|
local function pass()
|
|
text = text:gsub(".\n+.", function(i)
|
|
local l = i:sub(1, 1) .. i:sub(#i)
|
|
if not l:match("[^%(%)%{%}].") then
|
|
return l
|
|
end
|
|
return i:sub(1, 1) .. "\n" .. i:sub(#i)
|
|
end)
|
|
end
|
|
pass()
|
|
while otext ~= text do
|
|
otext = text
|
|
pass()
|
|
end
|
|
-- Final processing
|
|
text = text:gsub("^\n+", ""):gsub("\n+$", "")
|
|
io.write(text)
|