mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-16 01:11:28 +00:00
LunaCON: properly generate references to gamevars named like Lua keywords.
git-svn-id: https://svn.eduke32.com/eduke32@3855 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
7725544ef1
commit
ddb0d3f63d
1 changed files with 17 additions and 1 deletions
|
@ -431,10 +431,26 @@ end
|
|||
local BAD_ID_CHARS0 = "_/\\*?" -- allowed 1st identifier chars
|
||||
local BAD_ID_CHARS1 = "_/\\*-+?" -- allowed following identifier chars
|
||||
|
||||
local function truetab(tab)
|
||||
local ttab = {}
|
||||
for i=1,#tab do
|
||||
ttab[tab[i]] = true
|
||||
end
|
||||
return ttab
|
||||
end
|
||||
|
||||
-- Lua 5.2 keywords. Not 5.1 because we use "goto" for codegen.
|
||||
local LUA_KEYW = truetab {
|
||||
"and", "break", "do", "else", "elseif", "end",
|
||||
"false", "for", "function", "goto", "if", "in",
|
||||
"local", "nil", "not", "or", "repeat", "return",
|
||||
"then", "true", "until", "while"
|
||||
}
|
||||
|
||||
-- Return the Lua code by which the CON object <name> is referenced in the
|
||||
-- translated code.
|
||||
local function mangle_name(name, prefix)
|
||||
if (name:match("^[A-Za-z_][A-Za-z_0-9]*$")) then
|
||||
if (name:match("^[A-Za-z_][A-Za-z_0-9]*$") and not LUA_KEYW[name]) then
|
||||
return format("_%s.%s", prefix, name)
|
||||
else
|
||||
return format("_%s[%q]", prefix, name)
|
||||
|
|
Loading…
Reference in a new issue