mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-26 00:40:56 +00:00
Lunatic translator: warning options, on_state_end, more bad-identifier chars.
git-svn-id: https://svn.eduke32.com/eduke32@3255 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
99c67c0190
commit
2212e4e6f8
1 changed files with 62 additions and 7 deletions
|
@ -50,6 +50,10 @@ local g_filename = "???"
|
||||||
local g_directory = "" -- with trailing slash if not empty
|
local g_directory = "" -- with trailing slash if not empty
|
||||||
local g_numerrors = 0
|
local g_numerrors = 0
|
||||||
|
|
||||||
|
-- Warning options. Key names are the same as cmdline options, e.g.
|
||||||
|
-- -Wno-bad-identifier for disabling the "bad identifier" warning.
|
||||||
|
local g_warn = { ["not-redefined"]=true, ["bad-identifier"]=true, }
|
||||||
|
|
||||||
-- How many 'if' statements are following immediately each other,
|
-- How many 'if' statements are following immediately each other,
|
||||||
-- needed to cope with CONs dangling-else resolution
|
-- needed to cope with CONs dangling-else resolution
|
||||||
local g_ifseqlevel = 0
|
local g_ifseqlevel = 0
|
||||||
|
@ -94,6 +98,14 @@ local function on_actor_end(usertype, tsamm, codetab)
|
||||||
addcode("end)")
|
addcode("end)")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function on_state_end(statename, codetab)
|
||||||
|
-- TODO: mangle names, make them accessible from other translation units
|
||||||
|
addcodef("local function %s()", statename)
|
||||||
|
assert(type(codetab)=="table")
|
||||||
|
addcode(codetab)
|
||||||
|
addcode("end")
|
||||||
|
end
|
||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
||||||
local function linecolstr(pos)
|
local function linecolstr(pos)
|
||||||
|
@ -195,9 +207,11 @@ local function do_define_label(identifier, num)
|
||||||
LABEL[oldtype], identifier)
|
LABEL[oldtype], identifier)
|
||||||
else
|
else
|
||||||
-- conl.labels[...]: don't warn for wrong PROJ_ redefinitions
|
-- conl.labels[...]: don't warn for wrong PROJ_ redefinitions
|
||||||
if (oldval ~= num and conl.labels[2][identifier]==nil) then
|
if (g_warn["not-redefined"]) then
|
||||||
warnprintf("label \"%s\" not redefined with new value %d (old: %d)",
|
if (oldval ~= num and conl.labels[2][identifier]==nil) then
|
||||||
identifier, num, oldval)
|
warnprintf("label \"%s\" not redefined with new value %d (old: %d)",
|
||||||
|
identifier, num, oldval)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -1222,7 +1236,7 @@ end
|
||||||
|
|
||||||
local function BadIdent(pat)
|
local function BadIdent(pat)
|
||||||
local function tfunc(subj, pos, a)
|
local function tfunc(subj, pos, a)
|
||||||
if (not g_badids[a]) then
|
if (g_warn["bad-identifier"] and not g_badids[a]) then
|
||||||
warnprintf("bad identifier: %s", a)
|
warnprintf("bad identifier: %s", a)
|
||||||
g_badids[a] = true
|
g_badids[a] = true
|
||||||
end
|
end
|
||||||
|
@ -1364,7 +1378,8 @@ local Cb = {
|
||||||
|
|
||||||
onevent = sp1 * t_define * sp1 * stmt_list_or_eps * "endevent",
|
onevent = sp1 * t_define * sp1 * stmt_list_or_eps * "endevent",
|
||||||
|
|
||||||
state = sp1 * t_identifier * sp1 * stmt_list_or_eps * "ends",
|
state = sp1 * t_identifier * sp1 * stmt_list_or_eps * "ends"
|
||||||
|
/ on_state_end,
|
||||||
}
|
}
|
||||||
|
|
||||||
attachnames(Cb, after_cmd_Cmt)
|
attachnames(Cb, after_cmd_Cmt)
|
||||||
|
@ -1380,7 +1395,7 @@ local t_good_identifier = Range("AZ", "az", "__") * Range("AZ", "az", "__", "09"
|
||||||
-- in CON, so a trailing "-" is "OK", too.)
|
-- in CON, so a trailing "-" is "OK", too.)
|
||||||
-- This is broken in itself, so we ought to make a compatibility/modern CON switch.
|
-- This is broken in itself, so we ought to make a compatibility/modern CON switch.
|
||||||
local t_broken_identifier = BadIdent(-((t_number + t_good_identifier) * (sp1 + Set("[]:"))) *
|
local t_broken_identifier = BadIdent(-((t_number + t_good_identifier) * (sp1 + Set("[]:"))) *
|
||||||
(alphanum + Set("_/\\*")) * (alphanum + Set("_/\\*-"))^0)
|
(alphanum + Set("_/\\*?")) * (alphanum + Set("_/\\*-+?"))^0)
|
||||||
|
|
||||||
local function begin_if_fn(condstr)
|
local function begin_if_fn(condstr)
|
||||||
g_ifseqlevel = g_ifseqlevel+1
|
g_ifseqlevel = g_ifseqlevel+1
|
||||||
|
@ -1589,10 +1604,50 @@ function parse(contents) -- local
|
||||||
g_newlineidxs = newlineidxs
|
g_newlineidxs = newlineidxs
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function handle_cmdline_arg(str)
|
||||||
|
if (str:sub(1,1)=="-") then
|
||||||
|
if (#str == 1) then
|
||||||
|
printf("Warning: input from stdin not supported")
|
||||||
|
else
|
||||||
|
local ok = false
|
||||||
|
local kind = str:sub(2,2)
|
||||||
|
|
||||||
|
if (kind=="W" and #str >= 3) then
|
||||||
|
-- warnings
|
||||||
|
local val = true
|
||||||
|
local warnstr = str:sub(3)
|
||||||
|
|
||||||
|
if (#warnstr >= 4 and warnstr:sub(1,3)=="no-") then
|
||||||
|
val = false
|
||||||
|
warnstr = warnstr:sub(4)
|
||||||
|
end
|
||||||
|
|
||||||
|
if (type(g_warn[warnstr])=="boolean") then
|
||||||
|
g_warn[warnstr] = val
|
||||||
|
ok = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if (not ok) then
|
||||||
|
printf("Warning: Unrecognized option %s", str)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if (not _EDUKE32_LUNATIC) then
|
if (not _EDUKE32_LUNATIC) then
|
||||||
--- stand-alone
|
--- stand-alone
|
||||||
local debug = require("debug")
|
|
||||||
|
local i = 1
|
||||||
|
while (arg[i]) do
|
||||||
|
if (handle_cmdline_arg(arg[i])) then
|
||||||
|
table.remove(arg, i)
|
||||||
|
else
|
||||||
|
i = i+1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
for argi=1,#arg do
|
for argi=1,#arg do
|
||||||
local filename = arg[argi]
|
local filename = arg[argi]
|
||||||
|
|
Loading…
Reference in a new issue