mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-24 04:51:41 +00:00
- 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:
parent
157cfe3ab3
commit
7068070c0d
2 changed files with 44 additions and 22 deletions
|
@ -690,7 +690,7 @@ type_name(X) ::= DOT dottable_id(A).
|
||||||
/* Type names can also be used as identifiers in contexts where type names
|
/* Type names can also be used as identifiers in contexts where type names
|
||||||
* are not normally allowed. */
|
* are not normally allowed. */
|
||||||
%fallback IDENTIFIER
|
%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 */
|
/* Aggregate types */
|
||||||
%type aggregate_type {ZCC_Type *}
|
%type aggregate_type {ZCC_Type *}
|
||||||
|
|
|
@ -179,9 +179,9 @@ static void InitTokenMap()
|
||||||
TOKENDEF (TK_Loop, ZCC_LOOP);
|
TOKENDEF (TK_Loop, ZCC_LOOP);
|
||||||
TOKENDEF (TK_Goto, ZCC_GOTO);
|
TOKENDEF (TK_Goto, ZCC_GOTO);
|
||||||
TOKENDEF (TK_States, ZCC_STATES);
|
TOKENDEF (TK_States, ZCC_STATES);
|
||||||
TOKENDEF (TK_State, ZCC_STATE);
|
TOKENDEF2(TK_State, ZCC_STATE, NAME_State);
|
||||||
TOKENDEF (TK_Color, ZCC_COLOR);
|
TOKENDEF2(TK_Color, ZCC_COLOR, NAME_Color);
|
||||||
TOKENDEF (TK_Sound, ZCC_SOUND);
|
TOKENDEF2(TK_Sound, ZCC_SOUND, NAME_Sound);
|
||||||
|
|
||||||
TOKENDEF (TK_Identifier, ZCC_IDENTIFIER);
|
TOKENDEF (TK_Identifier, ZCC_IDENTIFIER);
|
||||||
TOKENDEF (TK_StringConst, ZCC_STRCONST);
|
TOKENDEF (TK_StringConst, ZCC_STRCONST);
|
||||||
|
@ -206,24 +206,27 @@ static void InitTokenMap()
|
||||||
#undef TOKENDEF
|
#undef TOKENDEF
|
||||||
#undef TOKENDEF2
|
#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 tokentype;
|
||||||
int lump;
|
|
||||||
//bool failed;
|
//bool failed;
|
||||||
ZCCToken value;
|
ZCCToken value;
|
||||||
FScanner sc;
|
FScanner sc;
|
||||||
|
|
||||||
lump = Wads.CheckNumForFullName(filename, true);
|
if (filename != nullptr)
|
||||||
if (lump >= 0)
|
|
||||||
{
|
{
|
||||||
sc.OpenLumpNum(lump);
|
lump = Wads.CheckNumForFullName(filename, true);
|
||||||
}
|
if (lump >= 0)
|
||||||
else
|
{
|
||||||
{
|
sc.OpenLumpNum(lump);
|
||||||
Printf("Could not find script lump '%s'\n", filename);
|
}
|
||||||
return;
|
else
|
||||||
|
{
|
||||||
|
Printf("Could not find script lump '%s'\n", filename);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else sc.OpenLumpNum(lump);
|
||||||
|
|
||||||
state.sc = ≻
|
state.sc = ≻
|
||||||
while (sc.GetToken())
|
while (sc.GetToken())
|
||||||
|
@ -309,20 +312,39 @@ static void DoParse(int lumpnum)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sc.OpenLumpNum(lumpnum);
|
sc.OpenLumpNum(lumpnum);
|
||||||
// parse all files from this list in one go.
|
auto saved = sc.SavePos();
|
||||||
while (sc.GetString())
|
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 (sc.CheckToken(TK_Identifier))
|
||||||
if (includefile != 0)
|
|
||||||
{
|
{
|
||||||
I_FatalError("File %s is overriding core lump %s.",
|
// This looks like an actual definition file and not a file list.
|
||||||
Wads.GetWadFullName(includefile), sc.String);
|
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;
|
value.Int = -1;
|
||||||
|
|
Loading…
Reference in a new issue