mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-07-01 15:20:23 +02:00
Fixes formatting.
This commit is contained in:
@ -360,7 +360,7 @@ local function lexLua(code)
|
|||||||
return str:match("^[%w_]+")
|
return str:match("^[%w_]+")
|
||||||
end
|
end
|
||||||
function lexElements.whitespace(str)
|
function lexElements.whitespace(str)
|
||||||
return str:match("^%s+")
|
return str:match("^[\r \t]+")
|
||||||
end
|
end
|
||||||
--Unimplemented stuff goes here.
|
--Unimplemented stuff goes here.
|
||||||
function lexElements.cleanup(str)
|
function lexElements.cleanup(str)
|
||||||
@ -394,7 +394,12 @@ local function lexLua(code)
|
|||||||
function lexElements.linecomment(str)
|
function lexElements.linecomment(str)
|
||||||
return str:match("^%-%-[^\r\n]+")
|
return str:match("^%-%-[^\r\n]+")
|
||||||
end
|
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 = {}
|
local lexResults = {}
|
||||||
while code:len() > 0 do
|
while code:len() > 0 do
|
||||||
--Because break doesn't exist.
|
--Because break doesn't exist.
|
||||||
@ -438,8 +443,9 @@ local function code_prohibited(code)
|
|||||||
return nil, "Couldn't lex code:"..err
|
return nil, "Couldn't lex code:"..err
|
||||||
end
|
end
|
||||||
for _, v in ipairs(lexed) do
|
for _, v in ipairs(lexed) do
|
||||||
--remove useless stuff since we're going over it anyway.
|
--remove/reduce useless stuff since we're going over it anyway.
|
||||||
if v[1]=="whitespace" then v[2]="\r\n" end
|
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] == "blockcomment" then v[2] = "" end
|
||||||
if v[1] == "linecomment" 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.
|
--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.
|
||||||
|
Reference in New Issue
Block a user