mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
LunaCON: allow ':' immediately after 'case' (legacy; warns), writing to ud.god.
Also, on one "gamevar `xxx' is not per-*" diagnostic, print the location of the gamevar definition. git-svn-id: https://svn.eduke32.com/eduke32@5187 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
564e7d2332
commit
d30bb3835e
2 changed files with 18 additions and 7 deletions
|
@ -869,7 +869,7 @@ local UserdefLabels = {
|
||||||
eog = UD".eog",
|
eog = UD".eog",
|
||||||
ffire = UDRO".ffire",
|
ffire = UDRO".ffire",
|
||||||
fta_on = UD".fta_on",
|
fta_on = UD".fta_on",
|
||||||
god = UDRO".god",
|
god = UD".god",
|
||||||
idplayers = UDRO".idplayers",
|
idplayers = UDRO".idplayers",
|
||||||
last_level = UDRO".last_level",
|
last_level = UDRO".last_level",
|
||||||
level_number = { UD".level_number", UD":set_level_number(%%s)", {0, MAXLEVELS-1} },
|
level_number = { UD".level_number", UD":set_level_number(%%s)", {0, MAXLEVELS-1} },
|
||||||
|
|
|
@ -910,20 +910,24 @@ end
|
||||||
|
|
||||||
local inform = {}
|
local inform = {}
|
||||||
|
|
||||||
function inform.common(loc, iserr)
|
function inform.common(loc, iserr, prefix)
|
||||||
if (loc) then
|
if (loc) then
|
||||||
contprintf(iserr, "Old definition is at %s %d:%d", loc[1], loc[2], loc[3])
|
contprintf(iserr, prefix.." is at %s %d:%d", loc[1], loc[2], loc[3])
|
||||||
else
|
else
|
||||||
contprintf(iserr, "Old definition is built-in")
|
contprintf(iserr, prefix.." is built-in")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function inform.olddef_location(identifier, iserr)
|
function inform.olddef_location(identifier, iserr)
|
||||||
inform.common(g_labelloc[identifier], iserr)
|
inform.common(g_labelloc[identifier], iserr, "Old definition")
|
||||||
end
|
end
|
||||||
|
|
||||||
function inform.oldgv_location(identifier, iserr)
|
function inform.oldgv_location(identifier, iserr)
|
||||||
inform.common(g_gamevar[identifier].loc, iserr)
|
inform.common(g_gamevar[identifier].loc, iserr, "Old definition")
|
||||||
|
end
|
||||||
|
|
||||||
|
function inform.gv_location(identifier, iserr)
|
||||||
|
inform.common(g_gamevar[identifier].loc, iserr, "Definition")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -2128,6 +2132,7 @@ function lookup.array_expr(writep, structname, index, membertab)
|
||||||
local gv = g_gamevar[structname]
|
local gv = g_gamevar[structname]
|
||||||
if (gv and bit.band(gv.flags, GVFLAG.PERX_MASK)~=GVFLAG.PERACTOR) then
|
if (gv and bit.band(gv.flags, GVFLAG.PERX_MASK)~=GVFLAG.PERACTOR) then
|
||||||
errprintf("gamevar `%s' is not per-actor", structname, "actor")
|
errprintf("gamevar `%s' is not per-actor", structname, "actor")
|
||||||
|
-- TODO: inform.gv_location()?
|
||||||
end
|
end
|
||||||
|
|
||||||
if (membertab == nil) then
|
if (membertab == nil) then
|
||||||
|
@ -2239,6 +2244,7 @@ local function GetOrSetPerxvarCmd(Setp, Actorp)
|
||||||
local xprintf = warnp and warnprintf or errprintf
|
local xprintf = warnp and warnprintf or errprintf
|
||||||
|
|
||||||
xprintf("gamevar `%s' is not per-%s", perxvarname, Actorp and "actor" or "player")
|
xprintf("gamevar `%s' is not per-%s", perxvarname, Actorp and "actor" or "player")
|
||||||
|
inform.gv_location(perxvarname, not warnp)
|
||||||
|
|
||||||
if (warnp and bit.band(gv.flags, GVFLAG.PERX_MASK)==GVFLAG.PERPLAYER
|
if (warnp and bit.band(gv.flags, GVFLAG.PERX_MASK)==GVFLAG.PERPLAYER
|
||||||
and g_cgopt["bad-getactorvar-use-pli"]) then
|
and g_cgopt["bad-getactorvar-use-pli"]) then
|
||||||
|
@ -3612,6 +3618,10 @@ function on.switch_end(testvar, blocks)
|
||||||
return code
|
return code
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function on.case_colon(pos)
|
||||||
|
pwarnprintf(pos, "encountered deprecated ':' after 'case'")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- The final grammar!
|
--- The final grammar!
|
||||||
local Grammar = Pat{
|
local Grammar = Pat{
|
||||||
|
@ -3687,7 +3697,8 @@ local Grammar = Pat{
|
||||||
/ on.switch_end,
|
/ on.switch_end,
|
||||||
|
|
||||||
-- NOTE: some old DNWMD has "case: PIGCOP". I don't think I'll allow that.
|
-- NOTE: some old DNWMD has "case: PIGCOP". I don't think I'll allow that.
|
||||||
case_block = lpeg.Ct((sp1 * Keyw("case") * sp1 * tok.define * (sp0*":")^-1)^1 * sp1 *
|
case_block = lpeg.Ct((sp1 * Keyw("case") * (POS()*Pat(":") / on.case_colon)^-1
|
||||||
|
* sp1 * tok.define * (sp0*":")^-1)^1 * sp1 *
|
||||||
stmt_list_nosp_or_eps), -- * "break",
|
stmt_list_nosp_or_eps), -- * "break",
|
||||||
|
|
||||||
default_block = lpeg.Ct(sp1 * Keyw("default") * (sp0*":"*sp0 + sp1) *
|
default_block = lpeg.Ct(sp1 * Keyw("default") * (sp0*":"*sp0 + sp1) *
|
||||||
|
|
Loading…
Reference in a new issue