Closed khonkhortisan closed 9 years ago
-- remove -- comments
for _, l in ipairs(string.split(nc, "\n")) do
for i = 1, #l do
local c = l:sub(i, i+1)
if c == "--" then
cleancode = cleancode..l:sub(1, i-1)
break
elseif i == #l then
cleancode = cleancode..l
end
end
end
That would be some code for -- comments. That is quite hacky, so anyone familiar with regexes for single-line and multi-line comments that work with lua's implementation in gsub?
cleancode = nc:gsub("--[^\r\n]*", "")
This might work, but like your example, it doesn't take into account whether the -- is inside a string, like in this snippet:
x = "--this is not really a comment"
As there are no prohibited commands anymore due to the instruction counter patch by @ShadowNinja, (#172) there is no need for this anymore. Closing this pull therefore.
Both of these give
Prohibited command: for
Apparently you can't redefine keywords. It'll have to be a smart search.