Fixes formatting.

This commit is contained in:
gamemanj
2015-11-14 11:59:19 +00:00
parent 853dcc50d5
commit 83d4264d8a

View File

@ -360,7 +360,7 @@ local function lexLua(code)
return str:match("^[%w_]+")
end
function lexElements.whitespace(str)
return str:match("^%s+")
return str:match("^[\r \t]+")
end
--Unimplemented stuff goes here.
function lexElements.cleanup(str)
@ -394,7 +394,12 @@ local function lexLua(code)
function lexElements.linecomment(str)
return str:match("^%-%-[^\r\n]+")
end
local lexElementsOrder={"keyword","whitespace","string","blockcomment","linecomment","cleanup"}
-- Note: EOL is not reliable for linecounting purposes, but keeps the code better formatted, if anything
function lexElements.eol()
return str:match("^[\n]+")
end
local lexElementsOrder = {"keyword", "eol", "whitespace",
"string", "blockcomment", "linecomment", "cleanup"}
local lexResults = {}
while code:len() > 0 do
--Because break doesn't exist.
@ -438,8 +443,9 @@ local function code_prohibited(code)
return nil, "Couldn't lex code:"..err
end
for _, v in ipairs(lexed) do
--remove useless stuff since we're going over it anyway.
if v[1]=="whitespace" then v[2]="\r\n" end
--remove/reduce useless stuff since we're going over it anyway.
if v[1] == "whitespace" then v[2] = " " end
if v[1] == "eol" then v[2] = "\r\n" end -- Windows users may like the \r
if v[1] == "blockcomment" then v[2] = "" end
if v[1] == "linecomment" then v[2] = "" end
--Code injection so we can safely use every feature in Lua. The only purpose of the lexer is to filter stuff that would break this, really.