From f23e5d26775c7e5af8f60f9dc66dee2a469c0f46 Mon Sep 17 00:00:00 2001 From: Marisa Heit Date: Fri, 14 Oct 2016 22:02:55 -0500 Subject: [PATCH 1/2] Fixed: XLAT would not parse - Disable the changes from commit 96afce241d6bc08cfdb0018ea6e5f0c23e8ba5c8 because it appears to not recognize default rules that reduce as reducing. - When tracing a parser, flush after every line output in case an assert is hit so you can actually see what it did up to that point. --- tools/lemon/lemon.c | 8 ++++++++ tools/lemon/lempar.c | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c index f2da9c6f8..bdc004a17 100644 --- a/tools/lemon/lemon.c +++ b/tools/lemon/lemon.c @@ -199,7 +199,9 @@ struct rule { int index; /* An index number for this rule */ int iRule; /* Rule number as used in the generated tables */ Boolean canReduce; /* True if this rule is ever reduced */ +#if 0 Boolean doesReduce; /* Reduce actions occur after optimization */ +#endif struct rule *nextlhs; /* Next rule with the same LHS */ struct rule *next; /* Next rule in the global list */ }; @@ -4156,6 +4158,7 @@ void ReportTable( } free(ax); +#if 0 /* Mark rules that are actually used for reduce actions after all ** optimizations have been applied */ @@ -4168,6 +4171,7 @@ void ReportTable( } } } +#endif /* Finish rendering the constants now that the action table has ** been computed */ @@ -4462,12 +4466,16 @@ void ReportTable( assert( rp->noCode ); fprintf(out," /* (%d) ", rp->iRule); writeRuleText(out, rp); +#if 0 if( rp->doesReduce ){ +#endif fprintf(out, " */ yytestcase(yyruleno==%d);\n", rp->iRule); lineno++; +#if 0 }else{ fprintf(out, " (OPTIMIZED OUT) */ assert(yyruleno!=%d);\n", rp->iRule); lineno++; } +#endif } fprintf(out," break;\n"); lineno++; tplt_xfer(lemp->name,in,out,&lineno); diff --git a/tools/lemon/lempar.c b/tools/lemon/lempar.c index 0e360bab9..93b612017 100644 --- a/tools/lemon/lempar.c +++ b/tools/lemon/lempar.c @@ -308,6 +308,7 @@ static int yyGrowStack(yyParser *p){ if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n", yyTracePrompt, p->yystksz, newSize); + fflush(yyTraceFILE); } #endif p->yystksz = newSize; @@ -410,6 +411,7 @@ static void yy_pop_parser_stack(yyParser *pParser){ fprintf(yyTraceFILE,"%sPopping %s\n", yyTracePrompt, yyTokenName[yytos->major]); + fflush(yyTraceFILE); } #endif yy_destructor(pParser, yytos->major, &yytos->minor); @@ -474,6 +476,7 @@ static unsigned int yy_find_shift_action( if( yyTraceFILE ){ fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); + fflush(yyTraceFILE); } #endif assert( yyFallback[iFallback]==0 ); /* Fallback loop must terminate */ @@ -498,6 +501,7 @@ static unsigned int yy_find_shift_action( fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); + fflush(yyTraceFILE); } #endif /* NDEBUG */ return yy_action[j]; @@ -551,6 +555,7 @@ static void yyStackOverflow(yyParser *yypParser){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); + fflush(yyTraceFILE); } #endif while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); @@ -576,6 +581,7 @@ static void yyTraceShift(yyParser *yypParser, int yyNewState){ fprintf(yyTraceFILE,"%sShift '%s'\n", yyTracePrompt,yyTokenName[yypParser->yytos->major]); } + fflush(yyTraceFILE); } } #else @@ -653,6 +659,7 @@ static void yy_reduce( yysize = yyRuleInfo[yyruleno].nrhs; fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt, yyRuleName[yyruleno], yymsp[-yysize].stateno); + fflush(yyTraceFILE); } #endif /* NDEBUG */ @@ -726,6 +733,7 @@ static void yy_parse_failed( #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); + fflush(yyTraceFILE); } #endif while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); @@ -764,12 +772,17 @@ static void yy_accept( #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); + fflush(yyTraceFILE); } #endif #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt = -1; #endif +#if 0 assert( yypParser->yytos==yypParser->yystack ); +#else + while (yypParser->yytos>yypParser->yystack) yy_pop_parser_stack(yypParser); +#endif /* Here code is inserted which will be executed whenever the ** parser accepts */ /*********** Begin %parse_accept code *****************************************/ @@ -823,6 +836,7 @@ void Parse( #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sInput '%s'\n",yyTracePrompt,yyTokenName[yymajor]); + fflush(yyTraceFILE); } #endif @@ -845,6 +859,7 @@ void Parse( #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); + fflush(yyTraceFILE); } #endif #ifdef YYERRORSYMBOL @@ -876,6 +891,7 @@ void Parse( if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sDiscard input token %s\n", yyTracePrompt,yyTokenName[yymajor]); + fflush(yyTraceFILE); } #endif yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); @@ -949,6 +965,7 @@ void Parse( cDiv = ' '; } fprintf(yyTraceFILE,"]\n"); + fflush(yyTraceFILE); } #endif return; From 162da2fcafbb4c9e55d2272470c81b0a29e2ad9a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 15 Oct 2016 10:51:48 +0200 Subject: [PATCH 2/2] - allow to specify "none" to set an actor's translation to the identity table. --- src/r_data/r_translate.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/r_data/r_translate.cpp b/src/r_data/r_translate.cpp index bf9365002..983baea58 100644 --- a/src/r_data/r_translate.cpp +++ b/src/r_data/r_translate.cpp @@ -1207,6 +1207,10 @@ int R_FindCustomTranslation(const char *name) { return TRANSLATION(TRANSLATION_Standard, 7); } + else if (!stricmp(name, "None")) + { + return 0; + } int *t = customTranslationMap.CheckKey(FName(name, true)); return (t != nullptr)? *t : -1; }