- fixed bad definition of struct grammar which tried to resolve from right to left, creating large amounts of recursion and strange problems with PlayerInfo.

- added a command line option to generate a parser trace file.
- fixed a syntax error in player.txt.
This commit is contained in:
Christoph Oelckers 2016-11-27 12:18:06 +01:00
parent b10ffb5133
commit 36f559ecb7
3 changed files with 13 additions and 11 deletions

View file

@ -299,7 +299,7 @@ opt_struct_body(X) ::= error. { X = NULL; }
struct_body(X) ::= struct_member(X). struct_body(X) ::= struct_member(X).
struct_body(X) ::= struct_member(A) struct_body(B). { X = A; /*X-overwrites-A*/ AppendTreeNodeSibling(X, B); } struct_body(X) ::= struct_body(A) struct_member(B). { X = A; /*X-overwrites-A*/ AppendTreeNodeSibling(X, B); }
struct_member(X) ::= declarator(A). { X = A; /*X-overwrites-A*/ } struct_member(X) ::= declarator(A). { X = A; /*X-overwrites-A*/ }
struct_member(X) ::= enum_def(A). { X = A; /*X-overwrites-A*/ } struct_member(X) ::= enum_def(A). { X = A; /*X-overwrites-A*/ }

View file

@ -302,12 +302,15 @@ static void DoParse(int lumpnum)
parser = ZCCParseAlloc(malloc); parser = ZCCParseAlloc(malloc);
ZCCParseState state; ZCCParseState state;
//#define TRACE
#ifdef TRACE // this costs a lot of time and should only be activated when it's really needed. FILE *f = nullptr;
FILE *f = fopen("trace.txt", "w"); const char *tracefile = Args->CheckValue("-tracefile");
char prompt = '\0'; if (tracefile != nullptr)
ZCCParseTrace(f, &prompt); {
#endif f = fopen(tracefile, "w");
char prompt = '\0';
ZCCParseTrace(f, &prompt);
}
sc.OpenLumpNum(lumpnum); sc.OpenLumpNum(lumpnum);
auto saved = sc.SavePos(); auto saved = sc.SavePos();
@ -341,6 +344,7 @@ static void DoParse(int lumpnum)
} }
} }
if (f) fprintf(f, "Starting parsing %s\n", sc.String);
ParseSingleFile(sc.String, 0, parser, state); ParseSingleFile(sc.String, 0, parser, state);
} }
} }
@ -356,12 +360,10 @@ static void DoParse(int lumpnum)
I_Error("%d errors while parsing %s", FScriptPosition::ErrorCounter, Wads.GetLumpFullPath(lumpnum).GetChars()); I_Error("%d errors while parsing %s", FScriptPosition::ErrorCounter, Wads.GetLumpFullPath(lumpnum).GetChars());
} }
#ifdef TRACE if (f != nullptr)
if (f != NULL)
{ {
fclose(f); fclose(f);
} }
#endif
// Make a dump of the AST before running the compiler for diagnostic purposes. // Make a dump of the AST before running the compiler for diagnostic purposes.
if (Args->CheckParm("-dumpast")) if (Args->CheckParm("-dumpast"))

View file

@ -228,7 +228,7 @@ FWeaponSlots weapons;
native bool UndoPlayerMorph(playerinfo player, int unmorphflag = 0, bool force = false); native bool UndoPlayerMorph(playerinfo player, int unmorphflag = 0, bool force = false);
native bool PoisonPlayer(Actor poisoner, Actor source, int poison); native bool PoisonPlayer(Actor poisoner, Actor source, int poison);
native PoisonDamage(Actor source, int damage, bool playPainSound) native void PoisonDamage(Actor source, int damage, bool playPainSound);
native void SetPsprite(int id, State stat, bool pending = false); native void SetPsprite(int id, State stat, bool pending = false);
native void SetSafeFlash(Weapon weap, State flashstate, int index); native void SetSafeFlash(Weapon weap, State flashstate, int index);
native PSprite GetPSprite(int id); native PSprite GetPSprite(int id);