mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 20:43:15 +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
|
||||
* 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 *}
|
||||
|
|
|
@ -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,14 +206,15 @@ 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;
|
||||
|
||||
if (filename != nullptr)
|
||||
{
|
||||
lump = Wads.CheckNumForFullName(filename, true);
|
||||
if (lump >= 0)
|
||||
{
|
||||
|
@ -224,6 +225,8 @@ static void ParseSingleFile(const char *filename, void *parser, ZCCParseState &s
|
|||
Printf("Could not find script lump '%s'\n", filename);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else sc.OpenLumpNum(lump);
|
||||
|
||||
state.sc = ≻
|
||||
while (sc.GetToken())
|
||||
|
@ -309,9 +312,27 @@ static void DoParse(int lumpnum)
|
|||
#endif
|
||||
|
||||
sc.OpenLumpNum(lumpnum);
|
||||
auto saved = sc.SavePos();
|
||||
bool parsed = false;
|
||||
if (sc.GetToken())
|
||||
{
|
||||
if (sc.TokenType == TK_Class || sc.TokenType == TK_Enum || sc.TokenType == TK_Struct || sc.TokenType == TK_Const || sc.TokenType == TK_Native)
|
||||
{
|
||||
if (sc.CheckToken(TK_Identifier))
|
||||
{
|
||||
// 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));
|
||||
|
@ -322,7 +343,8 @@ static void DoParse(int lumpnum)
|
|||
}
|
||||
}
|
||||
|
||||
ParseSingleFile(sc.String, parser, state);
|
||||
ParseSingleFile(sc.String, 0, parser, state);
|
||||
}
|
||||
}
|
||||
|
||||
value.Int = -1;
|
||||
|
|
Loading…
Reference in a new issue