Closed mdecourse closed 6 years ago
利用 https://www.msys2.org/ 編譯從 https://www.lua.org/download.html 下載的原始碼
mingw32-make mingw
就可以編譯取得 lua.exe, luac.exe 與 liblua.a, 接下來利用 SciTE 的 lua.properties 設定, 可以解譯 .lua 程式:
lua.properties 檔案:
# Define SciTE settings for Lua files. # Lua 5.x highlighting is enabled by default. For other choices, # including Lua 4 highlighting, see below. file.patterns.lua=*.lua *source.patterns.lua=$(file.patterns.lua); shbang.lua=lua filter.lua=Lua (lua)|$(file.patterns.lua)| *filter.lua=$(filter.lua) lexer.$(file.patterns.lua)=lua *language.lua=Lu&a|lua|| word.chars.lua=$(chars.alpha)$(chars.numeric)$(chars.accented)_% word.characters.$(file.patterns.lua)=$(word.chars.lua) #### Lua 4.0.1 # Keywords keywordclass.lua4=\ and break do else elseif \ end for function if in \ local nil not or repeat \ return then until while # Basic Functions keywordclass2.lua4=\ _ALERT assert call collectgarbage copytagmethods \ dofile dostring error foreach foreachi \ gcinfo getglobal getn gettagmethod globals \ newtag next print rawget rawset \ setglobal settag settagmethod sort tag \ tonumber tostring tinsert tremove type \ _VERSION _ERRORMESSAGE # String Manipulation & Mathematical Functions keywordclass3.lua4=\ strbyte strchar strfind strlen strlower \ strrep strsub strupper format gsub \ abs acos asin atan atan2 \ ceil cos deg exp floor \ log log10 max min mod \ rad sin sqrt tan frexp \ ldexp random randomseed PI # Input and Output Facilities & System Facilities keywordclass4.lua4=\ openfile closefile readfrom writeto appendto \ remove rename flush seek tmpname read write \ clock date execute exit getenv setlocale \ _INPUT _OUTPUT _STDIN _STDOUT _STDERR -- file descriptors # Debug (not enabled by default) keywordclass5.lua4=\ getinfo getlocal setlocal setcallhook setlinehook #### Lua 5.0.3 # Keywords keywordclass.lua50=$(keywordclass.lua4) false true # Basic Functions keywordclass2.lua5=\ assert collectgarbage dofile error _G \ getmetatable ipairs loadfile next pairs \ pcall print rawequal rawget rawset \ setmetatable tonumber tostring type _VERSION \ xpcall string table math coroutine io os debug keywordclass2.lua50=$(keywordclass2.lua5) \ getfenv gcinfo loadlib loadstring require \ setfenv unpack _LOADED LUA_PATH _REQUIREDNAME # String, Table , Mathematical, Bitwise keywordclass3.lua5=\ string.byte string.char string.dump string.find string.format \ string.gsub string.len string.lower string.rep string.sub string.upper \ table.concat table.insert table.remove table.sort \ math.abs math.acos math.asin math.atan math.atan2 \ math.ceil math.cos math.deg math.exp math.floor \ math.frexp math.ldexp math.log math.max math.min \ math.pi math.pow math.rad math.random math.randomseed \ math.sin math.sqrt math.tan keywordclass3.lua50=$(keywordclass3.lua5) \ string.gfind \ table.foreach table.foreachi table.getn table.setn \ math.mod math.log10 # Coroutine, Input/Output, System, Package keywordclass4.lua50=\ coroutine.create coroutine.resume coroutine.status coroutine.wrap coroutine.yield \ io.close io.flush io.input io.lines io.open \ io.output io.read io.tmpfile io.type io.write \ io.stdin io.stdout io.stderr \ os.clock os.date os.difftime os.execute os.exit \ os.getenv os.remove os.rename os.setlocale os.time \ os.tmpname # Debug (not enabled by default) keywordclass5.lua50=\ debug.debug debug.gethook debug.getinfo debug.getlocal debug.getupvalue \ debug.setlocal debug.setupvalue debug.sethook debug.traceback #### Lua 5.1.4 # Keywords keywordclass.lua51=$(keywordclass.lua50) # Basic Functions keywordclass2.lua51=$(keywordclass2.lua5) \ getfenv load loadstring select \ setfenv unpack package # String, Table , Mathematical, Bitwise keywordclass3.lua51=$(keywordclass3.lua5) \ string.gmatch string.match string.reverse \ table.maxn \ math.cosh math.fmod math.huge math.log10 math.modf \ math.sinh math.tanh # Coroutine, Input/Output, System, Package keywordclass4.package=\ require package.cpath package.loaded \ package.loadlib package.path package.preload keywordclass4.lua51=$(keywordclass4.lua50) \ coroutine.running io.popen \ module package.loaders package.seeall \ $(keywordclass4.package) # Debug (not enabled by default) keywordclass5.lua51=$(keywordclass5.lua50) \ debug.getfenv debug.getmetatable debug.getregistry debug.setfenv debug.setmetatable #### Lua 5.2.0 # Keywords keywordclass.lua52=$(keywordclass.lua50) goto # Basic Functions keywordclass2.lua52=$(keywordclass2.lua5) \ load rawlen select package bit32 _ENV # String, Table , Mathematical, Bitwise keywordclass3.bit32=\ bit32.arshift bit32.band bit32.bnot bit32.bor bit32.btest \ bit32.bxor bit32.extract bit32.replace bit32.lrotate bit32.lshift \ bit32.rrotate bit32.rshift keywordclass3.lua52=$(keywordclass3.lua5) \ string.gmatch string.match string.reverse \ table.pack table.unpack \ math.cosh math.fmod math.huge math.modf math.sinh math.tanh \ $(keywordclass3.bit32) # Coroutine, Input/Output, System, Package keywordclass4.lua52=$(keywordclass4.lua50) \ coroutine.running io.popen \ package.config package.searchers package.searchpath \ $(keywordclass4.package) # Debug (not enabled by default) keywordclass5.lua52=$(keywordclass5.lua50) \ debug.getmetatable debug.getregistry debug.setmetatable \ debug.getuservalue debug.setuservalue debug.upvalueid debug.upvaluejoin #### Lua 5.3.0 # Keywords keywordclass.lua53=$(keywordclass.lua50) goto # Basic Functions keywordclass2.lua53=$(keywordclass2.lua5) \ load rawlen select package utf8 _ENV # String, UTF8, Table , Mathematical keywordclass3.utf8=\ utf8.char utf8.charpattern utf8.codes \ utf8.codepoint utf8.len utf8.offset keywordclass3.lua53=\ string.byte string.char string.dump string.find string.format \ string.gmatch string.gsub string.len string.lower string.match \ string.pack string.packsize string.rep \ string.reverse string.sub string.unpack string.upper \ table.concat table.insert table.move table.pack \ table.remove table.sort table.unpack \ math.abs math.acos math.asin math.atan \ math.ceil math.cos math.deg math.exp \ math.floor math.fmod math.huge \ math.log math.max math.maxinteger math.min math.mininteger \ math.modf math.pi math.rad \ math.random math.randomseed math.sin \ math.sqrt math.tan \ math.tointeger math.type math.ult \ $(keywordclass3.utf8) # Coroutine, Input/Output, System, Package keywordclass4.lua53=$(keywordclass4.lua50) \ coroutine.isyieldable coroutine.running io.popen \ package.config package.searchers package.searchpath \ $(keywordclass4.package) # Debug (not enabled by default) keywordclass5.lua53=$(keywordclass5.lua52) #### Lua 5.x # Keywords keywordclass.lua5x=$(keywordclass.lua53) # Basic Functions keywordclass2.lua5x=$(keywordclass2.lua5) \ getfenv gcinfo load loadlib loadstring \ require select setfenv unpack \ _LOADED LUA_PATH _REQUIREDNAME \ package rawlen package bit32 utf8 _ENV # String, Table , Mathematical, Bitwise keywordclass3.lua5x=$(keywordclass3.lua5) \ string.gfind string.gmatch string.match string.reverse \ string.pack string.packsize string.unpack \ table.foreach table.foreachi table.getn table.setn \ table.maxn table.pack table.unpack table.move \ math.cosh math.fmod math.huge math.log10 math.modf \ math.mod math.sinh math.tanh math.maxinteger math.mininteger \ math.tointeger math.type math.ult \ $(keywordclass3.bit32) \ $(keywordclass3.utf8) # Coroutine, Input/Output, System, Package keywordclass4.lua5x=$(keywordclass4.lua50) \ coroutine.isyieldable coroutine.running io.popen \ module package.loaders package.seeall \ package.config package.searchers package.searchpath \ $(keywordclass4.package) # Debug (not enabled by default) keywordclass5.lua5x=$(keywordclass5.lua50) \ debug.getfenv debug.getmetatable debug.getregistry debug.setfenv debug.setmetatable \ debug.getuservalue debug.setuservalue debug.upvalueid debug.upvaluejoin # Keyword highlighting selection # Options: lua4, lua50, lua51, lua52, lua53, lua5x (default) # or enable everything like this: $(keywordclass.lua4)$(keywordclass.lua5x) keywords.$(file.patterns.lua)=$(keywordclass.lua5x) keywords2.$(file.patterns.lua)=$(keywordclass2.lua5x) keywords3.$(file.patterns.lua)=$(keywordclass3.lua5x) keywords4.$(file.patterns.lua)=$(keywordclass4.lua5x) # Add keywords5, 6, 7 & 8 for user-defined libraries #keywords5.$(file.patterns.lua)= #keywords6.$(file.patterns.lua)= #keywords7.$(file.patterns.lua)= #keywords8.$(file.patterns.lua)= #~ statement.indent.$(file.patterns.lua)=5 do else function then #~ statement.lookback.$(file.patterns.lua)=20 indent.maintain.$(file.patterns.lua)=1 comment.block.lua=--~ comment.block.at.line.start.lua=1 # Lua styles #Default style.lua.32=$(font.code.base),fore:#000000 # White space: Visible only in View Whitespace mode (or if it has a back colour) style.lua.0=fore:#FF0000 # Block comment (Lua 5.0) style.lua.1=$(colour.code.comment.box),$(font.code.comment.box),back:#D0F0F0,eolfilled # Line comment style.lua.2=$(colour.code.comment.line),$(font.code.comment.line) # Doc comment -- Not used in Lua (yet?) style.lua.3=$(colour.notused),$(font.notused) # Number style.lua.4=$(colour.number) # Keyword style.lua.5=$(colour.keyword) # (Double quoted) String style.lua.6=$(colour.string) # Character (Single quoted string) style.lua.7=$(colour.char) # Literal string style.lua.8=$(colour.string),$(font.code.comment.box),back:#E0FFFF # Preprocessor (obsolete in Lua 4.0 and up) style.lua.9=$(colour.preproc) # Operators style.lua.10=$(colour.operator) # Identifier (everything else...) style.lua.11= # End of line where string is not closed style.lua.12=back:#E0C0E0,eolfilled # Other keywords (bozo test colors, but toned down ;) style.lua.13=$(style.lua.5),back:#F5FFF5 style.lua.14=$(style.lua.5),back:#F5F5FF style.lua.15=$(style.lua.5),back:#FFF5F5 style.lua.16=$(style.lua.5),back:#FFF5FF style.lua.17=$(style.lua.5),back:#FFFFF5 style.lua.18=$(style.lua.5),back:#FFA0A0 style.lua.19=$(style.lua.5),back:#FFF5F5 # Labels style.lua.20=fore:#7F7F00 # Braces are only matched in operator style braces.lua.style=10 # compatible with LuaBinaries for Lua 5.1; will work on both platforms. command.compile.*.lua=y:\lua-5.3.4\bin\luac.exe -o "$(FileName).luc" "$(FileNameExt)" # Lua 5.1 command.go.*.lua=y:\lua-5.3.4\bin\lua.exe "$(FileNameExt)" # Lua 4.0 #command.go.*.lua=Lua-4.0.exe -c -f "$(FileNameExt)"
https://github.com/SCons/scons
從 https://github.com/fengari-lua/fengari-web 取得 fengari-web.js, 利用 https://ace.c9.io/ 當作編輯器, 可以組合成 https://github.com/davchoo/SchoolProject, 加以修改除錯後成為 http://mde.tw/vecp2018/lua/SchoolProject/
編譯 Lua
利用 https://www.msys2.org/ 編譯從 https://www.lua.org/download.html 下載的原始碼
就可以編譯取得 lua.exe, luac.exe 與 liblua.a, 接下來利用 SciTE 的 lua.properties 設定, 可以解譯 .lua 程式:
lua.properties 檔案:
需要 Build 時
https://github.com/SCons/scons
全球資訊網 Lua 解譯器
從 https://github.com/fengari-lua/fengari-web 取得 fengari-web.js, 利用 https://ace.c9.io/ 當作編輯器, 可以組合成 https://github.com/davchoo/SchoolProject, 加以修改除錯後成為 http://mde.tw/vecp2018/lua/SchoolProject/