CON: Add "defstate" token which functions identically as in M32script: synonymous with CON's "state" only at top-level (when defining a state). Useful for syntax highlighting.

git-svn-id: https://svn.eduke32.com/eduke32@5353 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-09-24 06:31:44 +00:00
parent a557eedf7e
commit f69f1e73df
4 changed files with 16 additions and 0 deletions

View File

@ -101,6 +101,7 @@ static struct { uint32_t keyw; uint32_t date; } g_keywdate[] =
{ CON_DEFINEVOLUMEFLAGS, 20150222 }, { CON_DEFINEVOLUMEFLAGS, 20150222 },
{ CON_RESETPLAYERFLAGS, 20150303 }, { CON_RESETPLAYERFLAGS, 20150303 },
{ CON_APPENDEVENT, 20150325 }, { CON_APPENDEVENT, 20150325 },
{ CON_DEFSTATE, 20150923 },
}; };
#endif #endif
@ -566,6 +567,7 @@ const char *keyw[] =
"definevolumeflags", // 380 "definevolumeflags", // 380
"resetplayerflags", // 381 "resetplayerflags", // 381
"appendevent", // 382 "appendevent", // 382
"defstate", // 383
"<null>" "<null>"
}; };
#endif #endif
@ -2783,9 +2785,18 @@ static int32_t C_ParseCommand(int32_t loop)
case -1: case -1:
case -2: case -2:
return 1; //End return 1; //End
case CON_DEFSTATE:
if (EDUKE32_PREDICT_FALSE(g_processingState || g_parsingActorPtr))
{
C_ReportError(ERROR_FOUNDWITHIN);
g_numCompilerErrors++;
continue;
}
goto DO_DEFSTATE;
case CON_STATE: case CON_STATE:
if (g_parsingActorPtr == NULL && g_processingState == 0) if (g_parsingActorPtr == NULL && g_processingState == 0)
{ {
DO_DEFSTATE:
C_GetNextLabelName(); C_GetNextLabelName();
g_scriptPtr--; g_scriptPtr--;
labelcode[g_numLabels] = g_scriptPtr-script; labelcode[g_numLabels] = g_scriptPtr-script;

View File

@ -1045,6 +1045,7 @@ enum ScriptKeywords_t
CON_DEFINEVOLUMEFLAGS, // 380 CON_DEFINEVOLUMEFLAGS, // 380
CON_RESETPLAYERFLAGS, // 381 CON_RESETPLAYERFLAGS, // 381
CON_APPENDEVENT, // 382 CON_APPENDEVENT, // 382
CON_DEFSTATE, // 383
CON_END CON_END
}; };
// KEEPINSYNC with the keyword list in lunatic/con_lang.lua // KEEPINSYNC with the keyword list in lunatic/con_lang.lua

View File

@ -1277,6 +1277,7 @@ lpeg.P(false) +
"displayrand" + "displayrand" +
"digitalnumberz" + "digitalnumberz" +
"digitalnumber" + "digitalnumber" +
"defstate" +
"definevolumename" + "definevolumename" +
"definevolumeflags" + "definevolumeflags" +
"definesound" + "definesound" +

View File

@ -3437,6 +3437,9 @@ local Cblock = {
state = POS() * sp1 * (lpeg.Cmt(tok.identifier, on.state_begin_Cmt)) state = POS() * sp1 * (lpeg.Cmt(tok.identifier, on.state_begin_Cmt))
* sp1 * stmt_list_or_eps * tok.state_ends * sp1 * stmt_list_or_eps * tok.state_ends
/ on.state_end, / on.state_end,
defstate = POS() * sp1 * (lpeg.Cmt(tok.identifier, on.state_begin_Cmt))
* sp1 * stmt_list_or_eps * tok.state_ends
/ on.state_end,
} }
for cmdname, cmdpat in pairs(Cblock) do for cmdname, cmdpat in pairs(Cblock) do