- fixed: The identifier fallback which existed for all other basic types was missing for 'state'.

- added the option to put code right into the ZSCRIPT lump for smaller definitions where a file list would be too cumbersome.
This commit is contained in:
Christoph Oelckers 2016-11-04 09:56:03 +01:00
parent 157cfe3ab3
commit 7068070c0d
2 changed files with 44 additions and 22 deletions

View File

@ -690,7 +690,7 @@ type_name(X) ::= DOT dottable_id(A).
/* Type names can also be used as identifiers in contexts where type names
* are not normally allowed. */
%fallback IDENTIFIER
SBYTE BYTE SHORT USHORT INT UINT BOOL FLOAT DOUBLE STRING VECTOR2 VECTOR3 NAME MAP ARRAY VOID.
SBYTE BYTE SHORT USHORT INT UINT BOOL FLOAT DOUBLE STRING VECTOR2 VECTOR3 NAME MAP ARRAY VOID STATE.
/* Aggregate types */
%type aggregate_type {ZCC_Type *}

View File

@ -179,9 +179,9 @@ static void InitTokenMap()
TOKENDEF (TK_Loop, ZCC_LOOP);
TOKENDEF (TK_Goto, ZCC_GOTO);
TOKENDEF (TK_States, ZCC_STATES);
TOKENDEF (TK_State, ZCC_STATE);
TOKENDEF (TK_Color, ZCC_COLOR);
TOKENDEF (TK_Sound, ZCC_SOUND);
TOKENDEF2(TK_State, ZCC_STATE, NAME_State);
TOKENDEF2(TK_Color, ZCC_COLOR, NAME_Color);
TOKENDEF2(TK_Sound, ZCC_SOUND, NAME_Sound);
TOKENDEF (TK_Identifier, ZCC_IDENTIFIER);
TOKENDEF (TK_StringConst, ZCC_STRCONST);
@ -206,24 +206,27 @@ static void InitTokenMap()
#undef TOKENDEF
#undef TOKENDEF2
static void ParseSingleFile(const char *filename, void *parser, ZCCParseState &state)
static void ParseSingleFile(const char *filename, int lump, void *parser, ZCCParseState &state)
{
int tokentype;
int lump;
//bool failed;
ZCCToken value;
FScanner sc;
lump = Wads.CheckNumForFullName(filename, true);
if (lump >= 0)
if (filename != nullptr)
{
sc.OpenLumpNum(lump);
}
else
{
Printf("Could not find script lump '%s'\n", filename);
return;
lump = Wads.CheckNumForFullName(filename, true);
if (lump >= 0)
{
sc.OpenLumpNum(lump);
}
else
{
Printf("Could not find script lump '%s'\n", filename);
return;
}
}
else sc.OpenLumpNum(lump);
state.sc = ≻
while (sc.GetToken())
@ -309,20 +312,39 @@ static void DoParse(int lumpnum)
#endif
sc.OpenLumpNum(lumpnum);
// parse all files from this list in one go.
while (sc.GetString())
auto saved = sc.SavePos();
bool parsed = false;
if (sc.GetToken())
{
if (Wads.GetLumpFile(sc.LumpNum) == 0)
if (sc.TokenType == TK_Class || sc.TokenType == TK_Enum || sc.TokenType == TK_Struct || sc.TokenType == TK_Const || sc.TokenType == TK_Native)
{
int includefile = Wads.GetLumpFile(Wads.CheckNumForFullName(sc.String, true));
if (includefile != 0)
if (sc.CheckToken(TK_Identifier))
{
I_FatalError("File %s is overriding core lump %s.",
Wads.GetWadFullName(includefile), sc.String);
// This looks like an actual definition file and not a file list.
ParseSingleFile(nullptr, lumpnum, parser, state);
parsed = true;
}
}
}
if (!parsed)
{
sc.RestorePos(saved);
// parse all files from this list in one go.
while (sc.GetString())
{
FixPathSeperator(sc.String);
if (Wads.GetLumpFile(sc.LumpNum) == 0)
{
int includefile = Wads.GetLumpFile(Wads.CheckNumForFullName(sc.String, true));
if (includefile != 0)
{
I_FatalError("File %s is overriding core lump %s.",
Wads.GetWadFullName(includefile), sc.String);
}
}
ParseSingleFile(sc.String, parser, state);
ParseSingleFile(sc.String, 0, parser, state);
}
}
value.Int = -1;