Use luau builtins

This commit is contained in:
Someone-dQw4w9WgXcQ 2023-07-27 13:26:58 +01:00
parent f80229c517
commit 1d9bac79fe

View file

@ -27,27 +27,24 @@
// long list of standard functions from lua manual // long list of standard functions from lua manual
var builtins = wordRE([ var builtins = wordRE([
"_G","_VERSION","assert","error","getfenv","getmetatable","ipairs","load", "loadstring","next","pairs","pcall", "_G","_VERSION","assert","error","getfenv","getmetatable","ipairs","load", "loadstring","next","pairs","pcall",
"print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type", "print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type","typeof",
"unpack","xpcall", "unpack","xpcall",
"coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield", "coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield",
"debug.debug","debug.getfenv","debug.gethook","debug.getinfo","debug.getlocal","debug.getmetatable", "debug.info","debug.traceback",
"debug.getregistry","debug.getupvalue","debug.setfenv","debug.sethook","debug.setlocal","debug.setmetatable",
"debug.setupvalue","debug.traceback",
"math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg", "math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg",
"math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max", "math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max",
"math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh", "math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh",
"math.sqrt","math.tan","math.tanh", "math.sqrt","math.tan","math.tanh",
"os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale", "os.clock","os.date","os.difftime","os.time",
"os.time","os.tmpname",
"string.byte","string.char","string.dump","string.find","string.format","string.gmatch","string.gsub", "string.byte","string.char","string.find","string.format","string.gmatch","string.gsub",
"string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper", "string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper",
"table.concat","table.insert","table.maxn","table.remove","table.sort" "table.concat","table.clone","table.create","table.freeze","table.isfrozen","table.insert","table.maxn","table.move","table.remove","table.sort","table.unpack"
]); ]);
var keywords = wordRE(["and","break","elseif","false","nil","not","or","return", var keywords = wordRE(["and","break","elseif","false","nil","not","or","return",
"true","function", "end", "if", "then", "else", "do", "true","function", "end", "if", "then", "else", "do",
@ -72,7 +69,7 @@
stream.skipToEnd(); stream.skipToEnd();
return "comment"; return "comment";
} }
if (ch == "\"" || ch == "'") if (ch == "\"" || ch == "'" || ch == "`")
return (state.cur = string(ch))(stream, state); return (state.cur = string(ch))(stream, state);
if (ch == "[" && /[\[=]/.test(stream.peek())) if (ch == "[" && /[\[=]/.test(stream.peek()))
return (state.cur = bracketed(readBracket(stream), "string"))(stream, state); return (state.cur = bracketed(readBracket(stream), "string"))(stream, state);