From 8ea316e33b7c56a1d9904edf420915f3586d58c8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 19 Mar 2008 21:09:53 +0000 Subject: [PATCH] - Integrated xlatcc into ZDoom.exe so that the linedef translation files don't need to be compiled and can be stored as text in zdoom.pk3. SVN r815 (trunk) --- Makefile.linux | 5 +- Makefile.mgw | 2 - docs/rh-log.txt | 2 + src/p_xlat.cpp | 232 +- src/thingdef/thingdef_specials.h | 568 ----- src/w_wad.cpp | 10 +- src/w_wad.h | 2 +- src/xlat/parse_xlat.cpp | 464 ++++ src/xlat/xlat.h | 67 + src/xlat/xlat_parser.c | 1806 +++++++++++++++ src/xlat/xlat_parser.h | 30 + src/xlat/xlat_parser.y | 451 ++++ tools/xlatcc/Makefile | 50 - tools/xlatcc/gen.c | 275 --- tools/xlatcc/xlat-parse.c | 2167 ------------------ tools/xlatcc/xlat-parse.h | 37 - tools/xlatcc/xlat-parse.y | 852 ------- tools/xlatcc/xlat.h | 59 - tools/xlatcc/xlatcc.vcproj | 411 ---- wadsrc/Makefile | 5 +- wadsrc/Makefile2 | 9 - wadsrc/xlat/defines.i | 20 - wadsrc/xlat/{doomxlat.txt => doom.txt} | 1 + wadsrc/xlat/{hereticxlat.txt => heretic.txt} | 0 wadsrc/xlat/specials.i | 190 -- wadsrc/xlat/{strifexlat.txt => strife.txt} | 0 wadsrc/zdoom.lst | 12 +- zdoom.sln | 19 +- zdoom.vcproj | 36 + 29 files changed, 2952 insertions(+), 4830 deletions(-) delete mode 100644 src/thingdef/thingdef_specials.h create mode 100644 src/xlat/parse_xlat.cpp create mode 100644 src/xlat/xlat.h create mode 100644 src/xlat/xlat_parser.c create mode 100644 src/xlat/xlat_parser.h create mode 100644 src/xlat/xlat_parser.y delete mode 100644 tools/xlatcc/Makefile delete mode 100644 tools/xlatcc/gen.c delete mode 100644 tools/xlatcc/xlat-parse.c delete mode 100644 tools/xlatcc/xlat-parse.h delete mode 100644 tools/xlatcc/xlat-parse.y delete mode 100644 tools/xlatcc/xlat.h delete mode 100644 tools/xlatcc/xlatcc.vcproj rename wadsrc/xlat/{doomxlat.txt => doom.txt} (97%) rename wadsrc/xlat/{hereticxlat.txt => heretic.txt} (100%) delete mode 100644 wadsrc/xlat/specials.i rename wadsrc/xlat/{strifexlat.txt => strife.txt} (100%) diff --git a/Makefile.linux b/Makefile.linux index d39a120821..5ae9ebee91 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -91,7 +91,7 @@ $(OBJDIR)/fmopl.o: src/oplsynth/fmopl.cpp $(OBJDIR): mkdir $(OBJDIR) -toolsandpk3: ccdv tools/makewad/makewad tools/dehsupp/dehsupp tools/xlatcc/xlatcc +toolsandpk3: ccdv tools/makewad/makewad tools/dehsupp/dehsupp $(MAKE) -C wadsrc/ zdoom.pk3: toolsandpk3 @@ -106,9 +106,6 @@ tools/makewad/makewad: tools/dehsupp/dehsupp: $(MAKE) -C tools/dehsupp/ -tools/xlatcc/xlatcc: - $(MAKE) -C tools/xlatcc/ - updaterev: tools/updaterevision/updaterevision @tools/updaterevision/updaterevision . src/svnrevision.h diff --git a/Makefile.mgw b/Makefile.mgw index 5d1ad42806..d21668bd4d 100644 --- a/Makefile.mgw +++ b/Makefile.mgw @@ -24,7 +24,6 @@ basetools: ccdv.exe $(MAKE) -C zlib -f Makefile.mgw $(MAKE) -C tools/makewad $(MAKE) -C tools/dehsupp - $(MAKE) -C tools/xlatcc $(MAKE) -C tools/fixrtext $(MAKE) -C wadsrc -f Makefile.mgw $(MAKE) -C jpeg-6b -f Makefile.mgw @@ -38,7 +37,6 @@ clean: @$(MAKE) -C tools/re2c clean @$(MAKE) -C tools/dehsupp clean @$(MAKE) -C tools/makewad clean - @$(MAKE) -C tools/xlatcc clean @$(MAKE) -C tools/fixrtext clean @$(MAKE) -C wadsrc -f Makefile.mgw clean @$(MAKE) -C . -f Makefile.mingw clean diff --git a/docs/rh-log.txt b/docs/rh-log.txt index a3bb078a40..e73203aebb 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,6 @@ March 19, 2008 (Changes by Graf Zahl) +- Integrated xlatcc into ZDoom.exe so that the linedef translation files + don't need to be compiled and can be stored as text in zdoom.pk3. - Removed thingdef_specials.h and thingdef_specials.gperf and replaced line special definition with something that automatically gets updated if new specials are added. diff --git a/src/p_xlat.cpp b/src/p_xlat.cpp index af3549a61b..9c5724d4fd 100644 --- a/src/p_xlat.cpp +++ b/src/p_xlat.cpp @@ -30,9 +30,6 @@ ** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **--------------------------------------------------------------------------- ** -** The linedef translations are read from a WAD lump (DOOMX or HERETICX), -** so most of this file's behavior can be easily customized without -** recompiling. */ #include "doomtype.h" @@ -48,6 +45,7 @@ #include "w_wad.h" #include "sc_man.h" #include "cmdlib.h" +#include "xlat/xlat.h" // define names for the TriggerType field of the general linedefs @@ -66,12 +64,10 @@ typedef enum void P_TranslateLineDef (line_t *ld, maplinedef_t *mld) { static FMemLump tlatebase; - const BYTE *tlate; - short special = LittleShort(mld->special); + unsigned short special = (unsigned short) LittleShort(mld->special); short tag = LittleShort(mld->tag); DWORD flags = LittleShort(mld->flags); INTBOOL passthrough; - int i; if (flags & ML_TRANSLUCENT_STRIFE) { @@ -79,9 +75,6 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld) } if (gameinfo.gametype == GAME_Strife) { - // It might be useful to make these usable by all games. - // Unfortunately, there aren't enough flag bits left to do that, - // so they're Strife-only. if (flags & ML_RAILING_STRIFE) { flags |= ML_RAILING; @@ -125,127 +118,63 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld) return; } - // The translation lump is cached across calls to P_TranslateLineDef. - if (tlatebase.GetMem() == NULL) + FLineTrans *linetrans = NULL; + if (special < SimpleLineTranslations.Size()) linetrans = &SimpleLineTranslations[special]; + if (linetrans != NULL && linetrans->special != 0) { - if (gameinfo.gametype == GAME_Doom) + ld->special = linetrans->special; + ld->args[0] = linetrans->args[0]; + ld->args[1] = linetrans->args[1]; + ld->args[2] = linetrans->args[2]; + ld->args[3] = linetrans->args[3]; + ld->args[4] = linetrans->args[4]; + + ld->flags = flags | ((linetrans->flags & 0x1f) << 9); + + if (passthrough && (GET_SPAC(ld->flags) == SPAC_USE)) { - tlatebase = Wads.ReadLump ("DOOMX"); + ld->flags &= ~ML_SPAC_MASK; + ld->flags |= SPAC_USETHROUGH << ML_SPAC_SHIFT; } - else if (gameinfo.gametype == GAME_Strife) + switch (linetrans->flags & 0xe0) { - tlatebase = Wads.ReadLump ("STRIFEX"); + case LINETRANS_HAS2TAGS: // First two arguments are tags + ld->args[1] = tag; + case LINETRANS_HASTAGAT1: // First argument is a tag + ld->args[0] = tag; + break; + + case LINETRANS_HASTAGAT2: // Second argument is a tag + ld->args[1] = tag; + break; + + case LINETRANS_HASTAGAT3: // Third argument is a tag + ld->args[2] = tag; + break; + + case LINETRANS_HASTAGAT4: // Fourth argument is a tag + ld->args[3] = tag; + break; + + case LINETRANS_HASTAGAT5: // Fifth argument is a tag + ld->args[4] = tag; + break; } - else + if ((ld->flags & ML_SECRET) && (GET_SPAC(ld->flags) == SPAC_USE || GET_SPAC(ld->flags) == SPAC_USETHROUGH)) { - tlatebase = Wads.ReadLump ("HERETICX"); - } - } - tlate = (const BYTE *)tlatebase.GetMem(); - - // Check if this is a regular linetype - if (tlate[0] == 'N' && tlate[1] == 'O' && tlate[2] == 'R' && tlate[3] == 'M') - { - int count = (tlate[4] << 8) | tlate[5]; - tlate += 6; - while (count) - { - int low = (tlate[0] << 8) | tlate[1]; - int high = (tlate[2] << 8) | tlate[3]; - tlate += 4; - if (special >= low && special <= high) - { // found it, so use the LUT - const BYTE *specialmap = tlate + (special - low) * 7; - - ld->flags = flags | ((specialmap[0] & 0x1f) << 9); - - if (passthrough && (GET_SPAC(ld->flags) == SPAC_USE)) - { - ld->flags &= ~ML_SPAC_MASK; - ld->flags |= SPAC_USETHROUGH << ML_SPAC_SHIFT; - } - ld->special = specialmap[1]; - ld->args[0] = specialmap[2]; - ld->args[1] = specialmap[3]; - ld->args[2] = specialmap[4]; - ld->args[3] = specialmap[5]; - ld->args[4] = specialmap[6]; - switch (specialmap[0] & 0xe0) - { - case 7<<5: // First two arguments are tags - ld->args[1] = tag; - case 1<<5: case 6<<5: // First argument is a tag - ld->args[0] = tag; - break; - - case 2<<5: // Second argument is a tag - ld->args[1] = tag; - break; - - case 3<<5: // Third argument is a tag - ld->args[2] = tag; - break; - - case 4<<5: // Fourth argument is a tag - ld->args[3] = tag; - break; - - case 5<<5: // Fifth argument is a tag - ld->args[4] = tag; - break; - } - if ((ld->flags & ML_SECRET) && (GET_SPAC(ld->flags) == SPAC_USE || GET_SPAC(ld->flags) == SPAC_USETHROUGH)) - { - ld->flags &= ~ML_MONSTERSCANACTIVATE; - } - return; - } - tlate += (high - low + 1) * 7; - count--; + ld->flags &= ~ML_MONSTERSCANACTIVATE; } + return; } - // Check if this is a BOOM generalized linetype - if (tlate[0] == 'B' && tlate[1] == 'O' && tlate[2] == 'O' && tlate[3] == 'M') + for(int i=0;i - // WORD - // BYTE - // repeat [BYTE op BYTES parms] - // - // op consists of some bits: - // - // 76543210 - // ||||||++-- Dest is arg[(op&3)+1] (arg[0] is always tag) - // |||||+---- 0 = store, 1 = or with existing value - // ||||+----- 0 = this is normal, 1 = x-op in next byte - // ++++------ # of elements in list, or 0 to always use a constant value - // - // If a constant value is used, parms is a single byte containing that value. - // Otherwise, parms has the format: - // - // WORD - // repeat [WORD BYTE ] - // - // These x-ops are defined: - // - // 0 = end of this BOOM translator - // 1 = dest is flags - - while (count) + if (special >= b->FirstLinetype && special <= b->LastLinetype) { - int low = (tlate[0] << 8) | tlate[1]; - int high = (tlate[2] << 8) | tlate[3]; - tlate += 4; + ld->special = b->NewSpecial; - DWORD oflags = flags; - - // Assume we found it and translate switch (special & 0x0007) { case WalkMany: @@ -275,60 +204,43 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld) ld->args[0] = tag; ld->args[1] = ld->args[2] = ld->args[3] = ld->args[4] = 0; - ld->special = *tlate++; - for (;;) + for(unsigned j=0; j < b->Args.Size(); j++) { + FBoomArg *arg = &b->Args[j]; int *destp; int flagtemp; - BYTE op = *tlate++; - BYTE dest; BYTE val = 0; // quiet, GCC bool found; - int lsize; - dest = op & 3; - if (op & 8) + if (arg->ArgNum < 4) { - BYTE xop = *tlate++; - if (xop == 0) - break; - else if (xop == 1) - dest = 4; - } - if (dest < 4) - { - destp = &ld->args[dest+1]; + destp = &ld->args[arg->ArgNum+1]; } else { flagtemp = ((flags >> 9) & 0x3f); destp = &flagtemp; } - lsize = op >> 4; - if (lsize == 0) + if (arg->ListSize == 0) { - val = *tlate++; + val = arg->ConstantValue; found = true; } else { - WORD mask = (tlate[0] << 8) | tlate[1]; - tlate += 2; found = false; - for (i = 0; i < lsize; i++) + for (int k = 0; k < arg->ListSize; k++) { - WORD filter = (tlate[0] << 8) | tlate[1]; - if ((special & mask) == filter) + if ((special & arg->AndValue) == arg->ResultFilter[k]) { - val = tlate[2]; + val = arg->ResultValue[k]; found = true; } - tlate += 3; } } if (found) { - if (op & 4) + if (arg->bOrExisting) { *destp |= val; } @@ -336,35 +248,28 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld) { *destp = val; } - if (dest == 4) + if (arg->ArgNum == 4) { flags = (flags & ~0x7e00) | (flagtemp << 9); } } } - if (special >= low && special <= high) - { // Really found it, so we're done - // We treat push triggers like switch triggers with zero tags. - if ((special & 7) == PushMany || (special & 7) == PushOnce) + // We treat push triggers like switch triggers with zero tags. + if ((special & 7) == PushMany || (special & 7) == PushOnce) + { + if (ld->special == Generic_Door) { - if (ld->special == Generic_Door) - { - ld->args[2] |= 128; - } - else - { - ld->args[0] = 0; - } + ld->args[2] |= 128; + } + else + { + ld->args[0] = 0; } - ld->flags = flags; - return; } - - flags = oflags; - count--; + ld->flags = flags; + return; } } - // Don't know what to do, so 0 it ld->special = 0; ld->flags = flags; @@ -557,3 +462,4 @@ int P_TranslateSectorSpecial (int special) return sectortables[1][special] | high; } + diff --git a/src/thingdef/thingdef_specials.h b/src/thingdef/thingdef_specials.h deleted file mode 100644 index 2cc373fadb..0000000000 --- a/src/thingdef/thingdef_specials.h +++ /dev/null @@ -1,568 +0,0 @@ -/* ANSI-C code produced by gperf version 3.0.1 */ -/* Command-line: gperf -m10000 -tE -LANSI-C -Hspecialhash -Nis_special -C --null-strings thingdef_specials.gperf */ -/* Computed positions: -k'1,7,9,14,17' */ - -#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ - && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ - && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ - && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ - && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ - && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ - && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ - && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ - && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ - && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ - && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ - && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ - && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ - && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ - && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ - && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ - && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ - && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ - && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ - && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ - && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ - && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ - && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) -/* The character set is not based on ISO-646. */ -#error "gperf generated tables don't work with this execution character set. Please report a bug to ." -#endif - -#line 10 "thingdef_specials.gperf" -struct ACSspecials { const char *name; unsigned char Special; unsigned char MinArgs; unsigned char MaxArgs; }; -/* maximum key range = 326, duplicates = 0 */ - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static unsigned int -specialhash (register const char *str, register unsigned int len) -{ - static const unsigned short asso_values[] = - { - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 53, 356, 20, 85, 15, - 107, 13, 88, 10, 68, 95, 10, 10, 13, 136, - 72, 84, 44, 356, 10, 11, 12, 28, 53, 69, - 10, 75, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, - 356, 356, 356, 356, 356, 356 - }; - register int hval = len; - - switch (hval) - { - default: - hval += asso_values[(unsigned char)str[16]]; - /*FALLTHROUGH*/ - case 16: - case 15: - case 14: - hval += asso_values[(unsigned char)str[13]]; - /*FALLTHROUGH*/ - case 13: - case 12: - case 11: - case 10: - case 9: - hval += asso_values[(unsigned char)str[8]]; - /*FALLTHROUGH*/ - case 8: - case 7: - hval += asso_values[(unsigned char)str[6]]; - /*FALLTHROUGH*/ - case 6: - case 5: - case 4: - case 3: - case 2: - case 1: - hval += asso_values[(unsigned char)str[0]]; - break; - } - return hval; -} - -#ifdef __GNUC__ -__inline -#endif -const struct ACSspecials * -is_special (register const char *str, register unsigned int len) -{ - enum - { - TOTAL_KEYWORDS = 169, - MIN_WORD_LENGTH = 8, - MAX_WORD_LENGTH = 29, - MIN_HASH_VALUE = 30, - MAX_HASH_VALUE = 355 - }; - - static const struct ACSspecials wordlist[] = - { - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, {(char*)0}, -#line 76 "thingdef_specials.gperf" - {"teleport",70,1}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, {(char*)0}, -#line 93 "thingdef_specials.gperf" - {"teleportgroup",77,5}, -#line 49 "thingdef_specials.gperf" - {"light_strobe",116,5}, -#line 160 "thingdef_specials.gperf" - {"exit_secret",244,1}, -#line 145 "thingdef_specials.gperf" - {"thing_setgoal",229,3}, - {(char*)0}, -#line 126 "thingdef_specials.gperf" - {"generic_lift",203,5}, - {(char*)0}, {(char*)0}, {(char*)0}, -#line 88 "thingdef_specials.gperf" - {"thing_spawn",135,3,4}, -#line 13 "thingdef_specials.gperf" - {"acs_suspend",81,2}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, -#line 127 "thingdef_specials.gperf" - {"generic_stairs",204,5}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, {(char*)0}, -#line 128 "thingdef_specials.gperf" - {"generic_crusher",205,5}, - {(char*)0}, {(char*)0}, -#line 82 "thingdef_specials.gperf" - {"thing_activate",130,1}, -#line 12 "thingdef_specials.gperf" - {"acs_execute",80,1,5}, - {(char*)0}, {(char*)0}, {(char*)0}, -#line 107 "thingdef_specials.gperf" - {"line_alignceiling",183,2}, - {(char*)0}, -#line 105 "thingdef_specials.gperf" - {"thing_settranslation",180,2}, - {(char*)0}, {(char*)0}, {(char*)0}, -#line 168 "thingdef_specials.gperf" - {"ceiling_raisetonearest",252,2}, -#line 170 "thingdef_specials.gperf" - {"ceiling_lowertofloor",254,2}, - {(char*)0}, -#line 99 "thingdef_specials.gperf" - {"thing_spawnfacing",139,2,4}, -#line 21 "thingdef_specials.gperf" - {"ceiling_crushraiseandstay",45,3}, -#line 118 "thingdef_specials.gperf" - {"ceiling_crushraiseandstaya",195,4}, -#line 135 "thingdef_specials.gperf" - {"teleport_line",215,2}, -#line 141 "thingdef_specials.gperf" - {"scroll_floor",223,4}, -#line 171 "thingdef_specials.gperf" - {"ceiling_crushraiseandstaysila",255,4}, -#line 16 "thingdef_specials.gperf" - {"ceiling_crushandraise",42,3}, -#line 119 "thingdef_specials.gperf" - {"ceiling_crushandraisea",196,4}, -#line 15 "thingdef_specials.gperf" - {"acs_lockedexecute",83,5}, -#line 18 "thingdef_specials.gperf" - {"ceiling_lowerandcrush",43,3}, - {(char*)0}, {(char*)0}, -#line 180 "thingdef_specials.gperf" - {"acs_lockedexecutedoor",85,5}, -#line 120 "thingdef_specials.gperf" - {"ceiling_crushandraisesilenta",197,4}, -#line 77 "thingdef_specials.gperf" - {"teleport_nofog",71,1,2}, - {(char*)0}, -#line 142 "thingdef_specials.gperf" - {"scroll_ceiling",224,4}, -#line 102 "thingdef_specials.gperf" - {"thing_hate",177,2,3}, -#line 70 "thingdef_specials.gperf" - {"radius_quake",120,5}, -#line 133 "thingdef_specials.gperf" - {"sector_setfade",213,4}, -#line 177 "thingdef_specials.gperf" - {"noisealert",173,2}, -#line 63 "thingdef_specials.gperf" - {"polyobj_rotateright",3,3}, -#line 175 "thingdef_specials.gperf" - {"acs_executewithresult",84,1,4}, - {(char*)0}, -#line 59 "thingdef_specials.gperf" - {"plat_stop",61,1}, -#line 78 "thingdef_specials.gperf" - {"teleport_newmap",74,2}, -#line 79 "thingdef_specials.gperf" - {"teleport_endgame",75,0}, -#line 17 "thingdef_specials.gperf" - {"ceiling_crushstop",44,1}, -#line 134 "thingdef_specials.gperf" - {"sector_setdamage",214,3}, - {(char*)0}, {(char*)0}, -#line 139 "thingdef_specials.gperf" - {"sector_setcurrent",220,4}, -#line 47 "thingdef_specials.gperf" - {"light_glow",114,4}, -#line 50 "thingdef_specials.gperf" - {"light_stop",117,1}, -#line 92 "thingdef_specials.gperf" - {"teleportother",76,3}, - {(char*)0}, -#line 91 "thingdef_specials.gperf" - {"ceiling_waggle",38,5}, -#line 112 "thingdef_specials.gperf" - {"sector_setceilingscale",188,5}, - {(char*)0}, -#line 110 "thingdef_specials.gperf" - {"sector_setceilingpanning",186,5}, - {(char*)0}, -#line 123 "thingdef_specials.gperf" - {"generic_floor",200,5}, -#line 124 "thingdef_specials.gperf" - {"generic_ceiling",201,5}, -#line 178 "thingdef_specials.gperf" - {"thing_raise",17,1}, -#line 106 "thingdef_specials.gperf" - {"line_mirror",182,0}, -#line 80 "thingdef_specials.gperf" - {"thrustthing",72,2,4}, -#line 98 "thingdef_specials.gperf" - {"thrustthingz",128,4}, -#line 104 "thingdef_specials.gperf" - {"changeskill",179,1}, - {(char*)0}, -#line 148 "thingdef_specials.gperf" - {"light_strobedoom",232,3}, -#line 108 "thingdef_specials.gperf" - {"line_alignfloor",184,2}, - {(char*)0}, -#line 51 "thingdef_specials.gperf" - {"pillar_build",29,3}, -#line 14 "thingdef_specials.gperf" - {"acs_terminate",82,2}, - {(char*)0}, -#line 131 "thingdef_specials.gperf" - {"translucentline",208,2,3}, -#line 23 "thingdef_specials.gperf" - {"door_close",10,2}, -#line 173 "thingdef_specials.gperf" - {"clearforcefield",34,1}, -#line 84 "thingdef_specials.gperf" - {"thing_destroy",133,1,2}, -#line 125 "thingdef_specials.gperf" - {"generic_door",202,5}, -#line 94 "thingdef_specials.gperf" - {"teleportinsector",78,4,5}, -#line 97 "thingdef_specials.gperf" - {"thing_setspecial",127,5}, -#line 89 "thingdef_specials.gperf" - {"thing_spawnnofog",137,3,4}, -#line 25 "thingdef_specials.gperf" - {"door_raise",12,3}, - {(char*)0}, -#line 73 "thingdef_specials.gperf" - {"stairs_buildup",27,5}, - {(char*)0}, -#line 53 "thingdef_specials.gperf" - {"pillar_open",30,4}, - {(char*)0}, {(char*)0}, -#line 169 "thingdef_specials.gperf" - {"ceiling_lowertolowest",253,2}, - {(char*)0}, -#line 101 "thingdef_specials.gperf" - {"thing_changetid",176,2}, -#line 143 "thingdef_specials.gperf" - {"acs_executealways",226,1,5}, - {(char*)0}, -#line 20 "thingdef_specials.gperf" - {"ceiling_raisebyvalue",41,3}, - {(char*)0}, -#line 117 "thingdef_specials.gperf" - {"ceiling_raiseinstant",194,3}, -#line 19 "thingdef_specials.gperf" - {"ceiling_lowerbyvalue",40,3}, -#line 45 "thingdef_specials.gperf" - {"light_changetovalue",112,2}, -#line 116 "thingdef_specials.gperf" - {"ceiling_lowerinstant",193,3}, -#line 121 "thingdef_specials.gperf" - {"ceiling_raisebyvaluetimes8",198,3}, - {(char*)0}, {(char*)0}, -#line 122 "thingdef_specials.gperf" - {"ceiling_lowerbyvaluetimes8",199,3}, -#line 87 "thingdef_specials.gperf" - {"thing_remove",132,1}, - {(char*)0}, -#line 115 "thingdef_specials.gperf" - {"ceiling_lowertohighestfloor",192,2}, - {(char*)0}, -#line 165 "thingdef_specials.gperf" - {"door_closewaitopen",249,3}, -#line 83 "thingdef_specials.gperf" - {"thing_deactivate",131,1}, -#line 132 "thingdef_specials.gperf" - {"sector_setcolor",212,4,5}, - {(char*)0}, -#line 153 "thingdef_specials.gperf" - {"changecamera",237,3}, -#line 90 "thingdef_specials.gperf" - {"floor_waggle",138,5}, - {(char*)0}, -#line 144 "thingdef_specials.gperf" - {"plat_raiseandstaytx0",228,2}, -#line 164 "thingdef_specials.gperf" - {"healthing",248,1,2}, -#line 62 "thingdef_specials.gperf" - {"polyobj_rotateleft",2,3}, -#line 68 "thingdef_specials.gperf" - {"polyobj_or_rotateleft",90,3}, -#line 69 "thingdef_specials.gperf" - {"polyobj_or_rotateright",91,3}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, -#line 57 "thingdef_specials.gperf" - {"plat_upbyvalue",65,4}, - {(char*)0}, -#line 72 "thingdef_specials.gperf" - {"stairs_builddown",26,5}, -#line 140 "thingdef_specials.gperf" - {"scroll_texture_both",221,5}, -#line 44 "thingdef_specials.gperf" - {"light_lowerbyvalue",111,2}, -#line 162 "thingdef_specials.gperf" - {"elevator_movetofloor",246,2}, -#line 113 "thingdef_specials.gperf" - {"sector_setfloorscale",189,5}, - {(char*)0}, -#line 138 "thingdef_specials.gperf" - {"sector_setwind",218,4}, -#line 109 "thingdef_specials.gperf" - {"sector_setrotation",185,3}, - {(char*)0}, -#line 114 "thingdef_specials.gperf" - {"setplayerproperty",191,3}, -#line 61 "thingdef_specials.gperf" - {"polyobj_move",4,4}, -#line 111 "thingdef_specials.gperf" - {"sector_setfloorpanning",187,5}, -#line 65 "thingdef_specials.gperf" - {"polyobj_doorslide",8,5}, - {(char*)0}, -#line 67 "thingdef_specials.gperf" - {"polyobj_or_move",92,4}, -#line 74 "thingdef_specials.gperf" - {"stairs_builddownsync",31,4}, -#line 56 "thingdef_specials.gperf" - {"plat_upwaitdownstay",64,3}, -#line 48 "thingdef_specials.gperf" - {"light_flicker",115,3}, - {(char*)0}, -#line 96 "thingdef_specials.gperf" - {"thing_move",125,2}, - {(char*)0}, -#line 42 "thingdef_specials.gperf" - {"light_forcelightning",109,1}, - {(char*)0}, -#line 31 "thingdef_specials.gperf" - {"floor_lowertolowest",21,2}, -#line 146 "thingdef_specials.gperf" - {"plat_upbyvaluestaytx",230,3}, -#line 43 "thingdef_specials.gperf" - {"light_raisebyvalue",110,2}, -#line 46 "thingdef_specials.gperf" - {"light_fade",113,3}, -#line 157 "thingdef_specials.gperf" - {"floor_lowertolowesttxty",241,2}, - {(char*)0}, {(char*)0}, -#line 136 "thingdef_specials.gperf" - {"sector_setgravity",216,3}, - {(char*)0}, {(char*)0}, -#line 81 "thingdef_specials.gperf" - {"damagething",73,1}, -#line 75 "thingdef_specials.gperf" - {"stairs_buildupsync",32,4}, -#line 52 "thingdef_specials.gperf" - {"pillar_buildandcrush",94,4}, -#line 58 "thingdef_specials.gperf" - {"plat_perpetualraise",60,3}, -#line 55 "thingdef_specials.gperf" - {"plat_downbyvalue",63,4}, -#line 41 "thingdef_specials.gperf" - {"floor_crushstop",46,1}, -#line 130 "thingdef_specials.gperf" - {"plat_perpetualraiselip",207,4}, -#line 24 "thingdef_specials.gperf" - {"door_open",11,2}, -#line 71 "thingdef_specials.gperf" - {"sector_changesound",140,2}, -#line 176 "thingdef_specials.gperf" - {"plat_upnearestwaitdownstay",172,3}, - {(char*)0}, {(char*)0}, -#line 156 "thingdef_specials.gperf" - {"floor_raisebytexture",240,2}, -#line 137 "thingdef_specials.gperf" - {"stairs_buildupdoom",217,5}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, -#line 159 "thingdef_specials.gperf" - {"exit_normal",243,1}, -#line 154 "thingdef_specials.gperf" - {"floor_raisetolowestceiling",238,2}, -#line 151 "thingdef_specials.gperf" - {"floor_transfertrigger",235,1}, - {(char*)0}, {(char*)0}, -#line 179 "thingdef_specials.gperf" - {"startconversation",18,1,2}, - {(char*)0}, -#line 85 "thingdef_specials.gperf" - {"thing_projectile",134,5}, - {(char*)0}, {(char*)0}, -#line 150 "thingdef_specials.gperf" - {"light_maxneighbor",234,1}, -#line 163 "thingdef_specials.gperf" - {"elevator_lowertonearest",247,2}, - {(char*)0}, -#line 64 "thingdef_specials.gperf" - {"polyobj_doorswing",7,4}, -#line 161 "thingdef_specials.gperf" - {"elevator_raisetonearest",245,2}, -#line 54 "thingdef_specials.gperf" - {"plat_downwaitupstay",62,3}, -#line 174 "thingdef_specials.gperf" - {"teleport_zombiechanger",39,2}, - {(char*)0}, -#line 129 "thingdef_specials.gperf" - {"plat_downwaitupstaylip",206,4}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, -#line 95 "thingdef_specials.gperf" - {"thing_damage",119,2,3}, -#line 86 "thingdef_specials.gperf" - {"thing_projectilegravity",136,5}, -#line 27 "thingdef_specials.gperf" - {"floor_lowerbyvalue",20,3}, - {(char*)0}, -#line 29 "thingdef_specials.gperf" - {"floor_lowerinstant",66,3}, -#line 32 "thingdef_specials.gperf" - {"floor_lowertonearest",22,2}, - {(char*)0}, {(char*)0}, -#line 28 "thingdef_specials.gperf" - {"floor_lowerbyvaluetimes8",36,3}, -#line 103 "thingdef_specials.gperf" - {"thing_projectileaimed",178,4,5}, - {(char*)0}, -#line 166 "thingdef_specials.gperf" - {"floor_donut",250,3}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, -#line 22 "thingdef_specials.gperf" - {"ceiling_movetovaluetimes8",69,4}, - {(char*)0}, -#line 40 "thingdef_specials.gperf" - {"floorandceiling_raisebyvalue",96,3}, -#line 167 "thingdef_specials.gperf" - {"floorandceiling_lowerraise",251,3}, -#line 152 "thingdef_specials.gperf" - {"floor_transfernumeric",236,1}, -#line 39 "thingdef_specials.gperf" - {"floorandceiling_lowerbyvalue",95,3}, - {(char*)0}, {(char*)0}, {(char*)0}, -#line 34 "thingdef_specials.gperf" - {"floor_raisebyvalue",23,3}, - {(char*)0}, -#line 36 "thingdef_specials.gperf" - {"floor_raiseinstant",67,3}, -#line 38 "thingdef_specials.gperf" - {"floor_raisetonearest",25,2}, -#line 155 "thingdef_specials.gperf" - {"floor_raisebyvaluetxty",239,3}, - {(char*)0}, -#line 35 "thingdef_specials.gperf" - {"floor_raisebyvaluetimes8",35,3}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, -#line 66 "thingdef_specials.gperf" - {"polyobj_or_movetimes8",93,4}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, -#line 26 "thingdef_specials.gperf" - {"door_lockedraise",13,4}, - {(char*)0}, -#line 60 "thingdef_specials.gperf" - {"polyobj_movetimes8",6,4}, - {(char*)0}, -#line 149 "thingdef_specials.gperf" - {"light_minneighbor",233,1}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, {(char*)0}, -#line 147 "thingdef_specials.gperf" - {"plat_toggleceiling",231,1}, - {(char*)0}, {(char*)0}, -#line 158 "thingdef_specials.gperf" - {"floor_lowertohighest",242,3}, - {(char*)0}, -#line 172 "thingdef_specials.gperf" - {"door_animated",14,3}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, -#line 30 "thingdef_specials.gperf" - {"floor_movetovaluetimes8",68,4}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, -#line 33 "thingdef_specials.gperf" - {"floor_raiseandcrush",28,3}, - {(char*)0}, -#line 37 "thingdef_specials.gperf" - {"floor_raisetohighest",24,2}, - {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0}, - {(char*)0}, -#line 100 "thingdef_specials.gperf" - {"thing_projectileintercept",175,5} - }; - - if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) - { - register int key = specialhash (str, len); - - if (key <= MAX_HASH_VALUE && key >= 0) - { - register const char *s = wordlist[key].name; - - if (s && *str == *s && !strcmp (str + 1, s + 1)) - return &wordlist[key]; - } - } - return 0; -} diff --git a/src/w_wad.cpp b/src/w_wad.cpp index b2673a86b0..7c53db2b7e 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -916,7 +916,7 @@ int FWadCollection::GetNumForName (const char *name, int space) // //========================================================================== -int FWadCollection::CheckNumForFullName (const char *name) +int FWadCollection::CheckNumForFullName (const char *name, bool trynormal) { WORD i; @@ -932,7 +932,13 @@ int FWadCollection::CheckNumForFullName (const char *name) i = NextLumpIndex_FullName[i]; } - return i != NULL_INDEX ? i : -1; + if (i != NULL_INDEX) return i; + + if (trynormal && strlen(name) <= 8 && !strpbrk(name, "./")) + { + return CheckNumForName(name, ns_global); + } + return -1; } int FWadCollection::CheckNumForFullName (const char *name, int wadnum) diff --git a/src/w_wad.h b/src/w_wad.h index 7cd148343a..0273a318ab 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -181,7 +181,7 @@ public: inline int GetNumForName (const BYTE *name) { return GetNumForName ((const char *)name); } inline int GetNumForName (const BYTE *name, int ns) { return GetNumForName ((const char *)name, ns); } - int CheckNumForFullName (const char *name); + int CheckNumForFullName (const char *name, bool trynormal = false); int CheckNumForFullName (const char *name, int wadfile); int GetNumForFullName (const char *name); diff --git a/src/xlat/parse_xlat.cpp b/src/xlat/parse_xlat.cpp new file mode 100644 index 0000000000..748a41f304 --- /dev/null +++ b/src/xlat/parse_xlat.cpp @@ -0,0 +1,464 @@ +/* +** parse_xlat.cpp +** Translation definition compiler +** +**--------------------------------------------------------------------------- +** Copyright 1998-2008 Randy Heit +** Copyright 2008 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ + + +#include "doomtype.h" +#include "tarray.h" +#include "w_wad.h" +#include "c_console.h" +#include "p_lnspec.h" +#include "info.h" +#include "gi.h" +#include "xlat_parser.h" +#include "xlat.h" + +TAutoGrowArray SimpleLineTranslations; +FBoomTranslator Boomish[MAX_BOOMISH]; +int NumBoomish; + +// Token types not used in the grammar +enum +{ + INCLUDE=128, + STRING, +}; + + +struct Symbol +{ + int Value; + char Sym[80]; +}; + +union XlatToken +{ + int val; + char sym[80]; + char string[80]; + Symbol *symval; +}; + +struct SpecialArgs +{ + int addflags; + int args[5]; +}; + +struct ListFilter +{ + WORD filter; + BYTE value; +}; + +struct MoreFilters +{ + MoreFilters *next; + ListFilter filter; +}; + +struct MoreLines +{ + MoreLines *next; + FBoomArg arg; +}; + +struct ParseBoomArg +{ + BYTE constant; + WORD mask; + MoreFilters *filters; +}; + + +struct XlatParseContext +{ + TArray symbols; + int SourceLine; + const char *SourceFile; + int EnumVal; + + XlatParseContext() + { + SourceLine = 0; + SourceFile = NULL; + } + + //========================================================================== + // + // + // + //========================================================================== + void AddSym (char *sym, int val) + { + Symbol syme; + syme.Value = val; + strncpy (syme.Sym, sym, 79); + syme.Sym[79]=0; + symbols.Push(syme); + } + + //========================================================================== + // + // + // + //========================================================================== + bool FindSym (char *sym, Symbol **val) + { + for(unsigned i=0;i= 0; i--) + { + if (strcmp (tok, tokens[i]) == 0) + { + *type = types[i]; + return 1; + } + } + return 0; + } + + //========================================================================== + // + // + // + //========================================================================== + int GetToken (char *&sourcep, XlatToken *yylval) + { + char token[80]; + int toksize; + int c; + + loop: + while (isspace (c = *sourcep++) && c != 0) + { + if (c == '\n') + SourceLine++; + } + + if (c == 0) + { + return 0; + } + if (isdigit (c)) + { + int buildup = c - '0'; + if (c == '0') + { + c = *sourcep++; + if (c == 'x' || c == 'X') + { + for (;;) + { + c = *sourcep++; + if (isdigit (c)) + { + buildup = (buildup<<4) + c - '0'; + } + else if (c >= 'a' && c <= 'f') + { + buildup = (buildup<<4) + c - 'a' + 10; + } + else if (c >= 'A' && c <= 'F') + { + buildup = (buildup<<4) + c - 'A' + 10; + } + else + { + sourcep--; + yylval->val = buildup; + return NUM; + } + } + } + else + { + sourcep--; + } + } + while (isdigit (c = *sourcep++)) + { + buildup = buildup*10 + c - '0'; + } + sourcep--; + yylval->val = buildup; + return NUM; + } + if (isalpha (c)) + { + int buildup = 0; + + token[0] = c; + toksize = 1; + while (toksize < 79 && (isalnum (c = *sourcep++) || c == '_')) + { + token[toksize++] = c; + } + token[toksize] = 0; + if (toksize == 79 && isalnum (c)) + { + while (isalnum (c = *sourcep++)) + ; + } + sourcep--; + if (FindToken (token, &buildup)) + { + return buildup; + } + if (FindSym (token, &yylval->symval)) + { + return SYMNUM; + } + if ((yylval->val = P_FindLineSpecial(token)) != 0) + { + return NUM; + } + strcpy (yylval->sym, token); + return SYM; + } + if (c == '/') + { + c = *sourcep++;; + if (c == '*') + { + for (;;) + { + while ((c = *sourcep++) != '*' && c != 0) + { + if (c == '\n') + SourceLine++; + } + if (c == 0) + return 0; + if ((c = *sourcep++) == '/') + goto loop; + if (c == 0) + return 0; + sourcep--; + } + } + else if (c == '/') + { + while ((c = *sourcep++) != '\n' && c != 0) + ; + if (c == '\n') + SourceLine++; + else if (c == EOF) + return 0; + goto loop; + } + else + { + sourcep--; + return DIVIDE; + } + } + if (c == '"') + { + int tokensize = 0; + while ((c = *sourcep++) != '"' && c != EOF) + { + yylval->string[tokensize++] = c; + } + yylval->string[tokensize] = 0; + return STRING; + } + if (c == '|') + { + c = *sourcep++; + if (c == '=') + return OR_EQUAL; + sourcep--; + return OR; + } + switch (c) + { + case '^': return XOR; + case '&': return AND; + case '-': return MINUS; + case '+': return PLUS; + case '*': return MULTIPLY; + case '(': return LPAREN; + case ')': return RPAREN; + case ',': return COMMA; + case '{': return LBRACE; + case '}': return RBRACE; + case '=': return EQUALS; + //case ';': return SEMICOLON; + case ':': return COLON; + case '[': return LBRACKET; + case ']': return RBRACKET; + default: return 0; + } + } + + int PrintError (char *s) + { + if (SourceFile != NULL) + Printf ("%s, line %d: %s\n", SourceFile, SourceLine, s); + else + Printf ("%s\n", s); + return 0; + } + + +}; + +#include "xlat_parser.c" + +//========================================================================== +// +// +// +//========================================================================== + +void ParseXlatLump(const char *lumpname, void *pParser, XlatParseContext *context) +{ + int tokentype; + int SavedSourceLine = context->SourceLine; + const char *SavedSourceFile = context->SourceFile; + XlatToken token; + + int lumpno = Wads.CheckNumForFullName(lumpname, true); + + if (lumpno == -1) + { + Printf ("%s, line %d: Lump '%s' not found\n", context->SourceFile, context->SourceLine, lumpname); + return; + } + + // Read the lump into a buffer and add a 0-terminator + int lumplen = Wads.LumpLength(lumpno); + char *lumpdata = new char[lumplen+1]; + Wads.ReadLump(lumpno, lumpdata); + lumpdata[lumplen] = 0; + + context->SourceLine = 0; + context->SourceFile = lumpname; + + char *sourcep = lumpdata; + while (tokentype = context->GetToken(sourcep, &token)) + { + // It is much easier to handle include statements outside the main parser. + if (tokentype == INCLUDE) + { + if (context->GetToken(sourcep, &token) != STRING) + { + Printf("%s, line %d: Include: String parameter expected\n", context->SourceFile, context->SourceLine); + return; + } + ParseXlatLump(token.string, pParser, context); + } + else + { + XlatParse(pParser, tokentype, token, context); + } + } + delete [] lumpdata; + context->SourceLine = SavedSourceLine; + context->SourceFile = SavedSourceFile; +} + + +//========================================================================== +// +// +// +//========================================================================== + +void ParseXlat(const char *lumpname) +{ + void *pParser = XlatParseAlloc(malloc); + + XlatParseContext context; + + ParseXlatLump(lumpname, pParser, &context); + XlatToken tok; + tok.val=0; + XlatParse(pParser, 0, tok, &context); + XlatParseFree(pParser, free ); +} + +//========================================================================== +// +// +// +//========================================================================== + +AT_GAME_SET(Translators) +{ + if (gameinfo.gametype == GAME_Doom) + { + ParseXlat("xlat/doom.txt"); + } + else if (gameinfo.gametype == GAME_Strife) + { + ParseXlat("xlat/strife.txt"); + } + else + { + ParseXlat("xlat/heretic.txt"); + } +} + + diff --git a/src/xlat/xlat.h b/src/xlat/xlat.h new file mode 100644 index 0000000000..29c80a183e --- /dev/null +++ b/src/xlat/xlat.h @@ -0,0 +1,67 @@ +#ifndef __XLAT_H +#define __XLAT_H + +#include "doomtype.h" +#include "tarray.h" + +enum +{ + LINETRANS_HASTAGAT1 = (1<<5), // (tag, x, x, x, x) + LINETRANS_HASTAGAT2 = (2<<5), // (x, tag, x, x, x) + LINETRANS_HASTAGAT3 = (3<<5), // (x, x, tag, x, x) + LINETRANS_HASTAGAT4 = (4<<5), // (x, x, x, tag, x) + LINETRANS_HASTAGAT5 = (5<<5), // (x, x, x, x, tag) + + LINETRANS_HAS2TAGS = (7<<5), // (tag, tag, x, x, x) +}; + +struct FLineTrans +{ + int special; + int flags; + int args[5]; + + FLineTrans() + { + special = flags = args[0] = args[1] = args[2] = args[3] = args[4] = 0; + } + FLineTrans(int _special, int _flags, int arg1, int arg2, int arg3, int arg4, int arg5) + { + special = _special; + flags = _flags; + args[0] = arg1; + args[1] = arg2; + args[2] = arg3; + args[3] = arg4; + args[4] = arg5; + } +}; + + +#define MAX_BOOMISH 16 + +struct FBoomArg +{ + bool bOrExisting; + bool bUseConstant; + BYTE ListSize; + BYTE ArgNum; + BYTE ConstantValue; + WORD AndValue; + WORD ResultFilter[15]; + BYTE ResultValue[15]; +}; + +struct FBoomTranslator +{ + WORD FirstLinetype; + WORD LastLinetype; + BYTE NewSpecial; + TArray Args; +} ; + +extern TAutoGrowArray SimpleLineTranslations; +extern FBoomTranslator Boomish[MAX_BOOMISH]; +extern int NumBoomish; + +#endif \ No newline at end of file diff --git a/src/xlat/xlat_parser.c b/src/xlat/xlat_parser.c new file mode 100644 index 0000000000..1efb872a93 --- /dev/null +++ b/src/xlat/xlat_parser.c @@ -0,0 +1,1806 @@ +/* Driver template for the LEMON parser generator. +** The author disclaims copyright to this source code. +*/ +/* First off, code is included which follows the "include" declaration +** in the input file. */ +#include +#include +#include +/* Next is all token values, in a form suitable for use by makeheaders. +** This section will be null unless lemon is run with the -m switch. +*/ +/* +** These constants (all generated automatically by the parser generator) +** specify the various kinds of tokens (terminals) that the parser +** understands. +** +** Each symbol here is a terminal symbol in the grammar. +*/ +/* Make sure the INTERFACE macro is defined. +*/ +#ifndef INTERFACE +# define INTERFACE 1 +#endif +/* The next thing included is series of defines which control +** various aspects of the generated parser. +** YYCODETYPE is the data type used for storing terminal +** and nonterminal numbers. "unsigned char" is +** used if there are fewer than 250 terminals +** and nonterminals. "int" is used otherwise. +** YYNOCODE is a number of type YYCODETYPE which corresponds +** to no legal terminal or nonterminal number. This +** number is used to fill in empty slots of the hash +** table. +** YYFALLBACK If defined, this indicates that one or more tokens +** have fall-back values which should be used if the +** original value of the token will not parse. +** YYACTIONTYPE is the data type used for storing terminal +** and nonterminal numbers. "unsigned char" is +** used if there are fewer than 250 rules and +** states combined. "int" is used otherwise. +** XlatParseTOKENTYPE is the data type used for minor tokens given +** directly to the parser from the tokenizer. +** YYMINORTYPE is the data type used for all minor tokens. +** This is typically a union of many types, one of +** which is XlatParseTOKENTYPE. The entry in the union +** for base tokens is called "yy0". +** YYSTACKDEPTH is the maximum depth of the parser's stack. If +** zero the stack is dynamically sized using realloc() +** XlatParseARG_SDECL A static variable declaration for the %extra_argument +** XlatParseARG_PDECL A parameter declaration for the %extra_argument +** XlatParseARG_STORE Code to store %extra_argument into yypParser +** XlatParseARG_FETCH Code to extract %extra_argument from yypParser +** YYNSTATE the combined number of states. +** YYNRULE the number of rules in the grammar +** YYERRORSYMBOL is the code number of the error symbol. If not +** defined, then do no error processing. +*/ +#define YYCODETYPE unsigned char +#define YYNOCODE 52 +#define YYACTIONTYPE unsigned char +#define XlatParseTOKENTYPE XlatToken +typedef union { + XlatParseTOKENTYPE yy0; + ListFilter yy11; + SpecialArgs yy15; + FBoomArg yy20; + MoreFilters * yy39; + ParseBoomArg yy40; + MoreLines * yy81; + int yy94; +} YYMINORTYPE; +#ifndef YYSTACKDEPTH +#define YYSTACKDEPTH 100 +#endif +#define XlatParseARG_SDECL XlatParseContext *context ; +#define XlatParseARG_PDECL , XlatParseContext *context +#define XlatParseARG_FETCH XlatParseContext *context = yypParser->context +#define XlatParseARG_STORE yypParser->context = context +#define YYNSTATE 131 +#define YYNRULE 70 +#define YY_NO_ACTION (YYNSTATE+YYNRULE+2) +#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) +#define YY_ERROR_ACTION (YYNSTATE+YYNRULE) + +/* Next are that tables used to determine what action to take based on the +** current state and lookahead token. These tables are used to implement +** functions that take a state number and lookahead value and return an +** action integer. +** +** Suppose the action integer is N. Then the action is determined as +** follows +** +** 0 <= N < YYNSTATE Shift N. That is, push the lookahead +** token onto the stack and goto state N. +** +** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE. +** +** N == YYNSTATE+YYNRULE A syntax error has occurred. +** +** N == YYNSTATE+YYNRULE+1 The parser accepts its input. +** +** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused +** slots in the yy_action[] table. +** +** The action table is constructed as a single large table named yy_action[]. +** Given state S and lookahead X, the action is computed as +** +** yy_action[ yy_shift_ofst[S] + X ] +** +** If the index value yy_shift_ofst[S]+X is out of range or if the value +** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] +** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table +** and that yy_default[S] should be used instead. +** +** The formula above is for computing the action when the lookahead is +** a terminal symbol. If the lookahead is a non-terminal (as occurs after +** a reduce action) then the yy_reduce_ofst[] array is used in place of +** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of +** YY_SHIFT_USE_DFLT. +** +** The following are the tables generated in this section: +** +** yy_action[] A single table containing all actions. +** yy_lookahead[] A table containing the lookahead for each entry in +** yy_action. Used to detect hash collisions. +** yy_shift_ofst[] For each state, the offset into yy_action for +** shifting terminals. +** yy_reduce_ofst[] For each state, the offset into yy_action for +** shifting non-terminals after a reduce. +** yy_default[] Default action for each state. +*/ +static const YYACTIONTYPE yy_action[] = { + /* 0 */ 131, 112, 25, 29, 17, 25, 63, 111, 109, 27, + /* 10 */ 111, 109, 27, 123, 82, 104, 90, 96, 84, 45, + /* 20 */ 2, 92, 24, 88, 90, 19, 23, 21, 36, 40, + /* 30 */ 29, 17, 19, 23, 21, 36, 40, 29, 17, 45, + /* 40 */ 2, 110, 14, 126, 127, 128, 129, 130, 67, 12, + /* 50 */ 202, 1, 19, 23, 21, 36, 40, 29, 17, 19, + /* 60 */ 23, 21, 36, 40, 29, 17, 49, 25, 55, 16, + /* 70 */ 87, 49, 111, 109, 27, 86, 34, 89, 8, 19, + /* 80 */ 23, 21, 36, 40, 29, 17, 19, 23, 21, 36, + /* 90 */ 40, 29, 17, 124, 19, 23, 21, 36, 40, 29, + /* 100 */ 17, 20, 125, 37, 6, 54, 46, 39, 100, 103, + /* 110 */ 19, 23, 21, 36, 40, 29, 17, 19, 23, 21, + /* 120 */ 36, 40, 29, 17, 5, 11, 18, 13, 21, 36, + /* 130 */ 40, 29, 17, 53, 28, 57, 43, 19, 23, 21, + /* 140 */ 36, 40, 29, 17, 36, 40, 29, 17, 107, 108, + /* 150 */ 48, 19, 23, 21, 36, 40, 29, 17, 19, 23, + /* 160 */ 21, 36, 40, 29, 17, 25, 3, 56, 38, 51, + /* 170 */ 111, 109, 27, 9, 95, 81, 30, 64, 106, 19, + /* 180 */ 23, 21, 36, 40, 29, 17, 19, 23, 21, 36, + /* 190 */ 40, 29, 17, 120, 69, 118, 42, 61, 70, 19, + /* 200 */ 23, 21, 36, 40, 29, 17, 4, 19, 23, 21, + /* 210 */ 36, 40, 29, 17, 93, 66, 32, 31, 91, 19, + /* 220 */ 23, 21, 36, 40, 29, 17, 19, 23, 21, 36, + /* 230 */ 40, 29, 17, 41, 52, 35, 26, 98, 119, 51, + /* 240 */ 101, 73, 58, 33, 95, 122, 19, 23, 21, 36, + /* 250 */ 40, 29, 17, 19, 23, 21, 36, 40, 29, 17, + /* 260 */ 19, 23, 21, 36, 40, 29, 17, 97, 75, 79, + /* 270 */ 22, 105, 50, 19, 23, 21, 36, 40, 29, 17, + /* 280 */ 19, 23, 21, 36, 40, 29, 17, 77, 68, 74, + /* 290 */ 15, 121, 116, 115, 114, 113, 65, 10, 23, 21, + /* 300 */ 36, 40, 29, 17, 25, 78, 60, 25, 76, 111, + /* 310 */ 109, 27, 111, 109, 27, 72, 59, 7, 62, 25, + /* 320 */ 85, 102, 80, 94, 111, 109, 27, 47, 71, 44, + /* 330 */ 203, 25, 203, 203, 203, 83, 111, 109, 27, 203, + /* 340 */ 203, 203, 203, 25, 203, 203, 203, 99, 111, 109, + /* 350 */ 27, 203, 203, 203, 203, 203, 203, 203, 203, 117, +}; +static const YYCODETYPE yy_lookahead[] = { + /* 0 */ 0, 1, 5, 7, 8, 5, 39, 10, 11, 12, + /* 10 */ 10, 11, 12, 46, 14, 41, 42, 17, 21, 48, + /* 20 */ 49, 50, 22, 41, 42, 2, 3, 4, 5, 6, + /* 30 */ 7, 8, 2, 3, 4, 5, 6, 7, 8, 48, + /* 40 */ 49, 50, 19, 24, 25, 26, 27, 28, 39, 19, + /* 50 */ 32, 33, 2, 3, 4, 5, 6, 7, 8, 2, + /* 60 */ 3, 4, 5, 6, 7, 8, 39, 5, 39, 19, + /* 70 */ 43, 39, 10, 11, 12, 43, 19, 15, 47, 2, + /* 80 */ 3, 4, 5, 6, 7, 8, 2, 3, 4, 5, + /* 90 */ 6, 7, 8, 20, 2, 3, 4, 5, 6, 7, + /* 100 */ 8, 12, 29, 19, 12, 39, 39, 30, 18, 39, + /* 110 */ 2, 3, 4, 5, 6, 7, 8, 2, 3, 4, + /* 120 */ 5, 6, 7, 8, 19, 19, 19, 19, 4, 5, + /* 130 */ 6, 7, 8, 39, 19, 39, 20, 2, 3, 4, + /* 140 */ 5, 6, 7, 8, 5, 6, 7, 8, 13, 16, + /* 150 */ 39, 2, 3, 4, 5, 6, 7, 8, 2, 3, + /* 160 */ 4, 5, 6, 7, 8, 5, 18, 39, 19, 39, + /* 170 */ 10, 11, 12, 19, 44, 45, 20, 39, 16, 2, + /* 180 */ 3, 4, 5, 6, 7, 8, 2, 3, 4, 5, + /* 190 */ 6, 7, 8, 13, 39, 13, 19, 39, 39, 2, + /* 200 */ 3, 4, 5, 6, 7, 8, 22, 2, 3, 4, + /* 210 */ 5, 6, 7, 8, 15, 39, 19, 19, 13, 2, + /* 220 */ 3, 4, 5, 6, 7, 8, 2, 3, 4, 5, + /* 230 */ 6, 7, 8, 19, 39, 19, 19, 15, 23, 39, + /* 240 */ 39, 39, 39, 19, 44, 45, 2, 3, 4, 5, + /* 250 */ 6, 7, 8, 2, 3, 4, 5, 6, 7, 8, + /* 260 */ 2, 3, 4, 5, 6, 7, 8, 23, 39, 39, + /* 270 */ 19, 13, 39, 2, 3, 4, 5, 6, 7, 8, + /* 280 */ 2, 3, 4, 5, 6, 7, 8, 39, 39, 39, + /* 290 */ 19, 34, 35, 36, 37, 38, 39, 40, 3, 4, + /* 300 */ 5, 6, 7, 8, 5, 39, 39, 5, 39, 10, + /* 310 */ 11, 12, 10, 11, 12, 39, 39, 12, 39, 5, + /* 320 */ 21, 39, 39, 21, 10, 11, 12, 39, 39, 12, + /* 330 */ 51, 5, 51, 51, 51, 21, 10, 11, 12, 51, + /* 340 */ 51, 51, 51, 5, 51, 51, 51, 21, 10, 11, + /* 350 */ 12, 51, 51, 51, 51, 51, 51, 51, 51, 21, +}; +#define YY_SHIFT_USE_DFLT (-5) +#define YY_SHIFT_MAX 99 +static const short yy_shift_ofst[] = { + /* 0 */ -5, 0, 19, 19, 160, 160, 326, 326, 160, 199, + /* 10 */ 199, 302, 299, 62, -3, 338, 314, 160, 160, 160, + /* 20 */ 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + /* 30 */ 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + /* 40 */ 160, 160, 160, 160, 160, 73, 271, 23, 50, 30, + /* 50 */ 57, 77, 84, 92, 108, 115, 258, 251, 244, 224, + /* 60 */ 217, 205, 197, 184, 177, 156, 149, 135, 278, 278, + /* 70 */ 278, 278, 278, 278, 278, 278, 295, 124, 139, -4, + /* 80 */ -4, 215, 222, 216, 214, 198, 182, 180, 162, 305, + /* 90 */ 154, 148, 133, 116, 107, 105, 90, 89, 317, 106, +}; +#define YY_REDUCE_USE_DFLT (-34) +#define YY_REDUCE_MAX 45 +static const short yy_reduce_ofst[] = { + /* 0 */ 18, 257, -9, -29, 130, 200, 27, 32, -33, -26, + /* 10 */ -18, 138, 111, 94, 67, 276, 288, 282, 277, 269, + /* 20 */ 267, 266, 249, 248, 203, 201, 158, 128, 96, 70, + /* 30 */ 66, 29, 159, 195, 229, 233, 283, 289, 279, 250, + /* 40 */ 230, 202, 176, 155, 9, 31, +}; +static const YYACTIONTYPE yy_default[] = { + /* 0 */ 132, 201, 186, 186, 201, 201, 160, 160, 201, 153, + /* 10 */ 153, 201, 201, 201, 201, 201, 201, 201, 201, 201, + /* 20 */ 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, + /* 30 */ 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, + /* 40 */ 201, 201, 201, 201, 201, 201, 173, 172, 171, 170, + /* 50 */ 180, 201, 168, 201, 201, 176, 201, 177, 201, 167, + /* 60 */ 201, 201, 164, 196, 162, 201, 163, 201, 178, 157, + /* 70 */ 165, 169, 174, 183, 200, 181, 145, 147, 146, 141, + /* 80 */ 142, 201, 201, 179, 182, 175, 201, 201, 201, 201, + /* 90 */ 154, 201, 201, 156, 166, 198, 201, 201, 201, 161, + /* 100 */ 152, 148, 144, 143, 155, 149, 151, 150, 185, 140, + /* 110 */ 187, 139, 138, 137, 136, 135, 134, 184, 159, 197, + /* 120 */ 158, 133, 199, 188, 194, 195, 189, 190, 191, 192, + /* 130 */ 193, +}; +#define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0])) + +/* The next table maps tokens into fallback tokens. If a construct +** like the following: +** +** %fallback ID X Y Z. +** +** appears in the grammer, then ID becomes a fallback token for X, Y, +** and Z. Whenever one of the tokens X, Y, or Z is input to the parser +** but it does not parse, the type of the token is changed to ID and +** the parse is retried before an error is thrown. +*/ +#ifdef YYFALLBACK +static const YYCODETYPE yyFallback[] = { +}; +#endif /* YYFALLBACK */ + +/* The following structure represents a single element of the +** parser's stack. Information stored includes: +** +** + The state number for the parser at this level of the stack. +** +** + The value of the token stored at this level of the stack. +** (In other words, the "major" token.) +** +** + The semantic value stored at this level of the stack. This is +** the information used by the action routines in the grammar. +** It is sometimes called the "minor" token. +*/ +struct yyStackEntry { + int stateno; /* The state-number */ + int major; /* The major token value. This is the code + ** number for the token at this stack level */ + YYMINORTYPE minor; /* The user-supplied minor token value. This + ** is the value of the token */ +}; +typedef struct yyStackEntry yyStackEntry; + +/* The state of the parser is completely contained in an instance of +** the following structure */ +struct yyParser { + int yyidx; /* Index of top element in stack */ + int yyerrcnt; /* Shifts left before out of the error */ + XlatParseARG_SDECL /* A place to hold %extra_argument */ +#if YYSTACKDEPTH<=0 + int yystksz; /* Current side of the stack */ + yyStackEntry *yystack; /* The parser's stack */ +#else + yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ +#endif +}; +typedef struct yyParser yyParser; + +#ifndef NDEBUG +#include +static FILE *yyTraceFILE = 0; +static char *yyTracePrompt = 0; +#endif /* NDEBUG */ + +#ifndef NDEBUG +/* +** Turn parser tracing on by giving a stream to which to write the trace +** and a prompt to preface each trace message. Tracing is turned off +** by making either argument NULL +** +** Inputs: +**
    +**
  • A FILE* to which trace output should be written. +** If NULL, then tracing is turned off. +**
  • A prefix string written at the beginning of every +** line of trace output. If NULL, then tracing is +** turned off. +**
+** +** Outputs: +** None. +*/ +void XlatParseTrace(FILE *TraceFILE, char *zTracePrompt){ + yyTraceFILE = TraceFILE; + yyTracePrompt = zTracePrompt; + if( yyTraceFILE==0 ) yyTracePrompt = 0; + else if( yyTracePrompt==0 ) yyTraceFILE = 0; +} +#endif /* NDEBUG */ + +#ifndef NDEBUG +/* For tracing shifts, the names of all terminals and nonterminals +** are required. The following table supplies these names */ +static const char *const yyTokenName[] = { + "$", "NOP", "OR", "XOR", + "AND", "MINUS", "PLUS", "MULTIPLY", + "DIVIDE", "NEG", "NUM", "SYMNUM", + "LPAREN", "RPAREN", "DEFINE", "SYM", + "RBRACE", "ENUM", "LBRACE", "COMMA", + "EQUALS", "TAG", "LBRACKET", "RBRACKET", + "FLAGS", "ARG2", "ARG3", "ARG4", + "ARG5", "OR_EQUAL", "COLON", "error", + "main", "translation_unit", "external_declaration", "define_statement", + "enum_statement", "linetype_declaration", "boom_declaration", "exp", + "enum_open", "enum_list", "single_enum", "special_args", + "list_val", "arg_list", "boom_args", "boom_op", + "boom_selector", "boom_line", "boom_body", +}; +#endif /* NDEBUG */ + +#ifndef NDEBUG +/* For tracing reduce actions, the names of all rules are required. +*/ +static const char *const yyRuleName[] = { + /* 0 */ "main ::= translation_unit", + /* 1 */ "translation_unit ::=", + /* 2 */ "translation_unit ::= translation_unit external_declaration", + /* 3 */ "external_declaration ::= define_statement", + /* 4 */ "external_declaration ::= enum_statement", + /* 5 */ "external_declaration ::= linetype_declaration", + /* 6 */ "external_declaration ::= boom_declaration", + /* 7 */ "external_declaration ::= NOP", + /* 8 */ "exp ::= NUM", + /* 9 */ "exp ::= SYMNUM", + /* 10 */ "exp ::= exp PLUS exp", + /* 11 */ "exp ::= exp MINUS exp", + /* 12 */ "exp ::= exp MULTIPLY exp", + /* 13 */ "exp ::= exp DIVIDE exp", + /* 14 */ "exp ::= exp OR exp", + /* 15 */ "exp ::= exp AND exp", + /* 16 */ "exp ::= exp XOR exp", + /* 17 */ "exp ::= MINUS exp", + /* 18 */ "exp ::= LPAREN exp RPAREN", + /* 19 */ "define_statement ::= DEFINE SYM LPAREN exp RPAREN", + /* 20 */ "enum_statement ::= enum_open enum_list RBRACE", + /* 21 */ "enum_open ::= ENUM LBRACE", + /* 22 */ "enum_list ::=", + /* 23 */ "enum_list ::= single_enum", + /* 24 */ "enum_list ::= single_enum COMMA enum_list", + /* 25 */ "single_enum ::= SYM", + /* 26 */ "single_enum ::= SYM EQUALS exp", + /* 27 */ "linetype_declaration ::= exp EQUALS exp COMMA exp LPAREN special_args RPAREN", + /* 28 */ "linetype_declaration ::= exp EQUALS exp COMMA SYM LPAREN special_args RPAREN", + /* 29 */ "special_args ::=", + /* 30 */ "special_args ::= TAG", + /* 31 */ "special_args ::= TAG COMMA exp", + /* 32 */ "special_args ::= TAG COMMA exp COMMA exp", + /* 33 */ "special_args ::= TAG COMMA exp COMMA exp COMMA exp", + /* 34 */ "special_args ::= TAG COMMA exp COMMA exp COMMA exp COMMA exp", + /* 35 */ "special_args ::= TAG COMMA TAG", + /* 36 */ "special_args ::= TAG COMMA TAG COMMA exp", + /* 37 */ "special_args ::= TAG COMMA TAG COMMA exp COMMA exp", + /* 38 */ "special_args ::= TAG COMMA TAG COMMA exp COMMA exp COMMA exp", + /* 39 */ "special_args ::= exp", + /* 40 */ "special_args ::= exp COMMA exp", + /* 41 */ "special_args ::= exp COMMA exp COMMA exp", + /* 42 */ "special_args ::= exp COMMA exp COMMA exp COMMA exp", + /* 43 */ "special_args ::= exp COMMA exp COMMA exp COMMA exp COMMA exp", + /* 44 */ "special_args ::= exp COMMA TAG", + /* 45 */ "special_args ::= exp COMMA TAG COMMA exp", + /* 46 */ "special_args ::= exp COMMA TAG COMMA exp COMMA exp", + /* 47 */ "special_args ::= exp COMMA TAG COMMA exp COMMA exp COMMA exp", + /* 48 */ "special_args ::= exp COMMA exp COMMA TAG", + /* 49 */ "special_args ::= exp COMMA exp COMMA TAG COMMA exp", + /* 50 */ "special_args ::= exp COMMA exp COMMA TAG COMMA exp COMMA exp", + /* 51 */ "special_args ::= exp COMMA exp COMMA exp COMMA TAG", + /* 52 */ "special_args ::= exp COMMA exp COMMA exp COMMA TAG COMMA exp", + /* 53 */ "special_args ::= exp COMMA exp COMMA exp COMMA exp COMMA TAG", + /* 54 */ "boom_declaration ::= LBRACKET exp RBRACKET LPAREN exp COMMA exp RPAREN LBRACE boom_body RBRACE", + /* 55 */ "boom_body ::=", + /* 56 */ "boom_body ::= boom_line boom_body", + /* 57 */ "boom_line ::= boom_selector boom_op boom_args", + /* 58 */ "boom_selector ::= FLAGS", + /* 59 */ "boom_selector ::= ARG2", + /* 60 */ "boom_selector ::= ARG3", + /* 61 */ "boom_selector ::= ARG4", + /* 62 */ "boom_selector ::= ARG5", + /* 63 */ "boom_op ::= EQUALS", + /* 64 */ "boom_op ::= OR_EQUAL", + /* 65 */ "boom_args ::= exp", + /* 66 */ "boom_args ::= exp LBRACKET arg_list RBRACKET", + /* 67 */ "arg_list ::= list_val", + /* 68 */ "arg_list ::= list_val COMMA arg_list", + /* 69 */ "list_val ::= exp COLON exp", +}; +#endif /* NDEBUG */ + +#if YYSTACKDEPTH<=0 +/* +** Try to increase the size of the parser stack. +*/ +static void yyGrowStack(yyParser *p){ + int newSize; + yyStackEntry *pNew; + + newSize = p->yystksz*2 + 100; + pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); + if( pNew ){ + p->yystack = pNew; + p->yystksz = newSize; +#ifndef NDEBUG + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sStack grows to %d entries!\n", + yyTracePrompt, p->yystksz); + } +#endif + } +} +#endif + +/* +** This function allocates a new parser. +** The only argument is a pointer to a function which works like +** malloc. +** +** Inputs: +** A pointer to the function used to allocate memory. +** +** Outputs: +** A pointer to a parser. This pointer is used in subsequent calls +** to XlatParse and XlatParseFree. +*/ +void *XlatParseAlloc(void *(*mallocProc)(size_t)){ + yyParser *pParser; + pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); + if( pParser ){ + pParser->yyidx = -1; +#if YYSTACKDEPTH<=0 + yyGrowStack(pParser); +#endif + } + return pParser; +} + +/* The following function deletes the value associated with a +** symbol. The symbol can be either a terminal or nonterminal. +** "yymajor" is the symbol code, and "yypminor" is a pointer to +** the value. +*/ +static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){ + switch( yymajor ){ + /* Here is inserted the actions which take place when a + ** terminal or non-terminal is destroyed. This can happen + ** when the symbol is popped from the stack during a + ** reduce or during error processing or when a parser is + ** being destroyed before it is finished parsing. + ** + ** Note: during a reduce, the only symbols destroyed are those + ** which appear on the RHS of the rule, but which are not used + ** inside the C code. + */ + case 1: /* NOP */ + case 2: /* OR */ + case 3: /* XOR */ + case 4: /* AND */ + case 5: /* MINUS */ + case 6: /* PLUS */ + case 7: /* MULTIPLY */ + case 8: /* DIVIDE */ + case 9: /* NEG */ + case 10: /* NUM */ + case 11: /* SYMNUM */ + case 12: /* LPAREN */ + case 13: /* RPAREN */ + case 14: /* DEFINE */ + case 15: /* SYM */ + case 16: /* RBRACE */ + case 17: /* ENUM */ + case 18: /* LBRACE */ + case 19: /* COMMA */ + case 20: /* EQUALS */ + case 21: /* TAG */ + case 22: /* LBRACKET */ + case 23: /* RBRACKET */ + case 24: /* FLAGS */ + case 25: /* ARG2 */ + case 26: /* ARG3 */ + case 27: /* ARG4 */ + case 28: /* ARG5 */ + case 29: /* OR_EQUAL */ + case 30: /* COLON */ +#line 3 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{} +#line 526 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + default: break; /* If no destructor action specified: do nothing */ + } +} + +/* +** Pop the parser's stack once. +** +** If there is a destructor routine associated with the token which +** is popped from the stack, then call it. +** +** Return the major token number for the symbol popped. +*/ +static int yy_pop_parser_stack(yyParser *pParser){ + YYCODETYPE yymajor; + yyStackEntry *yytos = &pParser->yystack[pParser->yyidx]; + + if( pParser->yyidx<0 ) return 0; +#ifndef NDEBUG + if( yyTraceFILE && pParser->yyidx>=0 ){ + fprintf(yyTraceFILE,"%sPopping %s\n", + yyTracePrompt, + yyTokenName[yytos->major]); + } +#endif + yymajor = yytos->major; + yy_destructor( yymajor, &yytos->minor); + pParser->yyidx--; + return yymajor; +} + +/* +** Deallocate and destroy a parser. Destructors are all called for +** all stack elements before shutting the parser down. +** +** Inputs: +**
    +**
  • A pointer to the parser. This should be a pointer +** obtained from XlatParseAlloc. +**
  • A pointer to a function used to reclaim memory obtained +** from malloc. +**
+*/ +void XlatParseFree( + void *p, /* The parser to be deleted */ + void (*freeProc)(void*) /* Function used to reclaim memory */ +){ + yyParser *pParser = (yyParser*)p; + if( pParser==0 ) return; + while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); +#if YYSTACKDEPTH<=0 + free(pParser->yystack); +#endif + (*freeProc)((void*)pParser); +} + +/* +** Find the appropriate action for a parser given the terminal +** look-ahead token iLookAhead. +** +** If the look-ahead token is YYNOCODE, then check to see if the action is +** independent of the look-ahead. If it is, return the action, otherwise +** return YY_NO_ACTION. +*/ +static int yy_find_shift_action( + yyParser *pParser, /* The parser */ + YYCODETYPE iLookAhead /* The look-ahead token */ +){ + int i; + int stateno = pParser->yystack[pParser->yyidx].stateno; + + if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){ + return yy_default[stateno]; + } + assert( iLookAhead!=YYNOCODE ); + i += iLookAhead; + if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ + if( iLookAhead>0 ){ +#ifdef YYFALLBACK + int iFallback; /* Fallback token */ + if( iLookAhead %s\n", + yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); + } +#endif + return yy_find_shift_action(pParser, iFallback); + } +#endif +#ifdef YYWILDCARD + { + int j = i - iLookAhead + YYWILDCARD; + if( j>=0 && j %s\n", + yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); + } +#endif /* NDEBUG */ + return yy_action[j]; + } + } +#endif /* YYWILDCARD */ + } + return yy_default[stateno]; + }else{ + return yy_action[i]; + } +} + +/* +** Find the appropriate action for a parser given the non-terminal +** look-ahead token iLookAhead. +** +** If the look-ahead token is YYNOCODE, then check to see if the action is +** independent of the look-ahead. If it is, return the action, otherwise +** return YY_NO_ACTION. +*/ +static int yy_find_reduce_action( + int stateno, /* Current state number */ + YYCODETYPE iLookAhead /* The look-ahead token */ +){ + int i; + if( stateno>YY_REDUCE_MAX || + (i = yy_reduce_ofst[stateno])==YY_REDUCE_USE_DFLT ){ + return yy_default[stateno]; + } + assert( i!=YY_REDUCE_USE_DFLT ); + assert( iLookAhead!=YYNOCODE ); + i += iLookAhead; + if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ + return yy_default[stateno]; + }else{ + return yy_action[i]; + } + return yy_action[i]; +} + +/* +** The following routine is called if the stack overflows. +*/ +static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){ + XlatParseARG_FETCH; + yypParser->yyidx--; +#ifndef NDEBUG + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); + } +#endif + while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); + /* Here code is inserted which will execute if the parser + ** stack every overflows */ + XlatParseARG_STORE; /* Suppress warning about unused %extra_argument var */ +} + +/* +** Perform a shift action. +*/ +static void yy_shift( + yyParser *yypParser, /* The parser to be shifted */ + int yyNewState, /* The new state to shift in */ + int yyMajor, /* The major token to shift in */ + YYMINORTYPE *yypMinor /* Pointer ot the minor token to shift in */ +){ + yyStackEntry *yytos; + yypParser->yyidx++; +#if YYSTACKDEPTH>0 + if( yypParser->yyidx>=YYSTACKDEPTH ){ + yyStackOverflow(yypParser, yypMinor); + return; + } +#else + if( yypParser->yyidx>=yypParser->yystksz ){ + yyGrowStack(yypParser); + if( yypParser->yyidx>=yypParser->yystksz ){ + yyStackOverflow(yypParser, yypMinor); + return; + } + } +#endif + yytos = &yypParser->yystack[yypParser->yyidx]; + yytos->stateno = yyNewState; + yytos->major = yyMajor; + yytos->minor = *yypMinor; +#ifndef NDEBUG + if( yyTraceFILE && yypParser->yyidx>0 ){ + int i; + fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState); + fprintf(yyTraceFILE,"%sStack:",yyTracePrompt); + for(i=1; i<=yypParser->yyidx; i++) + fprintf(yyTraceFILE," (%d)%s",yypParser->yystack[i].stateno,yyTokenName[yypParser->yystack[i].major]); + fprintf(yyTraceFILE,"\n"); + } +#endif +} + +/* The following table contains information about every rule that +** is used during the reduce. +*/ +static const struct { + YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ + unsigned char nrhs; /* Number of right-hand side symbols in the rule */ +} yyRuleInfo[] = { + { 32, 1 }, + { 33, 0 }, + { 33, 2 }, + { 34, 1 }, + { 34, 1 }, + { 34, 1 }, + { 34, 1 }, + { 34, 1 }, + { 39, 1 }, + { 39, 1 }, + { 39, 3 }, + { 39, 3 }, + { 39, 3 }, + { 39, 3 }, + { 39, 3 }, + { 39, 3 }, + { 39, 3 }, + { 39, 2 }, + { 39, 3 }, + { 35, 5 }, + { 36, 3 }, + { 40, 2 }, + { 41, 0 }, + { 41, 1 }, + { 41, 3 }, + { 42, 1 }, + { 42, 3 }, + { 37, 8 }, + { 37, 8 }, + { 43, 0 }, + { 43, 1 }, + { 43, 3 }, + { 43, 5 }, + { 43, 7 }, + { 43, 9 }, + { 43, 3 }, + { 43, 5 }, + { 43, 7 }, + { 43, 9 }, + { 43, 1 }, + { 43, 3 }, + { 43, 5 }, + { 43, 7 }, + { 43, 9 }, + { 43, 3 }, + { 43, 5 }, + { 43, 7 }, + { 43, 9 }, + { 43, 5 }, + { 43, 7 }, + { 43, 9 }, + { 43, 7 }, + { 43, 9 }, + { 43, 9 }, + { 38, 11 }, + { 50, 0 }, + { 50, 2 }, + { 49, 3 }, + { 48, 1 }, + { 48, 1 }, + { 48, 1 }, + { 48, 1 }, + { 48, 1 }, + { 47, 1 }, + { 47, 1 }, + { 46, 1 }, + { 46, 4 }, + { 45, 1 }, + { 45, 3 }, + { 44, 3 }, +}; + +static void yy_accept(yyParser*); /* Forward Declaration */ + +/* +** Perform a reduce action and the shift that must immediately +** follow the reduce. +*/ +static void yy_reduce( + yyParser *yypParser, /* The parser */ + int yyruleno /* Number of the rule by which to reduce */ +){ + int yygoto; /* The next state */ + int yyact; /* The next action */ + YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ + yyStackEntry *yymsp; /* The top of the parser's stack */ + int yysize; /* Amount to pop the stack */ + XlatParseARG_FETCH; + yymsp = &yypParser->yystack[yypParser->yyidx]; +#ifndef NDEBUG + if( yyTraceFILE && yyruleno>=0 + && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ + fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, + yyRuleName[yyruleno]); + } +#endif /* NDEBUG */ + + /* Silence complaints from purify about yygotominor being uninitialized + ** in some cases when it is copied into the stack after the following + ** switch. yygotominor is uninitialized when a rule reduces that does + ** not set the value of its left-hand side nonterminal. Leaving the + ** value of the nonterminal uninitialized is utterly harmless as long + ** as the value is never used. So really the only thing this code + ** accomplishes is to quieten purify. + ** + ** 2007-01-16: The wireshark project (www.wireshark.org) reports that + ** without this code, their parser segfaults. I'm not sure what there + ** parser is doing to make this happen. This is the second bug report + ** from wireshark this week. Clearly they are stressing Lemon in ways + ** that it has not been previously stressed... (SQLite ticket #2172) + */ + memset(&yygotominor, 0, sizeof(yygotominor)); + + + switch( yyruleno ){ + /* Beginning here are the reduction cases. A typical example + ** follows: + ** case 0: + ** #line + ** { ... } // User supplied code + ** #line + ** break; + */ + case 0: /* main ::= translation_unit */ + case 1: /*translation_unit ::= */ + case 2: /*translation_unit ::= translation_unit external_declaration */ + case 3: /*external_declaration ::= define_statement */ + case 4: /*external_declaration ::= enum_statement */ + case 5: /*external_declaration ::= linetype_declaration */ + case 6: /*external_declaration ::= boom_declaration */ + case 22: /*enum_list ::= */ + case 23: /*enum_list ::= single_enum */ +#line 9 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ +} +#line 867 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 7: /* external_declaration ::= NOP */ +#line 18 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yy_destructor(1,&yymsp[0].minor); +} +#line 874 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 8: /* exp ::= NUM */ +#line 29 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = yymsp[0].minor.yy0.val; } +#line 879 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 9: /* exp ::= SYMNUM */ +#line 30 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = yymsp[0].minor.yy0.symval->Value; } +#line 884 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 10: /* exp ::= exp PLUS exp */ +#line 31 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = yymsp[-2].minor.yy94 + yymsp[0].minor.yy94; yy_destructor(6,&yymsp[-1].minor); +} +#line 890 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 11: /* exp ::= exp MINUS exp */ +#line 32 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = yymsp[-2].minor.yy94 - yymsp[0].minor.yy94; yy_destructor(5,&yymsp[-1].minor); +} +#line 896 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 12: /* exp ::= exp MULTIPLY exp */ +#line 33 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = yymsp[-2].minor.yy94 * yymsp[0].minor.yy94; yy_destructor(7,&yymsp[-1].minor); +} +#line 902 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 13: /* exp ::= exp DIVIDE exp */ +#line 34 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = yymsp[-2].minor.yy94 / yymsp[0].minor.yy94; yy_destructor(8,&yymsp[-1].minor); +} +#line 908 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 14: /* exp ::= exp OR exp */ +#line 35 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = yymsp[-2].minor.yy94 | yymsp[0].minor.yy94; yy_destructor(2,&yymsp[-1].minor); +} +#line 914 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 15: /* exp ::= exp AND exp */ +#line 36 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = yymsp[-2].minor.yy94 & yymsp[0].minor.yy94; yy_destructor(4,&yymsp[-1].minor); +} +#line 920 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 16: /* exp ::= exp XOR exp */ +#line 37 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = yymsp[-2].minor.yy94 ^ yymsp[0].minor.yy94; yy_destructor(3,&yymsp[-1].minor); +} +#line 926 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 17: /* exp ::= MINUS exp */ +#line 38 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = -yymsp[0].minor.yy94; yy_destructor(5,&yymsp[-1].minor); +} +#line 932 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 18: /* exp ::= LPAREN exp RPAREN */ +#line 39 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = yymsp[-1].minor.yy94; yy_destructor(12,&yymsp[-2].minor); + yy_destructor(13,&yymsp[0].minor); +} +#line 939 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 19: /* define_statement ::= DEFINE SYM LPAREN exp RPAREN */ +#line 49 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + context->AddSym (yymsp[-3].minor.yy0.sym, yymsp[-1].minor.yy94); + yy_destructor(14,&yymsp[-4].minor); + yy_destructor(12,&yymsp[-2].minor); + yy_destructor(13,&yymsp[0].minor); +} +#line 949 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 20: /* enum_statement ::= enum_open enum_list RBRACE */ +#line 59 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yy_destructor(16,&yymsp[0].minor); +} +#line 956 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 21: /* enum_open ::= ENUM LBRACE */ +#line 62 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + context->EnumVal = 0; + yy_destructor(17,&yymsp[-1].minor); + yy_destructor(18,&yymsp[0].minor); +} +#line 965 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 24: /* enum_list ::= single_enum COMMA enum_list */ +#line 68 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yy_destructor(19,&yymsp[-1].minor); +} +#line 972 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 25: /* single_enum ::= SYM */ +#line 71 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + context->AddSym (yymsp[0].minor.yy0.sym, context->EnumVal++); +} +#line 979 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 26: /* single_enum ::= SYM EQUALS exp */ +#line 76 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + context->AddSym (yymsp[-2].minor.yy0.sym, context->EnumVal = yymsp[0].minor.yy94); + yy_destructor(20,&yymsp[-1].minor); +} +#line 987 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 27: /* linetype_declaration ::= exp EQUALS exp COMMA exp LPAREN special_args RPAREN */ +#line 87 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + SimpleLineTranslations.SetVal(yymsp[-7].minor.yy94, + FLineTrans(yymsp[-3].minor.yy94&0xffff, yymsp[-5].minor.yy94+yymsp[-1].minor.yy15.addflags, yymsp[-1].minor.yy15.args[0], yymsp[-1].minor.yy15.args[1], yymsp[-1].minor.yy15.args[2], yymsp[-1].minor.yy15.args[3], yymsp[-1].minor.yy15.args[4])); + yy_destructor(20,&yymsp[-6].minor); + yy_destructor(19,&yymsp[-4].minor); + yy_destructor(12,&yymsp[-2].minor); + yy_destructor(13,&yymsp[0].minor); +} +#line 999 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 28: /* linetype_declaration ::= exp EQUALS exp COMMA SYM LPAREN special_args RPAREN */ +#line 93 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + Printf ("%s, line %d: %s is undefined\n", context->SourceFile, context->SourceLine, yymsp[-3].minor.yy0.sym); + yy_destructor(20,&yymsp[-6].minor); + yy_destructor(19,&yymsp[-4].minor); + yy_destructor(12,&yymsp[-2].minor); + yy_destructor(13,&yymsp[0].minor); +} +#line 1010 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 29: /* special_args ::= */ +#line 100 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = 0; + yygotominor.yy15.args[0] = 0; + yygotominor.yy15.args[1] = 0; + yygotominor.yy15.args[2] = 0; + yygotominor.yy15.args[3] = 0; + yygotominor.yy15.args[4] = 0; +} +#line 1022 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 30: /* special_args ::= TAG */ +#line 109 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HASTAGAT1; + yygotominor.yy15.args[0] = 0; + yygotominor.yy15.args[1] = 0; + yygotominor.yy15.args[2] = 0; + yygotominor.yy15.args[3] = 0; + yygotominor.yy15.args[4] = 0; + yy_destructor(21,&yymsp[0].minor); +} +#line 1035 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 31: /* special_args ::= TAG COMMA exp */ +#line 118 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HASTAGAT1; + yygotominor.yy15.args[0] = 0; + yygotominor.yy15.args[1] = yymsp[0].minor.yy94; + yygotominor.yy15.args[2] = 0; + yygotominor.yy15.args[3] = 0; + yygotominor.yy15.args[4] = 0; + yy_destructor(21,&yymsp[-2].minor); + yy_destructor(19,&yymsp[-1].minor); +} +#line 1049 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 32: /* special_args ::= TAG COMMA exp COMMA exp */ +#line 127 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HASTAGAT1; + yygotominor.yy15.args[0] = 0; + yygotominor.yy15.args[1] = yymsp[-2].minor.yy94; + yygotominor.yy15.args[2] = yymsp[0].minor.yy94; + yygotominor.yy15.args[3] = 0; + yygotominor.yy15.args[4] = 0; + yy_destructor(21,&yymsp[-4].minor); + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(19,&yymsp[-1].minor); +} +#line 1064 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 33: /* special_args ::= TAG COMMA exp COMMA exp COMMA exp */ +#line 136 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HASTAGAT1; + yygotominor.yy15.args[0] = 0; + yygotominor.yy15.args[1] = yymsp[-4].minor.yy94; + yygotominor.yy15.args[2] = yymsp[-2].minor.yy94; + yygotominor.yy15.args[3] = yymsp[0].minor.yy94; + yygotominor.yy15.args[4] = 0; + yy_destructor(21,&yymsp[-6].minor); + yy_destructor(19,&yymsp[-5].minor); + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(19,&yymsp[-1].minor); +} +#line 1080 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 34: /* special_args ::= TAG COMMA exp COMMA exp COMMA exp COMMA exp */ +#line 145 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HASTAGAT1; + yygotominor.yy15.args[0] = 0; + yygotominor.yy15.args[1] = yymsp[-6].minor.yy94; + yygotominor.yy15.args[2] = yymsp[-4].minor.yy94; + yygotominor.yy15.args[3] = yymsp[-2].minor.yy94; + yygotominor.yy15.args[4] = yymsp[0].minor.yy94; + yy_destructor(21,&yymsp[-8].minor); + yy_destructor(19,&yymsp[-7].minor); + yy_destructor(19,&yymsp[-5].minor); + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(19,&yymsp[-1].minor); +} +#line 1097 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 35: /* special_args ::= TAG COMMA TAG */ +#line 154 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HAS2TAGS; + yygotominor.yy15.args[0] = yygotominor.yy15.args[1] = 0; + yygotominor.yy15.args[2] = 0; + yygotominor.yy15.args[3] = 0; + yygotominor.yy15.args[4] = 0; + yy_destructor(21,&yymsp[-2].minor); + yy_destructor(19,&yymsp[-1].minor); + yy_destructor(21,&yymsp[0].minor); +} +#line 1111 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 36: /* special_args ::= TAG COMMA TAG COMMA exp */ +#line 162 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HAS2TAGS; + yygotominor.yy15.args[0] = yygotominor.yy15.args[1] = 0; + yygotominor.yy15.args[2] = yymsp[0].minor.yy94; + yygotominor.yy15.args[3] = 0; + yygotominor.yy15.args[4] = 0; + yy_destructor(21,&yymsp[-4].minor); + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(21,&yymsp[-2].minor); + yy_destructor(19,&yymsp[-1].minor); +} +#line 1126 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 37: /* special_args ::= TAG COMMA TAG COMMA exp COMMA exp */ +#line 170 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HAS2TAGS; + yygotominor.yy15.args[0] = yygotominor.yy15.args[1] = 0; + yygotominor.yy15.args[2] = yymsp[-2].minor.yy94; + yygotominor.yy15.args[3] = yymsp[0].minor.yy94; + yygotominor.yy15.args[4] = 0; + yy_destructor(21,&yymsp[-6].minor); + yy_destructor(19,&yymsp[-5].minor); + yy_destructor(21,&yymsp[-4].minor); + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(19,&yymsp[-1].minor); +} +#line 1142 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 38: /* special_args ::= TAG COMMA TAG COMMA exp COMMA exp COMMA exp */ +#line 178 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HAS2TAGS; + yygotominor.yy15.args[0] = yygotominor.yy15.args[1] = 0; + yygotominor.yy15.args[2] = yymsp[-4].minor.yy94; + yygotominor.yy15.args[3] = yymsp[-2].minor.yy94; + yygotominor.yy15.args[4] = yymsp[0].minor.yy94; + yy_destructor(21,&yymsp[-8].minor); + yy_destructor(19,&yymsp[-7].minor); + yy_destructor(21,&yymsp[-6].minor); + yy_destructor(19,&yymsp[-5].minor); + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(19,&yymsp[-1].minor); +} +#line 1159 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 39: /* special_args ::= exp */ +#line 186 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = 0; + yygotominor.yy15.args[0] = yymsp[0].minor.yy94; + yygotominor.yy15.args[1] = 0; + yygotominor.yy15.args[2] = 0; + yygotominor.yy15.args[3] = 0; + yygotominor.yy15.args[4] = 0; +} +#line 1171 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 40: /* special_args ::= exp COMMA exp */ +#line 195 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = 0; + yygotominor.yy15.args[0] = yymsp[-2].minor.yy94; + yygotominor.yy15.args[1] = yymsp[0].minor.yy94; + yygotominor.yy15.args[2] = 0; + yygotominor.yy15.args[3] = 0; + yygotominor.yy15.args[4] = 0; + yy_destructor(19,&yymsp[-1].minor); +} +#line 1184 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 41: /* special_args ::= exp COMMA exp COMMA exp */ +#line 204 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = 0; + yygotominor.yy15.args[0] = yymsp[-4].minor.yy94; + yygotominor.yy15.args[1] = yymsp[-2].minor.yy94; + yygotominor.yy15.args[2] = yymsp[0].minor.yy94; + yygotominor.yy15.args[3] = 0; + yygotominor.yy15.args[4] = 0; + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(19,&yymsp[-1].minor); +} +#line 1198 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 42: /* special_args ::= exp COMMA exp COMMA exp COMMA exp */ +#line 213 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = 0; + yygotominor.yy15.args[0] = yymsp[-6].minor.yy94; + yygotominor.yy15.args[1] = yymsp[-4].minor.yy94; + yygotominor.yy15.args[2] = yymsp[-2].minor.yy94; + yygotominor.yy15.args[3] = yymsp[0].minor.yy94; + yygotominor.yy15.args[4] = 0; + yy_destructor(19,&yymsp[-5].minor); + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(19,&yymsp[-1].minor); +} +#line 1213 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 43: /* special_args ::= exp COMMA exp COMMA exp COMMA exp COMMA exp */ +#line 222 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = 0; + yygotominor.yy15.args[0] = yymsp[-8].minor.yy94; + yygotominor.yy15.args[1] = yymsp[-6].minor.yy94; + yygotominor.yy15.args[2] = yymsp[-4].minor.yy94; + yygotominor.yy15.args[3] = yymsp[-2].minor.yy94; + yygotominor.yy15.args[4] = yymsp[0].minor.yy94; + yy_destructor(19,&yymsp[-7].minor); + yy_destructor(19,&yymsp[-5].minor); + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(19,&yymsp[-1].minor); +} +#line 1229 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 44: /* special_args ::= exp COMMA TAG */ +#line 231 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HASTAGAT2; + yygotominor.yy15.args[0] = yymsp[-2].minor.yy94; + yygotominor.yy15.args[1] = 0; + yygotominor.yy15.args[2] = 0; + yygotominor.yy15.args[3] = 0; + yygotominor.yy15.args[4] = 0; + yy_destructor(19,&yymsp[-1].minor); + yy_destructor(21,&yymsp[0].minor); +} +#line 1243 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 45: /* special_args ::= exp COMMA TAG COMMA exp */ +#line 240 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HASTAGAT2; + yygotominor.yy15.args[0] = yymsp[-4].minor.yy94; + yygotominor.yy15.args[1] = 0; + yygotominor.yy15.args[2] = yymsp[0].minor.yy94; + yygotominor.yy15.args[3] = 0; + yygotominor.yy15.args[4] = 0; + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(21,&yymsp[-2].minor); + yy_destructor(19,&yymsp[-1].minor); +} +#line 1258 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 46: /* special_args ::= exp COMMA TAG COMMA exp COMMA exp */ +#line 249 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HASTAGAT2; + yygotominor.yy15.args[0] = yymsp[-6].minor.yy94; + yygotominor.yy15.args[1] = 0; + yygotominor.yy15.args[2] = yymsp[-2].minor.yy94; + yygotominor.yy15.args[3] = yymsp[0].minor.yy94; + yygotominor.yy15.args[4] = 0; + yy_destructor(19,&yymsp[-5].minor); + yy_destructor(21,&yymsp[-4].minor); + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(19,&yymsp[-1].minor); +} +#line 1274 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 47: /* special_args ::= exp COMMA TAG COMMA exp COMMA exp COMMA exp */ +#line 258 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HASTAGAT2; + yygotominor.yy15.args[0] = yymsp[-8].minor.yy94; + yygotominor.yy15.args[1] = 0; + yygotominor.yy15.args[2] = yymsp[-4].minor.yy94; + yygotominor.yy15.args[3] = yymsp[-2].minor.yy94; + yygotominor.yy15.args[4] = yymsp[0].minor.yy94; + yy_destructor(19,&yymsp[-7].minor); + yy_destructor(21,&yymsp[-6].minor); + yy_destructor(19,&yymsp[-5].minor); + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(19,&yymsp[-1].minor); +} +#line 1291 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 48: /* special_args ::= exp COMMA exp COMMA TAG */ +#line 267 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HASTAGAT3; + yygotominor.yy15.args[0] = yymsp[-4].minor.yy94; + yygotominor.yy15.args[1] = yymsp[-2].minor.yy94; + yygotominor.yy15.args[2] = 0; + yygotominor.yy15.args[3] = 0; + yygotominor.yy15.args[4] = 0; + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(19,&yymsp[-1].minor); + yy_destructor(21,&yymsp[0].minor); +} +#line 1306 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 49: /* special_args ::= exp COMMA exp COMMA TAG COMMA exp */ +#line 276 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HASTAGAT3; + yygotominor.yy15.args[0] = yymsp[-6].minor.yy94; + yygotominor.yy15.args[1] = yymsp[-4].minor.yy94; + yygotominor.yy15.args[2] = 0; + yygotominor.yy15.args[3] = yymsp[0].minor.yy94; + yygotominor.yy15.args[4] = 0; + yy_destructor(19,&yymsp[-5].minor); + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(21,&yymsp[-2].minor); + yy_destructor(19,&yymsp[-1].minor); +} +#line 1322 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 50: /* special_args ::= exp COMMA exp COMMA TAG COMMA exp COMMA exp */ +#line 285 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HASTAGAT3; + yygotominor.yy15.args[0] = yymsp[-8].minor.yy94; + yygotominor.yy15.args[1] = yymsp[-6].minor.yy94; + yygotominor.yy15.args[2] = 0; + yygotominor.yy15.args[3] = yymsp[-2].minor.yy94; + yygotominor.yy15.args[4] = yymsp[0].minor.yy94; + yy_destructor(19,&yymsp[-7].minor); + yy_destructor(19,&yymsp[-5].minor); + yy_destructor(21,&yymsp[-4].minor); + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(19,&yymsp[-1].minor); +} +#line 1339 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 51: /* special_args ::= exp COMMA exp COMMA exp COMMA TAG */ +#line 294 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HASTAGAT4; + yygotominor.yy15.args[0] = yymsp[-6].minor.yy94; + yygotominor.yy15.args[1] = yymsp[-4].minor.yy94; + yygotominor.yy15.args[2] = yymsp[-2].minor.yy94; + yygotominor.yy15.args[3] = 0; + yygotominor.yy15.args[4] = 0; + yy_destructor(19,&yymsp[-5].minor); + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(19,&yymsp[-1].minor); + yy_destructor(21,&yymsp[0].minor); +} +#line 1355 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 52: /* special_args ::= exp COMMA exp COMMA exp COMMA TAG COMMA exp */ +#line 303 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HASTAGAT4; + yygotominor.yy15.args[0] = yymsp[-8].minor.yy94; + yygotominor.yy15.args[1] = yymsp[-6].minor.yy94; + yygotominor.yy15.args[2] = yymsp[-4].minor.yy94; + yygotominor.yy15.args[3] = 0; + yygotominor.yy15.args[4] = yymsp[0].minor.yy94; + yy_destructor(19,&yymsp[-7].minor); + yy_destructor(19,&yymsp[-5].minor); + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(21,&yymsp[-2].minor); + yy_destructor(19,&yymsp[-1].minor); +} +#line 1372 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 53: /* special_args ::= exp COMMA exp COMMA exp COMMA exp COMMA TAG */ +#line 312 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy15.addflags = LINETRANS_HASTAGAT5; + yygotominor.yy15.args[0] = yymsp[-8].minor.yy94; + yygotominor.yy15.args[1] = yymsp[-6].minor.yy94; + yygotominor.yy15.args[2] = yymsp[-4].minor.yy94; + yygotominor.yy15.args[3] = yymsp[-2].minor.yy94; + yygotominor.yy15.args[4] = 0; + yy_destructor(19,&yymsp[-7].minor); + yy_destructor(19,&yymsp[-5].minor); + yy_destructor(19,&yymsp[-3].minor); + yy_destructor(19,&yymsp[-1].minor); + yy_destructor(21,&yymsp[0].minor); +} +#line 1389 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 54: /* boom_declaration ::= LBRACKET exp RBRACKET LPAREN exp COMMA exp RPAREN LBRACE boom_body RBRACE */ +#line 337 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + int i; + MoreLines *probe; + + if (NumBoomish == MAX_BOOMISH) + { + MoreLines *probe = yymsp[-1].minor.yy81; + + while (probe != NULL) + { + MoreLines *next = probe->next; + delete probe; + probe = next; + } + Printf ("%s, line %d: Too many BOOM translators\n", context->SourceFile, context->SourceLine); + } + else + { + Boomish[NumBoomish].FirstLinetype = yymsp[-6].minor.yy94; + Boomish[NumBoomish].LastLinetype = yymsp[-4].minor.yy94; + Boomish[NumBoomish].NewSpecial = yymsp[-9].minor.yy94; + + for (i = 0, probe = yymsp[-1].minor.yy81; probe != NULL; i++) + { + MoreLines *next = probe->next; + Boomish[NumBoomish].Args.Push(probe->arg); + delete probe; + probe = next; + } + NumBoomish++; + } + yy_destructor(22,&yymsp[-10].minor); + yy_destructor(23,&yymsp[-8].minor); + yy_destructor(12,&yymsp[-7].minor); + yy_destructor(19,&yymsp[-5].minor); + yy_destructor(13,&yymsp[-3].minor); + yy_destructor(18,&yymsp[-2].minor); + yy_destructor(16,&yymsp[0].minor); +} +#line 1432 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 55: /* boom_body ::= */ +#line 371 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy81 = NULL; +} +#line 1439 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 56: /* boom_body ::= boom_line boom_body */ +#line 375 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy81 = new MoreLines; + yygotominor.yy81->next = yymsp[0].minor.yy81; + yygotominor.yy81->arg = yymsp[-1].minor.yy20; +} +#line 1448 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 57: /* boom_line ::= boom_selector boom_op boom_args */ +#line 382 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy20.bOrExisting = (yymsp[-1].minor.yy94 == OR_EQUAL); + yygotominor.yy20.bUseConstant = (yymsp[0].minor.yy40.filters == NULL); + yygotominor.yy20.ArgNum = yymsp[-2].minor.yy94; + yygotominor.yy20.ConstantValue = yymsp[0].minor.yy40.constant; + yygotominor.yy20.AndValue = yymsp[0].minor.yy40.mask; + + if (yymsp[0].minor.yy40.filters != NULL) + { + int i; + MoreFilters *probe; + + for (i = 0, probe = yymsp[0].minor.yy40.filters; probe != NULL; i++) + { + MoreFilters *next = probe->next; + if (i < 15) + { + yygotominor.yy20.ResultFilter[i] = probe->filter.filter; + yygotominor.yy20.ResultValue[i] = probe->filter.value; + } + else if (i == 15) + { + context->PrintError ("Lists can only have 15 elements"); + } + delete probe; + probe = next; + } + yygotominor.yy20.ListSize = i > 15 ? 15 : i; + } +} +#line 1482 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 58: /* boom_selector ::= FLAGS */ +#line 413 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = 4; yy_destructor(24,&yymsp[0].minor); +} +#line 1488 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 59: /* boom_selector ::= ARG2 */ +#line 414 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = 0; yy_destructor(25,&yymsp[0].minor); +} +#line 1494 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 60: /* boom_selector ::= ARG3 */ +#line 415 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = 1; yy_destructor(26,&yymsp[0].minor); +} +#line 1500 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 61: /* boom_selector ::= ARG4 */ +#line 416 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = 2; yy_destructor(27,&yymsp[0].minor); +} +#line 1506 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 62: /* boom_selector ::= ARG5 */ +#line 417 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = 3; yy_destructor(28,&yymsp[0].minor); +} +#line 1512 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 63: /* boom_op ::= EQUALS */ +#line 419 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = '='; yy_destructor(20,&yymsp[0].minor); +} +#line 1518 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 64: /* boom_op ::= OR_EQUAL */ +#line 420 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ yygotominor.yy94 = OR_EQUAL; yy_destructor(29,&yymsp[0].minor); +} +#line 1524 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 65: /* boom_args ::= exp */ +#line 423 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy40.constant = yymsp[0].minor.yy94; + yygotominor.yy40.filters = NULL; +} +#line 1532 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 66: /* boom_args ::= exp LBRACKET arg_list RBRACKET */ +#line 428 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy40.mask = yymsp[-3].minor.yy94; + yygotominor.yy40.filters = yymsp[-1].minor.yy39; + yy_destructor(22,&yymsp[-2].minor); + yy_destructor(23,&yymsp[0].minor); +} +#line 1542 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 67: /* arg_list ::= list_val */ +#line 434 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy39 = new MoreFilters; + yygotominor.yy39->next = NULL; + yygotominor.yy39->filter = yymsp[0].minor.yy11; +} +#line 1551 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 68: /* arg_list ::= list_val COMMA arg_list */ +#line 440 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy39 = new MoreFilters; + yygotominor.yy39->next = yymsp[0].minor.yy39; + yygotominor.yy39->filter = yymsp[-2].minor.yy11; + yy_destructor(19,&yymsp[-1].minor); +} +#line 1561 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + case 69: /* list_val ::= exp COLON exp */ +#line 447 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" +{ + yygotominor.yy11.filter = yymsp[-2].minor.yy94; + yygotominor.yy11.value = yymsp[0].minor.yy94; + yy_destructor(30,&yymsp[-1].minor); +} +#line 1570 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + break; + }; + yygoto = yyRuleInfo[yyruleno].lhs; + yysize = yyRuleInfo[yyruleno].nrhs; + yypParser->yyidx -= yysize; + yyact = yy_find_reduce_action(yymsp[-yysize].stateno,yygoto); + if( yyact < YYNSTATE ){ +#ifdef NDEBUG + /* If we are not debugging and the reduce action popped at least + ** one element off the stack, then we can push the new element back + ** onto the stack here, and skip the stack overflow test in yy_shift(). + ** That gives a significant speed improvement. */ + if( yysize ){ + yypParser->yyidx++; + yymsp -= yysize-1; + yymsp->stateno = yyact; + yymsp->major = yygoto; + yymsp->minor = yygotominor; + }else +#endif + { + yy_shift(yypParser,yyact,yygoto,&yygotominor); + } + }else{ + assert( yyact == YYNSTATE + YYNRULE + 1 ); + yy_accept(yypParser); + } +} + +/* +** The following code executes when the parse fails +*/ +static void yy_parse_failed( + yyParser *yypParser /* The parser */ +){ + XlatParseARG_FETCH; +#ifndef NDEBUG + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); + } +#endif + while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); + /* Here code is inserted which will be executed whenever the + ** parser fails */ + XlatParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ +} + +/* +** The following code executes when a syntax error first occurs. +*/ +static void yy_syntax_error( + yyParser *yypParser, /* The parser */ + int yymajor, /* The major type of the error token */ + YYMINORTYPE yyminor /* The minor type of the error token */ +){ + XlatParseARG_FETCH; +#define TOKEN (yyminor.yy0) +#line 6 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.y" + context->PrintError("syntax error"); +#line 1630 "d:\\windoom\\zdoomstuff\\zdoomsrc\\zdoom\\trunk\\src\\xlat\\xlat_parser.c" + XlatParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ +} + +/* +** The following is executed when the parser accepts +*/ +static void yy_accept( + yyParser *yypParser /* The parser */ +){ + XlatParseARG_FETCH; +#ifndef NDEBUG + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); + } +#endif + while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); + /* Here code is inserted which will be executed whenever the + ** parser accepts */ + XlatParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ +} + +/* The main parser program. +** The first argument is a pointer to a structure obtained from +** "XlatParseAlloc" which describes the current state of the parser. +** The second argument is the major token number. The third is +** the minor token. The fourth optional argument is whatever the +** user wants (and specified in the grammar) and is available for +** use by the action routines. +** +** Inputs: +**
    +**
  • A pointer to the parser (an opaque structure.) +**
  • The major token number. +**
  • The minor token number. +**
  • An option argument of a grammar-specified type. +**
+** +** Outputs: +** None. +*/ +void XlatParse( + void *yyp, /* The parser */ + int yymajor, /* The major token code number */ + XlatParseTOKENTYPE yyminor /* The value for the token */ + XlatParseARG_PDECL /* Optional %extra_argument parameter */ +){ + YYMINORTYPE yyminorunion; + int yyact; /* The parser action. */ + int yyendofinput; /* True if we are at the end of input */ +#ifdef YYERRORSYMBOL + int yyerrorhit = 0; /* True if yymajor has invoked an error */ +#endif + yyParser *yypParser; /* The parser */ + + /* (re)initialize the parser, if necessary */ + yypParser = (yyParser*)yyp; + if( yypParser->yyidx<0 ){ +#if YYSTACKDEPTH<=0 + if( yypParser->yystksz <=0 ){ + memset(&yyminorunion, 0, sizeof(yyminorunion)); + yyStackOverflow(yypParser, &yyminorunion); + return; + } +#endif + yypParser->yyidx = 0; + yypParser->yyerrcnt = -1; + yypParser->yystack[0].stateno = 0; + yypParser->yystack[0].major = 0; + } + yyminorunion.yy0 = yyminor; + yyendofinput = (yymajor==0); + XlatParseARG_STORE; + +#ifndef NDEBUG + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]); + } +#endif + + do{ + yyact = yy_find_shift_action(yypParser,yymajor); + if( yyactyyerrcnt--; + yymajor = YYNOCODE; + }else if( yyact < YYNSTATE + YYNRULE ){ + yy_reduce(yypParser,yyact-YYNSTATE); + }else{ +#ifdef YYERRORSYMBOL + int yymx; +#endif + assert( yyact == YY_ERROR_ACTION ); +#ifndef NDEBUG + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); + } +#endif +#ifdef YYERRORSYMBOL + /* A syntax error has occurred. + ** The response to an error depends upon whether or not the + ** grammar defines an error token "ERROR". + ** + ** This is what we do if the grammar does define ERROR: + ** + ** * Call the %syntax_error function. + ** + ** * Begin popping the stack until we enter a state where + ** it is legal to shift the error symbol, then shift + ** the error symbol. + ** + ** * Set the error count to three. + ** + ** * Begin accepting and shifting new tokens. No new error + ** processing will occur until three tokens have been + ** shifted successfully. + ** + */ + if( yypParser->yyerrcnt<0 ){ + yy_syntax_error(yypParser,yymajor,yyminorunion); + } + yymx = yypParser->yystack[yypParser->yyidx].major; + if( yymx==YYERRORSYMBOL || yyerrorhit ){ +#ifndef NDEBUG + if( yyTraceFILE ){ + fprintf(yyTraceFILE,"%sDiscard input token %s\n", + yyTracePrompt,yyTokenName[yymajor]); + } +#endif + yy_destructor(yymajor,&yyminorunion); + yymajor = YYNOCODE; + }else{ + while( + yypParser->yyidx >= 0 && + yymx != YYERRORSYMBOL && + (yyact = yy_find_reduce_action( + yypParser->yystack[yypParser->yyidx].stateno, + YYERRORSYMBOL)) >= YYNSTATE + ){ + yy_pop_parser_stack(yypParser); + } + if( yypParser->yyidx < 0 || yymajor==0 ){ + yy_destructor(yymajor,&yyminorunion); + yy_parse_failed(yypParser); + yymajor = YYNOCODE; + }else if( yymx!=YYERRORSYMBOL ){ + YYMINORTYPE u2; + u2.YYERRSYMDT = 0; + yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2); + } + } + yypParser->yyerrcnt = 3; + yyerrorhit = 1; +#else /* YYERRORSYMBOL is not defined */ + /* This is what we do if the grammar does not define ERROR: + ** + ** * Report an error message, and throw away the input token. + ** + ** * If the input token is $, then fail the parse. + ** + ** As before, subsequent error messages are suppressed until + ** three input tokens have been successfully shifted. + */ + if( yypParser->yyerrcnt<=0 ){ + yy_syntax_error(yypParser,yymajor,yyminorunion); + } + yypParser->yyerrcnt = 3; + yy_destructor(yymajor,&yyminorunion); + if( yyendofinput ){ + yy_parse_failed(yypParser); + } + yymajor = YYNOCODE; +#endif + } + }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); + return; +} diff --git a/src/xlat/xlat_parser.h b/src/xlat/xlat_parser.h new file mode 100644 index 0000000000..abb1be416c --- /dev/null +++ b/src/xlat/xlat_parser.h @@ -0,0 +1,30 @@ +#define NOP 1 +#define OR 2 +#define XOR 3 +#define AND 4 +#define MINUS 5 +#define PLUS 6 +#define MULTIPLY 7 +#define DIVIDE 8 +#define NEG 9 +#define NUM 10 +#define SYMNUM 11 +#define LPAREN 12 +#define RPAREN 13 +#define DEFINE 14 +#define SYM 15 +#define RBRACE 16 +#define ENUM 17 +#define LBRACE 18 +#define COMMA 19 +#define EQUALS 20 +#define TAG 21 +#define LBRACKET 22 +#define RBRACKET 23 +#define FLAGS 24 +#define ARG2 25 +#define ARG3 26 +#define ARG4 27 +#define ARG5 28 +#define OR_EQUAL 29 +#define COLON 30 diff --git a/src/xlat/xlat_parser.y b/src/xlat/xlat_parser.y new file mode 100644 index 0000000000..0d83357e13 --- /dev/null +++ b/src/xlat/xlat_parser.y @@ -0,0 +1,451 @@ + +%token_type {XlatToken} +%token_destructor {} // just to avoid a compiler warning +%name XlatParse +%extra_argument { XlatParseContext *context } +%syntax_error { context->PrintError("syntax error");} + + +main ::= translation_unit. + +translation_unit ::= . /* empty */ +translation_unit ::= translation_unit external_declaration. + +external_declaration ::= define_statement. +external_declaration ::= enum_statement. +external_declaration ::= linetype_declaration. +external_declaration ::= boom_declaration. +external_declaration ::= NOP. + + +%left OR. +%left XOR. +%left AND. +%left MINUS PLUS. +%left MULTIPLY DIVIDE. +%left NEG. + +%type exp {int} +exp(A) ::= NUM(B). { A = B.val; } +exp(A) ::= SYMNUM(B). { A = B.symval->Value; } +exp(A) ::= exp(B) PLUS exp(C). { A = B + C; } +exp(A) ::= exp(B) MINUS exp(C). { A = B - C; } +exp(A) ::= exp(B) MULTIPLY exp(C). { A = B * C; } +exp(A) ::= exp(B) DIVIDE exp(C). { A = B / C; } +exp(A) ::= exp(B) OR exp(C). { A = B | C; } +exp(A) ::= exp(B) AND exp(C). { A = B & C; } +exp(A) ::= exp(B) XOR exp(C). { A = B ^ C; } +exp(A) ::= MINUS exp(B). [NEG] { A = -B; } +exp(A) ::= LPAREN exp(B) RPAREN. { A = B; } + + +//========================================================================== +// +// define +// +//========================================================================== + +define_statement ::= DEFINE SYM(A) LPAREN exp(B) RPAREN. +{ + context->AddSym (A.sym, B); +} + +//========================================================================== +// +// enum +// +//========================================================================== + +enum_statement ::= enum_open enum_list RBRACE. + +enum_open ::= ENUM LBRACE. +{ + context->EnumVal = 0; +} + +enum_list ::= . /* empty */ +enum_list ::= single_enum. +enum_list ::= single_enum COMMA enum_list. + +single_enum ::= SYM(A). +{ + context->AddSym (A.sym, context->EnumVal++); +} + +single_enum ::= SYM(A) EQUALS exp(B). +{ + context->AddSym (A.sym, context->EnumVal = B); +} + +//========================================================================== +// +// standard linetype +// +//========================================================================== + +linetype_declaration ::= exp(linetype) EQUALS exp(flags) COMMA exp(special) LPAREN special_args(arg) RPAREN. +{ + SimpleLineTranslations.SetVal(linetype, + FLineTrans(special&0xffff, flags+arg.addflags, arg.args[0], arg.args[1], arg.args[2], arg.args[3], arg.args[4])); +} + +linetype_declaration ::= exp EQUALS exp COMMA SYM(S) LPAREN special_args RPAREN. +{ + Printf ("%s, line %d: %s is undefined\n", context->SourceFile, context->SourceLine, S.sym); +} + +%type special_args {SpecialArgs} + +special_args(Z) ::= . /* empty */ +{ + Z.addflags = 0; + Z.args[0] = 0; + Z.args[1] = 0; + Z.args[2] = 0; + Z.args[3] = 0; + Z.args[4] = 0; +} +special_args(Z) ::= TAG. +{ + Z.addflags = LINETRANS_HASTAGAT1; + Z.args[0] = 0; + Z.args[1] = 0; + Z.args[2] = 0; + Z.args[3] = 0; + Z.args[4] = 0; +} +special_args(Z) ::= TAG COMMA exp(B). +{ + Z.addflags = LINETRANS_HASTAGAT1; + Z.args[0] = 0; + Z.args[1] = B; + Z.args[2] = 0; + Z.args[3] = 0; + Z.args[4] = 0; +} +special_args(Z) ::= TAG COMMA exp(B) COMMA exp(C). +{ + Z.addflags = LINETRANS_HASTAGAT1; + Z.args[0] = 0; + Z.args[1] = B; + Z.args[2] = C; + Z.args[3] = 0; + Z.args[4] = 0; +} +special_args(Z) ::= TAG COMMA exp(B) COMMA exp(C) COMMA exp(D). +{ + Z.addflags = LINETRANS_HASTAGAT1; + Z.args[0] = 0; + Z.args[1] = B; + Z.args[2] = C; + Z.args[3] = D; + Z.args[4] = 0; +} +special_args(Z) ::= TAG COMMA exp(B) COMMA exp(C) COMMA exp(D) COMMA exp(E). +{ + Z.addflags = LINETRANS_HASTAGAT1; + Z.args[0] = 0; + Z.args[1] = B; + Z.args[2] = C; + Z.args[3] = D; + Z.args[4] = E; +} +special_args(Z) ::= TAG COMMA TAG. +{ + Z.addflags = LINETRANS_HAS2TAGS; + Z.args[0] = Z.args[1] = 0; + Z.args[2] = 0; + Z.args[3] = 0; + Z.args[4] = 0; +} +special_args(Z) ::= TAG COMMA TAG COMMA exp(C). +{ + Z.addflags = LINETRANS_HAS2TAGS; + Z.args[0] = Z.args[1] = 0; + Z.args[2] = C; + Z.args[3] = 0; + Z.args[4] = 0; +} +special_args(Z) ::= TAG COMMA TAG COMMA exp(C) COMMA exp(D). +{ + Z.addflags = LINETRANS_HAS2TAGS; + Z.args[0] = Z.args[1] = 0; + Z.args[2] = C; + Z.args[3] = D; + Z.args[4] = 0; +} +special_args(Z) ::= TAG COMMA TAG COMMA exp(C) COMMA exp(D) COMMA exp(E). +{ + Z.addflags = LINETRANS_HAS2TAGS; + Z.args[0] = Z.args[1] = 0; + Z.args[2] = C; + Z.args[3] = D; + Z.args[4] = E; +} +special_args(Z) ::= exp(A). +{ + Z.addflags = 0; + Z.args[0] = A; + Z.args[1] = 0; + Z.args[2] = 0; + Z.args[3] = 0; + Z.args[4] = 0; +} +special_args(Z) ::= exp(A) COMMA exp(B). +{ + Z.addflags = 0; + Z.args[0] = A; + Z.args[1] = B; + Z.args[2] = 0; + Z.args[3] = 0; + Z.args[4] = 0; +} +special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C). +{ + Z.addflags = 0; + Z.args[0] = A; + Z.args[1] = B; + Z.args[2] = C; + Z.args[3] = 0; + Z.args[4] = 0; +} +special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA exp(D). +{ + Z.addflags = 0; + Z.args[0] = A; + Z.args[1] = B; + Z.args[2] = C; + Z.args[3] = D; + Z.args[4] = 0; +} +special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA exp(D) COMMA exp(E). +{ + Z.addflags = 0; + Z.args[0] = A; + Z.args[1] = B; + Z.args[2] = C; + Z.args[3] = D; + Z.args[4] = E; +} +special_args(Z) ::= exp(A) COMMA TAG. +{ + Z.addflags = LINETRANS_HASTAGAT2; + Z.args[0] = A; + Z.args[1] = 0; + Z.args[2] = 0; + Z.args[3] = 0; + Z.args[4] = 0; +} +special_args(Z) ::= exp(A) COMMA TAG COMMA exp(C). +{ + Z.addflags = LINETRANS_HASTAGAT2; + Z.args[0] = A; + Z.args[1] = 0; + Z.args[2] = C; + Z.args[3] = 0; + Z.args[4] = 0; +} +special_args(Z) ::= exp(A) COMMA TAG COMMA exp(C) COMMA exp(D). +{ + Z.addflags = LINETRANS_HASTAGAT2; + Z.args[0] = A; + Z.args[1] = 0; + Z.args[2] = C; + Z.args[3] = D; + Z.args[4] = 0; +} +special_args(Z) ::= exp(A) COMMA TAG COMMA exp(C) COMMA exp(D) COMMA exp(E). +{ + Z.addflags = LINETRANS_HASTAGAT2; + Z.args[0] = A; + Z.args[1] = 0; + Z.args[2] = C; + Z.args[3] = D; + Z.args[4] = E; +} +special_args(Z) ::= exp(A) COMMA exp(B) COMMA TAG. +{ + Z.addflags = LINETRANS_HASTAGAT3; + Z.args[0] = A; + Z.args[1] = B; + Z.args[2] = 0; + Z.args[3] = 0; + Z.args[4] = 0; +} +special_args(Z) ::= exp(A) COMMA exp(B) COMMA TAG COMMA exp(D). +{ + Z.addflags = LINETRANS_HASTAGAT3; + Z.args[0] = A; + Z.args[1] = B; + Z.args[2] = 0; + Z.args[3] = D; + Z.args[4] = 0; +} +special_args(Z) ::= exp(A) COMMA exp(B) COMMA TAG COMMA exp(D) COMMA exp(E). +{ + Z.addflags = LINETRANS_HASTAGAT3; + Z.args[0] = A; + Z.args[1] = B; + Z.args[2] = 0; + Z.args[3] = D; + Z.args[4] = E; +} +special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA TAG. +{ + Z.addflags = LINETRANS_HASTAGAT4; + Z.args[0] = A; + Z.args[1] = B; + Z.args[2] = C; + Z.args[3] = 0; + Z.args[4] = 0; +} +special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA TAG COMMA exp(E). +{ + Z.addflags = LINETRANS_HASTAGAT4; + Z.args[0] = A; + Z.args[1] = B; + Z.args[2] = C; + Z.args[3] = 0; + Z.args[4] = E; +} +special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA exp(D) COMMA TAG. +{ + Z.addflags = LINETRANS_HASTAGAT5; + Z.args[0] = A; + Z.args[1] = B; + Z.args[2] = C; + Z.args[3] = D; + Z.args[4] = 0; +} + +//========================================================================== +// +// boom generalized linetypes +// +//========================================================================== + +%type list_val {ListFilter} +%type arg_list {MoreFilters *} +%type boom_args {ParseBoomArg} +%type boom_op {int} +%type boom_selector {int} +%type boom_line {FBoomArg} +%type boom_body {MoreLines *} + + +boom_declaration ::= LBRACKET exp(special) RBRACKET LPAREN exp(firsttype) COMMA exp(lasttype) RPAREN LBRACE boom_body(stores) RBRACE. +{ + int i; + MoreLines *probe; + + if (NumBoomish == MAX_BOOMISH) + { + MoreLines *probe = stores; + + while (probe != NULL) + { + MoreLines *next = probe->next; + delete probe; + probe = next; + } + Printf ("%s, line %d: Too many BOOM translators\n", context->SourceFile, context->SourceLine); + } + else + { + Boomish[NumBoomish].FirstLinetype = firsttype; + Boomish[NumBoomish].LastLinetype = lasttype; + Boomish[NumBoomish].NewSpecial = special; + + for (i = 0, probe = stores; probe != NULL; i++) + { + MoreLines *next = probe->next; + Boomish[NumBoomish].Args.Push(probe->arg); + delete probe; + probe = next; + } + NumBoomish++; + } +} + +boom_body(A) ::= . /* empty */ +{ + A = NULL; +} +boom_body(A) ::= boom_line(B) boom_body(C). +{ + A = new MoreLines; + A->next = C; + A->arg = B; +} + +boom_line(A) ::= boom_selector(sel) boom_op(op) boom_args(args). +{ + A.bOrExisting = (op == OR_EQUAL); + A.bUseConstant = (args.filters == NULL); + A.ArgNum = sel; + A.ConstantValue = args.constant; + A.AndValue = args.mask; + + if (args.filters != NULL) + { + int i; + MoreFilters *probe; + + for (i = 0, probe = args.filters; probe != NULL; i++) + { + MoreFilters *next = probe->next; + if (i < 15) + { + A.ResultFilter[i] = probe->filter.filter; + A.ResultValue[i] = probe->filter.value; + } + else if (i == 15) + { + context->PrintError ("Lists can only have 15 elements"); + } + delete probe; + probe = next; + } + A.ListSize = i > 15 ? 15 : i; + } +} + +boom_selector(A) ::= FLAGS. { A = 4; } +boom_selector(A) ::= ARG2. { A = 0; } +boom_selector(A) ::= ARG3. { A = 1; } +boom_selector(A) ::= ARG4. { A = 2; } +boom_selector(A) ::= ARG5. { A = 3; } + +boom_op(A) ::= EQUALS. { A = '='; } +boom_op(A) ::= OR_EQUAL. { A = OR_EQUAL; } + +boom_args(A) ::= exp(B). +{ + A.constant = B; + A.filters = NULL; +} +boom_args(A) ::= exp(B) LBRACKET arg_list(C) RBRACKET. +{ + A.mask = B; + A.filters = C; +} + +arg_list(A) ::= list_val(B). +{ + A = new MoreFilters; + A->next = NULL; + A->filter = B; +} +arg_list(A) ::= list_val(B) COMMA arg_list(C). +{ + A = new MoreFilters; + A->next = C; + A->filter = B; +} + +list_val(A) ::= exp(B) COLON exp(C). +{ + A.filter = B; + A.value = C; +} + diff --git a/tools/xlatcc/Makefile b/tools/xlatcc/Makefile deleted file mode 100644 index 4d15400180..0000000000 --- a/tools/xlatcc/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -ifeq (Windows_NT,$(OS)) - WIN=1 - WINCMD=1 -endif -ifeq ($(findstring msys,$(shell sh --version 2>nul)),msys) - WIN=1 - WINCMD=0 -endif - -ifeq (1,$(WIN)) - EXE = xlatcc.exe - CFLAGS = $(LOC) -Os -Wall -fomit-frame-pointer -else - EXE = xlatcc - CFLAGS = -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp $(LOC) -Os -Wall -fomit-frame-pointer -endif - -CCDV = @../../ccdv -CC = gcc -LDFLAGS= -s - -LEMON = ../lemon/lemon -LEMONFLAGS = - -OBJS = gen.o xlat-parse.o - -all: $(EXE) - -$(EXE): $(OBJS) - $(CCDV) $(CC) $(LDFLAGS) -o $(EXE) $(OBJS) - -.PHONY: clean - -clean: -ifeq (1,$(WINCMD)) - -del /q /f $(EXE) 2>nul - -del /q /f *.o 2>nul -else - rm -f $(EXE) - rm -f *.o -endif - -xlat-parse.o: xlat-parse.c xlat.h xlat-parse.h - $(CCDV) $(CC) $(CFLAGS) -c -o $@ $< - -xlat-parse.c xlat-parse.h: xlat-parse.y - $(CCDV) $(LEMON) $(LEMONFLAGS) $< - -gen.o: gen.c xlat.h - $(CCDV) $(CC) $(CFLAGS) -c -o $@ $< diff --git a/tools/xlatcc/gen.c b/tools/xlatcc/gen.c deleted file mode 100644 index 010dec693b..0000000000 --- a/tools/xlatcc/gen.c +++ /dev/null @@ -1,275 +0,0 @@ -#include -#include -#include -#include "xlat.h" - -#define FILE_STACK 32 - -SimpleTranslator Simple[65536]; -BoomTranslator Boomish[MAX_BOOMISH]; - -int NumBoomish; - -FILE *Source; -char *SourceName; -int SourceLine; - -static FILE *SourceStack[FILE_STACK]; -static char *NameStack[FILE_STACK]; -static int LineStack[FILE_STACK]; -static int SourceStackSize; - -void yyparse (void); - -int CountSimpleTranslators (void) -{ - int i, count; - - for (i = 1, count = 0; i < 65536; i++) - { - if (Simple[i].NewSpecial != 0) - { - count++; - for ( ; i < 65536 && Simple[i].NewSpecial != 0; i++) - ; - } - } - return count; -} - -void WriteSimpleTranslators (FILE *file) -{ - int i, start, count; - - for (count = 0, i = 1; i < 65536; i++) - { - if (Simple[i].NewSpecial != 0) - { - start = i; - for ( ; i < 65536; i++) - { - if (Simple[i].NewSpecial == 0) - { - break; - } - } - - i--; - - // start = first linetype # - // i = last linetype # - - putc (start >> 8, file); - putc (start & 255, file); - putc (i >> 8, file); - putc (i & 255, file); - - for (; start <= i; start++) - { - putc (Simple[start].Flags, file); - putc (Simple[start].NewSpecial, file); - putc (Simple[start].Args[0], file); - putc (Simple[start].Args[1], file); - putc (Simple[start].Args[2], file); - putc (Simple[start].Args[3], file); - putc (Simple[start].Args[4], file); - count++; - } - } - } - printf ("Wrote %d normal linetypes\n", count); -} - -// BOOM translators are stored on disk as: -// -// WORD -// WORD -// BYTE -// repeat [BYTE op BYTES parms] -// -// op consists of some bits: -// -// 76543210 -// ||||||++-- Dest is arg[(op&3)+1] (arg[0] is always tag) -// |||||+---- 0 = store, 1 = or with existing value -// ||||+----- 0 = this is normal, 1 = x-op in next byte -// ++++------ # of elements in list, or 0 to always use a constant value -// -// If a constant value is used, parms is a single byte containing that value. -// Otherwise, parms has the format: -// -// WORD -// repeat [WORD BYTE ] -// -// These x-ops are defined: -// -// 0 = end of this BOOM translator -// 1 = dest is flags - -void WriteBoomTranslators (FILE *file) -{ - int i, j, k; - - for (i = 0; i < NumBoomish; i++) - { - putc (Boomish[i].FirstLinetype >> 8, file); - putc (Boomish[i].FirstLinetype & 255, file); - putc (Boomish[i].LastLinetype >> 8, file); - putc (Boomish[i].LastLinetype & 255, file); - putc (Boomish[i].NewSpecial, file); - - for (j = 0; j < MAX_BOOMISH_EXEC; j++) - { - if (Boomish[i].Args[j].bDefined) - { - BYTE op; - - if (Boomish[i].Args[j].ArgNum < 4) - { - op = Boomish[i].Args[j].ArgNum; - } - else - { - op = 8; - } - if (Boomish[i].Args[j].bOrExisting) - { - op |= 4; - } - if (!Boomish[i].Args[j].bUseConstant) - { - op |= Boomish[i].Args[j].ListSize << 4; - } - putc (op, file); - if (op & 8) - { - putc (Boomish[i].Args[j].ArgNum - 3, file); - } - if (Boomish[i].Args[j].bUseConstant) - { - putc (Boomish[i].Args[j].ConstantValue, file); - } - else - { - putc (Boomish[i].Args[j].AndValue >> 8, file); - putc (Boomish[i].Args[j].AndValue & 255, file); - for (k = 0; k < Boomish[i].Args[j].ListSize; k++) - { - putc (Boomish[i].Args[j].ResultFilter[k] >> 8, file); - putc (Boomish[i].Args[j].ResultFilter[k] & 255, file); - putc (Boomish[i].Args[j].ResultValue[k], file); - } - } - } - } - putc (8, file); - putc (0, file); - } - printf ("Wrote %d BOOM-style generalized linetypes\n", NumBoomish); -} - -void WriteTranslatorFile (FILE *file, int count) -{ - putc ('N', file); - putc ('O', file); - putc ('R', file); - putc ('M', file); - putc (count >> 8, file); - putc (count & 255, file); - WriteSimpleTranslators (file); - - putc ('B', file); - putc ('O', file); - putc ('O', file); - putc ('M', file); - putc (NumBoomish >> 8, file); - putc (NumBoomish & 255, file); - WriteBoomTranslators (file); -} - -void IncludeFile (const char *name) -{ - FILE *newsource; - - if (Source != NULL) - { - if (SourceStackSize == FILE_STACK) - { - printf ("Too many files included. Skipping %s\n", name); - return; - } - SourceStack[SourceStackSize] = Source; - LineStack[SourceStackSize] = SourceLine; - NameStack[SourceStackSize] = SourceName; - SourceStackSize++; - } - newsource = fopen (name, "r"); - if (newsource == NULL) - { - printf ("Cannot open %s\n", name); - if (Source != NULL) - { - SourceStackSize--; - } - return; - } - - Source = newsource; - SourceLine = 1; - SourceName = strdup (name); -} - -bool EndFile () -{ - if (Source != NULL) - { - fclose (Source); - } - if (SourceName != NULL) - { - free (SourceName); - } - if (SourceStackSize) - { - Source = SourceStack[--SourceStackSize]; - SourceName = NameStack[SourceStackSize]; - SourceLine = LineStack[SourceStackSize]; - - return 1; - } - return 0; -} - -int main (int argc, char **argv) -{ - FILE *output; - int count; - - if (argc != 3) - { - printf ("Usage: %s \n", argv[0]); - return -1; - } -#if !defined(NDEBUG) && 0 - ParseTrace(fopen("trace.txt", "w"), ":"); -#endif - IncludeFile (argv[1]); - yyparse (); - count = CountSimpleTranslators (); - if ((count | NumBoomish) != 0) - { - output = fopen (argv[2], "wb"); - if (output == NULL) - { - printf ("Could not open %s\n", argv[2]); - return -2; - } - WriteTranslatorFile (output, count); - fclose (output); - } - else - { - printf ("No linedef types to translate\n"); - } - return 0; -} diff --git a/tools/xlatcc/xlat-parse.c b/tools/xlatcc/xlat-parse.c deleted file mode 100644 index 33504302de..0000000000 --- a/tools/xlatcc/xlat-parse.c +++ /dev/null @@ -1,2167 +0,0 @@ -/* Driver template for the LEMON parser generator. -** The author disclaims copyright to this source code. -*/ -/* First off, code is included which follows the "include" declaration -** in the input file. */ -#include -#include -#include -#line 1 "xlat-parse.y" - -#include "xlat.h" -#include "xlat-parse.h" -#include -#include - -int yyerror (char *s); - -typedef struct _Symbol -{ - struct _Symbol *Next; - int Value; - char Sym[1]; -} Symbol; - -static bool FindToken (char *tok, int *type); -static void AddSym (char *sym, int val); -static bool FindSym (char *sym, Symbol **val); - -static int EnumVal; - -struct ListFilter -{ - WORD filter; - BYTE value; -}; - -typedef struct _morefilters -{ - struct _morefilters *next; - struct ListFilter filter; -} MoreFilters; - -typedef struct _morelines -{ - struct _morelines *next; - BoomArg arg; -} MoreLines; - -typedef struct _specialargs -{ - BYTE addflags; - BYTE args[5]; -} SpecialArgs; - -typedef struct _boomarg -{ - BYTE constant; - WORD mask; - MoreFilters *filters; -} ParseBoomArg; - -typedef union YYSTYPE -{ - int val; - char sym[80]; - char string[80]; - Symbol *symval; -} YYSTYPE; - -#include -#include - -int yylex (YYSTYPE *yylval) -{ - char token[80]; - int toksize; - int c; - -loop: - while (Source == NULL) - { - if (!EndFile ()) - return 0; - } - while (isspace (c = fgetc (Source)) && c != EOF) - { - if (c == '\n') - SourceLine++; - } - - if (c == EOF) - { - if (EndFile ()) - goto loop; - return 0; - } - if (isdigit (c)) - { - int buildup = c - '0'; - if (c == '0') - { - c = fgetc (Source); - if (c == 'x' || c == 'X') - { - for (;;) - { - c = fgetc (Source); - if (isdigit (c)) - { - buildup = (buildup<<4) + c - '0'; - } - else if (c >= 'a' && c <= 'f') - { - buildup = (buildup<<4) + c - 'a' + 10; - } - else if (c >= 'A' && c <= 'F') - { - buildup = (buildup<<4) + c - 'A' + 10; - } - else - { - ungetc (c, Source); - yylval->val = buildup; - return NUM; - } - } - } - else - { - ungetc (c, Source); - } - } - while (isdigit (c = fgetc (Source))) - { - buildup = buildup*10 + c - '0'; - } - ungetc (c, Source); - yylval->val = buildup; - return NUM; - } - if (isalpha (c)) - { - int buildup = 0; - - token[0] = c; - toksize = 1; - while (toksize < 79 && (isalnum (c = fgetc (Source)) || c == '_')) - { - token[toksize++] = c; - } - token[toksize] = 0; - if (toksize == 79 && isalnum (c)) - { - while (isalnum (c = fgetc (Source))) - ; - } - ungetc (c, Source); - if (FindToken (token, &buildup)) - { - return buildup; - } - if (FindSym (token, &yylval->symval)) - { - return SYMNUM; - } - strcpy (yylval->sym, token); - return SYM; - } - if (c == '/') - { - c = fgetc (Source); - if (c == '*') - { - for (;;) - { - while ((c = fgetc (Source)) != '*' && c != EOF) - { - if (c == '\n') - SourceLine++; - } - if (c == EOF) - return 0; - if ((c = fgetc (Source)) == '/') - goto loop; - if (c == EOF) - return 0; - ungetc (c, Source); - } - } - else if (c == '/') - { - while ((c = fgetc (Source)) != '\n' && c != EOF) - ; - if (c == '\n') - SourceLine++; - else if (c == EOF) - return 0; - goto loop; - } - else - { - ungetc (c, Source); - return DIVIDE; - } - } - if (c == '"') - { - int tokensize = 0; - while ((c = fgetc (Source)) != '"' && c != EOF) - { - yylval->string[tokensize++] = c; - } - yylval->string[tokensize] = 0; - return STRING; - } - if (c == '|') - { - c = fgetc (Source); - if (c == '=') - return OR_EQUAL; - ungetc (c, Source); - return OR; - } - switch (c) - { - case '^': return XOR; - case '&': return AND; - case '-': return MINUS; - case '+': return PLUS; - case '*': return MULTIPLY; - case '(': return LPAREN; - case ')': return RPAREN; - case ',': return COMMA; - case '{': return LBRACE; - case '}': return RBRACE; - case '=': return EQUALS; - case ';': return SEMICOLON; - case ':': return COLON; - case '[': return LBRACKET; - case ']': return RBRACKET; - default: return 0; - } -} - -void *ParseAlloc(void *(*mallocProc)(size_t)); -void Parse(void *yyp, int yymajor, YYSTYPE yyminor); -void ParseFree(void *p, void (*freeProc)(void*)); -void ParseTrace(FILE *TraceFILE, char *zTracePrompt); - -void yyparse (void) -{ - void *pParser = ParseAlloc (malloc); - YYSTYPE token; - int tokentype; - int include_state = 0; - - while ((tokentype = yylex(&token)) != 0) - { - /* Whenever the sequence INCLUDE STRING is encountered in the token - * stream, feed a dummy NOP token to the parser so that it will - * reduce the include_statement before grabbing any more tokens - * from the current file. - */ - if (tokentype == INCLUDE && include_state == 0) - { - include_state = 1; - } - else if (tokentype == STRING && include_state == 1) - { - include_state = 2; - } - else - { - include_state = 0; - } - Parse (pParser, tokentype, token); - if (include_state == 2) - { - include_state = 0; - Parse (pParser, NOP, token); - } - } - memset (&token, 0, sizeof(token)); - Parse (pParser, 0, token); - ParseFree (pParser, free); -} - -static Symbol *FirstSym; - -static void AddSym (char *sym, int val) -{ - Symbol *syme = malloc (strlen (sym) + sizeof(Symbol)); - syme->Next = FirstSym; - syme->Value = val; - strcpy (syme->Sym, sym); - FirstSym = syme; -} - -static bool FindSym (char *sym, Symbol **val) -{ - Symbol *syme = FirstSym; - - while (syme != NULL) - { - if (strcmp (syme->Sym, sym) == 0) - { - *val = syme; - return 1; - } - syme = syme->Next; - } - return 0; -} - -static bool FindToken (char *tok, int *type) -{ - static const char tokens[][8] = - { - "endl", "print", "include", "special", "define", "enum", - "arg5", "arg4", "arg3", "arg2", "flags", "lineid", "tag" - - }; - static const short types[] = - { - ENDL, PRINT, INCLUDE, SPECIAL, DEFINE, ENUM, - ARG5, ARG4, ARG3, ARG2, FLAGS, LINEID, TAG - }; - int i; - - for (i = sizeof(tokens)/sizeof(tokens[0])-1; i >= 0; i--) - { - if (strcmp (tok, tokens[i]) == 0) - { - *type = types[i]; - return 1; - } - } - return 0; -} - -int yyerror (char *s) -{ - if (SourceName != NULL) - printf ("%s, line %d: %s\n", SourceName, SourceLine, s); - else - printf ("%s\n", s); - return 0; -} - -#line 351 "xlat-parse.c" -/* Next is all token values, in a form suitable for use by makeheaders. -** This section will be null unless lemon is run with the -m switch. -*/ -/* -** These constants (all generated automatically by the parser generator) -** specify the various kinds of tokens (terminals) that the parser -** understands. -** -** Each symbol here is a terminal symbol in the grammar. -*/ -/* Make sure the INTERFACE macro is defined. -*/ -#ifndef INTERFACE -# define INTERFACE 1 -#endif -/* The next thing included is series of defines which control -** various aspects of the generated parser. -** YYCODETYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 terminals -** and nonterminals. "int" is used otherwise. -** YYNOCODE is a number of type YYCODETYPE which corresponds -** to no legal terminal or nonterminal number. This -** number is used to fill in empty slots of the hash -** table. -** YYFALLBACK If defined, this indicates that one or more tokens -** have fall-back values which should be used if the -** original value of the token will not parse. -** YYACTIONTYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 rules and -** states combined. "int" is used otherwise. -** ParseTOKENTYPE is the data type used for minor tokens given -** directly to the parser from the tokenizer. -** YYMINORTYPE is the data type used for all minor tokens. -** This is typically a union of many types, one of -** which is ParseTOKENTYPE. The entry in the union -** for base tokens is called "yy0". -** YYSTACKDEPTH is the maximum depth of the parser's stack. If -** zero the stack is dynamically sized using realloc() -** ParseARG_SDECL A static variable declaration for the %extra_argument -** ParseARG_PDECL A parameter declaration for the %extra_argument -** ParseARG_STORE Code to store %extra_argument into yypParser -** ParseARG_FETCH Code to extract %extra_argument from yypParser -** YYNSTATE the combined number of states. -** YYNRULE the number of rules in the grammar -** YYERRORSYMBOL is the code number of the error symbol. If not -** defined, then do no error processing. -*/ -#define YYCODETYPE unsigned char -#define YYNOCODE 67 -#define YYACTIONTYPE unsigned short int -#define ParseTOKENTYPE YYSTYPE -typedef union { - ParseTOKENTYPE yy0; - struct ListFilter yy20; - MoreFilters * yy39; - MoreLines * yy57; - int yy64; - BoomArg yy65; - ParseBoomArg yy87; - SpecialArgs yy123; -} YYMINORTYPE; -#ifndef YYSTACKDEPTH -#define YYSTACKDEPTH 100 -#endif -#define ParseARG_SDECL -#define ParseARG_PDECL -#define ParseARG_FETCH -#define ParseARG_STORE -#define YYNSTATE 174 -#define YYNRULE 94 -#define YY_NO_ACTION (YYNSTATE+YYNRULE+2) -#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) -#define YY_ERROR_ACTION (YYNSTATE+YYNRULE) - -/* Next are that tables used to determine what action to take based on the -** current state and lookahead token. These tables are used to implement -** functions that take a state number and lookahead value and return an -** action integer. -** -** Suppose the action integer is N. Then the action is determined as -** follows -** -** 0 <= N < YYNSTATE Shift N. That is, push the lookahead -** token onto the stack and goto state N. -** -** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE. -** -** N == YYNSTATE+YYNRULE A syntax error has occurred. -** -** N == YYNSTATE+YYNRULE+1 The parser accepts its input. -** -** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused -** slots in the yy_action[] table. -** -** The action table is constructed as a single large table named yy_action[]. -** Given state S and lookahead X, the action is computed as -** -** yy_action[ yy_shift_ofst[S] + X ] -** -** If the index value yy_shift_ofst[S]+X is out of range or if the value -** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] -** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table -** and that yy_default[S] should be used instead. -** -** The formula above is for computing the action when the lookahead is -** a terminal symbol. If the lookahead is a non-terminal (as occurs after -** a reduce action) then the yy_reduce_ofst[] array is used in place of -** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of -** YY_SHIFT_USE_DFLT. -** -** The following are the tables generated in this section: -** -** yy_action[] A single table containing all actions. -** yy_lookahead[] A table containing the lookahead for each entry in -** yy_action. Used to detect hash collisions. -** yy_shift_ofst[] For each state, the offset into yy_action for -** shifting terminals. -** yy_reduce_ofst[] For each state, the offset into yy_action for -** shifting non-terminals after a reduce. -** yy_default[] Default action for each state. -*/ -static const YYACTIONTYPE yy_action[] = { - /* 0 */ 174, 30, 71, 123, 30, 70, 157, 152, 26, 157, - /* 10 */ 152, 26, 79, 144, 115, 83, 126, 80, 104, 166, - /* 20 */ 109, 64, 120, 128, 127, 6, 71, 102, 53, 154, - /* 30 */ 150, 164, 149, 148, 147, 146, 145, 100, 140, 16, - /* 40 */ 162, 39, 34, 37, 54, 32, 55, 41, 39, 34, - /* 50 */ 37, 54, 32, 55, 41, 49, 34, 37, 54, 32, - /* 60 */ 55, 41, 51, 11, 39, 34, 37, 54, 32, 55, - /* 70 */ 41, 39, 34, 37, 54, 32, 55, 41, 50, 37, - /* 80 */ 54, 32, 55, 41, 9, 44, 14, 39, 34, 37, - /* 90 */ 54, 32, 55, 41, 39, 34, 37, 54, 32, 55, - /* 100 */ 41, 45, 169, 170, 171, 172, 173, 81, 42, 151, - /* 110 */ 39, 34, 37, 54, 32, 55, 41, 54, 32, 55, - /* 120 */ 41, 136, 79, 39, 34, 37, 54, 32, 55, 41, - /* 130 */ 39, 34, 37, 54, 32, 55, 41, 39, 34, 37, - /* 140 */ 54, 32, 55, 41, 29, 56, 5, 124, 139, 23, - /* 150 */ 163, 20, 155, 39, 34, 37, 54, 32, 55, 41, - /* 160 */ 39, 34, 37, 54, 32, 55, 41, 39, 34, 37, - /* 170 */ 54, 32, 55, 41, 47, 56, 5, 153, 132, 114, - /* 180 */ 7, 19, 39, 34, 37, 54, 32, 55, 41, 39, - /* 190 */ 34, 37, 54, 32, 55, 41, 39, 34, 37, 54, - /* 200 */ 32, 55, 41, 167, 86, 24, 30, 82, 112, 114, - /* 210 */ 36, 157, 152, 26, 168, 101, 110, 39, 34, 37, - /* 220 */ 54, 32, 55, 41, 142, 106, 55, 41, 159, 86, - /* 230 */ 39, 34, 37, 54, 32, 55, 41, 39, 34, 37, - /* 240 */ 54, 32, 55, 41, 52, 64, 98, 128, 165, 108, - /* 250 */ 106, 21, 117, 39, 34, 37, 54, 32, 55, 41, - /* 260 */ 39, 34, 37, 54, 32, 55, 41, 25, 269, 1, - /* 270 */ 10, 82, 39, 34, 37, 54, 32, 55, 41, 4, - /* 280 */ 121, 68, 43, 122, 131, 39, 34, 37, 54, 32, - /* 290 */ 55, 41, 39, 34, 37, 54, 32, 55, 41, 18, - /* 300 */ 94, 130, 78, 27, 57, 35, 17, 60, 39, 34, - /* 310 */ 37, 54, 32, 55, 41, 39, 34, 37, 54, 32, - /* 320 */ 55, 41, 31, 39, 34, 37, 54, 32, 55, 41, - /* 330 */ 39, 34, 37, 54, 32, 55, 41, 33, 59, 30, - /* 340 */ 28, 13, 30, 107, 157, 152, 26, 157, 152, 26, - /* 350 */ 30, 141, 138, 30, 116, 157, 152, 26, 157, 152, - /* 360 */ 26, 30, 12, 125, 30, 84, 157, 152, 26, 157, - /* 370 */ 152, 26, 30, 137, 111, 119, 3, 157, 152, 26, - /* 380 */ 66, 15, 129, 133, 85, 103, 40, 62, 22, 61, - /* 390 */ 93, 135, 161, 158, 134, 87, 118, 143, 95, 38, - /* 400 */ 65, 2, 97, 46, 113, 48, 88, 156, 105, 67, - /* 410 */ 270, 96, 8, 69, 99, 91, 160, 270, 270, 72, - /* 420 */ 90, 74, 77, 76, 270, 270, 75, 270, 270, 270, - /* 430 */ 92, 270, 58, 73, 270, 89, 270, 63, -}; -static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 0, 4, 39, 40, 4, 39, 9, 10, 11, 9, - /* 10 */ 10, 11, 39, 13, 14, 39, 19, 39, 18, 43, - /* 20 */ 20, 39, 22, 41, 42, 25, 39, 40, 28, 51, - /* 30 */ 52, 53, 54, 55, 56, 57, 58, 64, 65, 61, - /* 40 */ 29, 1, 2, 3, 4, 5, 6, 7, 1, 2, - /* 50 */ 3, 4, 5, 6, 7, 15, 2, 3, 4, 5, - /* 60 */ 6, 7, 15, 44, 1, 2, 3, 4, 5, 6, - /* 70 */ 7, 1, 2, 3, 4, 5, 6, 7, 15, 3, - /* 80 */ 4, 5, 6, 7, 11, 15, 11, 1, 2, 3, - /* 90 */ 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, - /* 100 */ 7, 15, 30, 31, 32, 33, 34, 39, 15, 21, - /* 110 */ 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, - /* 120 */ 7, 12, 39, 1, 2, 3, 4, 5, 6, 7, - /* 130 */ 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, - /* 140 */ 4, 5, 6, 7, 15, 45, 46, 47, 65, 27, - /* 150 */ 39, 15, 12, 1, 2, 3, 4, 5, 6, 7, - /* 160 */ 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, - /* 170 */ 4, 5, 6, 7, 15, 45, 46, 47, 62, 63, - /* 180 */ 28, 15, 1, 2, 3, 4, 5, 6, 7, 1, - /* 190 */ 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, - /* 200 */ 5, 6, 7, 24, 39, 24, 4, 39, 62, 63, - /* 210 */ 15, 9, 10, 11, 35, 27, 48, 1, 2, 3, - /* 220 */ 4, 5, 6, 7, 59, 60, 6, 7, 12, 39, - /* 230 */ 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, - /* 240 */ 4, 5, 6, 7, 15, 39, 39, 41, 42, 59, - /* 250 */ 60, 15, 19, 1, 2, 3, 4, 5, 6, 7, - /* 260 */ 1, 2, 3, 4, 5, 6, 7, 15, 49, 50, - /* 270 */ 11, 39, 1, 2, 3, 4, 5, 6, 7, 23, - /* 280 */ 48, 39, 15, 12, 12, 1, 2, 3, 4, 5, - /* 290 */ 6, 7, 1, 2, 3, 4, 5, 6, 7, 15, - /* 300 */ 39, 23, 39, 15, 39, 15, 15, 39, 1, 2, - /* 310 */ 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, - /* 320 */ 6, 7, 15, 1, 2, 3, 4, 5, 6, 7, - /* 330 */ 1, 2, 3, 4, 5, 6, 7, 15, 39, 4, - /* 340 */ 24, 11, 4, 29, 9, 10, 11, 9, 10, 11, - /* 350 */ 4, 16, 17, 4, 10, 9, 10, 11, 9, 10, - /* 360 */ 11, 4, 15, 19, 4, 39, 9, 10, 11, 9, - /* 370 */ 10, 11, 4, 26, 36, 37, 11, 9, 10, 11, - /* 380 */ 39, 15, 36, 21, 39, 36, 15, 39, 15, 39, - /* 390 */ 39, 12, 39, 36, 16, 39, 36, 12, 39, 11, - /* 400 */ 39, 15, 39, 11, 36, 15, 39, 12, 19, 39, - /* 410 */ 66, 39, 15, 39, 39, 39, 39, 66, 66, 39, - /* 420 */ 39, 39, 39, 39, 66, 66, 39, 66, 66, 66, - /* 430 */ 39, 66, 39, 39, 66, 39, 66, 39, -}; -#define YY_SHIFT_USE_DFLT (-4) -#define YY_SHIFT_MAX 129 -static const short yy_shift_ofst[] = { - /* 0 */ -4, 0, 335, 335, 72, 72, 202, 202, 202, 338, - /* 10 */ 338, 202, 202, 202, 202, 233, 233, 346, 349, 368, - /* 20 */ 357, -3, 360, 202, 202, 202, 202, 202, 202, 202, - /* 30 */ 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, - /* 40 */ 202, 202, 202, 202, 202, 202, 202, 202, 202, 202, - /* 50 */ 202, 202, 202, 202, 202, 202, 179, 229, 40, 63, - /* 60 */ 70, 86, 93, 109, 122, 129, 136, 322, 314, 307, - /* 70 */ 291, 284, 271, 259, 252, 236, 47, 216, 195, 188, - /* 80 */ 181, 166, 159, 152, 329, 329, 329, 329, 329, 329, - /* 90 */ 329, 329, 329, 329, 329, 54, 76, 113, 220, 220, - /* 100 */ 347, 344, 395, 390, 389, 392, 386, 388, 385, 378, - /* 110 */ 379, 373, 362, 371, 366, 365, 330, 316, 290, 288, - /* 120 */ 278, 272, 256, 140, 88, 75, 73, 11, 397, 267, -}; -#define YY_REDUCE_USE_DFLT (-38) -#define YY_REDUCE_MAX 56 -static const short yy_reduce_ofst[] = { - /* 0 */ 219, -22, 165, 190, 100, 130, -27, -18, 206, -37, - /* 10 */ -13, -24, 83, 168, 232, 116, 146, 68, -34, 341, - /* 20 */ 396, 394, 393, 391, 387, 384, 383, 382, 381, 380, - /* 30 */ 377, 376, 375, 374, 372, 370, 367, 363, 361, 359, - /* 40 */ 356, 353, 351, 350, 348, 345, 398, 326, 299, 268, - /* 50 */ 265, 263, 261, 242, 207, 111, 19, -}; -static const YYACTIONTYPE yy_default[] = { - /* 0 */ 186, 268, 197, 197, 223, 223, 268, 268, 268, 238, - /* 10 */ 238, 268, 268, 217, 217, 207, 207, 268, 268, 268, - /* 20 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, - /* 30 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, - /* 40 */ 268, 268, 268, 268, 268, 268, 268, 268, 268, 268, - /* 50 */ 268, 268, 268, 268, 268, 268, 268, 260, 240, 259, - /* 60 */ 241, 263, 242, 268, 268, 268, 256, 245, 268, 246, - /* 70 */ 254, 253, 268, 268, 249, 268, 250, 268, 251, 268, - /* 80 */ 268, 255, 218, 233, 219, 264, 201, 266, 252, 257, - /* 90 */ 211, 247, 237, 243, 261, 181, 183, 182, 178, 177, - /* 100 */ 268, 268, 268, 258, 268, 268, 198, 268, 268, 268, - /* 110 */ 268, 239, 268, 265, 208, 268, 268, 210, 244, 248, - /* 120 */ 268, 268, 268, 268, 268, 268, 268, 268, 235, 262, - /* 130 */ 206, 215, 209, 205, 204, 216, 203, 212, 202, 214, - /* 140 */ 213, 200, 199, 196, 195, 194, 193, 192, 191, 190, - /* 150 */ 188, 222, 176, 224, 187, 221, 220, 175, 267, 185, - /* 160 */ 184, 180, 234, 179, 189, 236, 225, 231, 232, 226, - /* 170 */ 227, 228, 229, 230, -}; -#define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0])) - -/* The next table maps tokens into fallback tokens. If a construct -** like the following: -** -** %fallback ID X Y Z. -** -** appears in the grammer, then ID becomes a fallback token for X, Y, -** and Z. Whenever one of the tokens X, Y, or Z is input to the parser -** but it does not parse, the type of the token is changed to ID and -** the parse is retried before an error is thrown. -*/ -#ifdef YYFALLBACK -static const YYCODETYPE yyFallback[] = { -}; -#endif /* YYFALLBACK */ - -/* The following structure represents a single element of the -** parser's stack. Information stored includes: -** -** + The state number for the parser at this level of the stack. -** -** + The value of the token stored at this level of the stack. -** (In other words, the "major" token.) -** -** + The semantic value stored at this level of the stack. This is -** the information used by the action routines in the grammar. -** It is sometimes called the "minor" token. -*/ -struct yyStackEntry { - int stateno; /* The state-number */ - int major; /* The major token value. This is the code - ** number for the token at this stack level */ - YYMINORTYPE minor; /* The user-supplied minor token value. This - ** is the value of the token */ -}; -typedef struct yyStackEntry yyStackEntry; - -/* The state of the parser is completely contained in an instance of -** the following structure */ -struct yyParser { - int yyidx; /* Index of top element in stack */ - int yyerrcnt; /* Shifts left before out of the error */ - ParseARG_SDECL /* A place to hold %extra_argument */ -#if YYSTACKDEPTH<=0 - int yystksz; /* Current side of the stack */ - yyStackEntry *yystack; /* The parser's stack */ -#else - yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ -#endif -}; -typedef struct yyParser yyParser; - -#ifndef NDEBUG -#include -static FILE *yyTraceFILE = 0; -static char *yyTracePrompt = 0; -#endif /* NDEBUG */ - -#ifndef NDEBUG -/* -** Turn parser tracing on by giving a stream to which to write the trace -** and a prompt to preface each trace message. Tracing is turned off -** by making either argument NULL -** -** Inputs: -**
    -**
  • A FILE* to which trace output should be written. -** If NULL, then tracing is turned off. -**
  • A prefix string written at the beginning of every -** line of trace output. If NULL, then tracing is -** turned off. -**
-** -** Outputs: -** None. -*/ -void ParseTrace(FILE *TraceFILE, char *zTracePrompt){ - yyTraceFILE = TraceFILE; - yyTracePrompt = zTracePrompt; - if( yyTraceFILE==0 ) yyTracePrompt = 0; - else if( yyTracePrompt==0 ) yyTraceFILE = 0; -} -#endif /* NDEBUG */ - -#ifndef NDEBUG -/* For tracing shifts, the names of all terminals and nonterminals -** are required. The following table supplies these names */ -static const char *const yyTokenName[] = { - "$", "OR", "XOR", "AND", - "MINUS", "PLUS", "MULTIPLY", "DIVIDE", - "NEG", "NUM", "SYMNUM", "LPAREN", - "RPAREN", "NOP", "PRINT", "COMMA", - "STRING", "ENDL", "DEFINE", "SYM", - "INCLUDE", "RBRACE", "ENUM", "LBRACE", - "EQUALS", "SPECIAL", "SEMICOLON", "COLON", - "LBRACKET", "RBRACKET", "FLAGS", "ARG2", - "ARG3", "ARG4", "ARG5", "OR_EQUAL", - "TAG", "LINEID", "error", "exp", - "special_args", "list_val", "arg_list", "boom_args", - "boom_op", "boom_selector", "boom_line", "boom_body", - "maybe_argcount", "main", "translation_unit", "external_declaration", - "define_statement", "include_statement", "print_statement", "enum_statement", - "linetype_declaration", "boom_declaration", "special_declaration", "print_list", - "print_item", "enum_open", "enum_list", "single_enum", - "special_list", "special_def", -}; -#endif /* NDEBUG */ - -#ifndef NDEBUG -/* For tracing reduce actions, the names of all rules are required. -*/ -static const char *const yyRuleName[] = { - /* 0 */ "main ::= translation_unit", - /* 1 */ "exp ::= NUM", - /* 2 */ "exp ::= SYMNUM", - /* 3 */ "exp ::= exp PLUS exp", - /* 4 */ "exp ::= exp MINUS exp", - /* 5 */ "exp ::= exp MULTIPLY exp", - /* 6 */ "exp ::= exp DIVIDE exp", - /* 7 */ "exp ::= exp OR exp", - /* 8 */ "exp ::= exp AND exp", - /* 9 */ "exp ::= exp XOR exp", - /* 10 */ "exp ::= MINUS exp", - /* 11 */ "exp ::= LPAREN exp RPAREN", - /* 12 */ "translation_unit ::=", - /* 13 */ "translation_unit ::= translation_unit external_declaration", - /* 14 */ "external_declaration ::= define_statement", - /* 15 */ "external_declaration ::= include_statement", - /* 16 */ "external_declaration ::= print_statement", - /* 17 */ "external_declaration ::= enum_statement", - /* 18 */ "external_declaration ::= linetype_declaration", - /* 19 */ "external_declaration ::= boom_declaration", - /* 20 */ "external_declaration ::= special_declaration", - /* 21 */ "external_declaration ::= NOP", - /* 22 */ "print_statement ::= PRINT LPAREN print_list RPAREN", - /* 23 */ "print_list ::=", - /* 24 */ "print_list ::= print_item", - /* 25 */ "print_list ::= print_item COMMA print_list", - /* 26 */ "print_item ::= STRING", - /* 27 */ "print_item ::= exp", - /* 28 */ "print_item ::= ENDL", - /* 29 */ "define_statement ::= DEFINE SYM LPAREN exp RPAREN", - /* 30 */ "include_statement ::= INCLUDE STRING", - /* 31 */ "enum_statement ::= enum_open enum_list RBRACE", - /* 32 */ "enum_open ::= ENUM LBRACE", - /* 33 */ "enum_list ::=", - /* 34 */ "enum_list ::= single_enum", - /* 35 */ "enum_list ::= single_enum COMMA enum_list", - /* 36 */ "single_enum ::= SYM", - /* 37 */ "single_enum ::= SYM EQUALS exp", - /* 38 */ "special_declaration ::= SPECIAL special_list SEMICOLON", - /* 39 */ "special_list ::= special_def", - /* 40 */ "special_list ::= special_list COMMA special_def", - /* 41 */ "special_def ::= exp COLON SYM LPAREN maybe_argcount RPAREN", - /* 42 */ "special_def ::= exp COLON SYMNUM LPAREN maybe_argcount RPAREN", - /* 43 */ "maybe_argcount ::=", - /* 44 */ "maybe_argcount ::= exp", - /* 45 */ "maybe_argcount ::= exp COMMA exp", - /* 46 */ "linetype_declaration ::= exp EQUALS exp COMMA exp LPAREN special_args RPAREN", - /* 47 */ "linetype_declaration ::= exp EQUALS exp COMMA SYM LPAREN special_args RPAREN", - /* 48 */ "boom_declaration ::= LBRACKET exp RBRACKET LPAREN exp COMMA exp RPAREN LBRACE boom_body RBRACE", - /* 49 */ "boom_body ::=", - /* 50 */ "boom_body ::= boom_line boom_body", - /* 51 */ "boom_line ::= boom_selector boom_op boom_args", - /* 52 */ "boom_selector ::= FLAGS", - /* 53 */ "boom_selector ::= ARG2", - /* 54 */ "boom_selector ::= ARG3", - /* 55 */ "boom_selector ::= ARG4", - /* 56 */ "boom_selector ::= ARG5", - /* 57 */ "boom_op ::= EQUALS", - /* 58 */ "boom_op ::= OR_EQUAL", - /* 59 */ "boom_args ::= exp", - /* 60 */ "boom_args ::= exp LBRACKET arg_list RBRACKET", - /* 61 */ "arg_list ::= list_val", - /* 62 */ "arg_list ::= list_val COMMA arg_list", - /* 63 */ "list_val ::= exp COLON exp", - /* 64 */ "special_args ::=", - /* 65 */ "special_args ::= TAG", - /* 66 */ "special_args ::= TAG COMMA exp", - /* 67 */ "special_args ::= TAG COMMA exp COMMA exp", - /* 68 */ "special_args ::= TAG COMMA exp COMMA exp COMMA exp", - /* 69 */ "special_args ::= TAG COMMA exp COMMA exp COMMA exp COMMA exp", - /* 70 */ "special_args ::= TAG COMMA TAG", - /* 71 */ "special_args ::= TAG COMMA TAG COMMA exp", - /* 72 */ "special_args ::= TAG COMMA TAG COMMA exp COMMA exp", - /* 73 */ "special_args ::= TAG COMMA TAG COMMA exp COMMA exp COMMA exp", - /* 74 */ "special_args ::= LINEID", - /* 75 */ "special_args ::= LINEID COMMA exp", - /* 76 */ "special_args ::= LINEID COMMA exp COMMA exp", - /* 77 */ "special_args ::= LINEID COMMA exp COMMA exp COMMA exp", - /* 78 */ "special_args ::= LINEID COMMA exp COMMA exp COMMA exp COMMA exp", - /* 79 */ "special_args ::= exp", - /* 80 */ "special_args ::= exp COMMA exp", - /* 81 */ "special_args ::= exp COMMA exp COMMA exp", - /* 82 */ "special_args ::= exp COMMA exp COMMA exp COMMA exp", - /* 83 */ "special_args ::= exp COMMA exp COMMA exp COMMA exp COMMA exp", - /* 84 */ "special_args ::= exp COMMA TAG", - /* 85 */ "special_args ::= exp COMMA TAG COMMA exp", - /* 86 */ "special_args ::= exp COMMA TAG COMMA exp COMMA exp", - /* 87 */ "special_args ::= exp COMMA TAG COMMA exp COMMA exp COMMA exp", - /* 88 */ "special_args ::= exp COMMA exp COMMA TAG", - /* 89 */ "special_args ::= exp COMMA exp COMMA TAG COMMA exp", - /* 90 */ "special_args ::= exp COMMA exp COMMA TAG COMMA exp COMMA exp", - /* 91 */ "special_args ::= exp COMMA exp COMMA exp COMMA TAG", - /* 92 */ "special_args ::= exp COMMA exp COMMA exp COMMA TAG COMMA exp", - /* 93 */ "special_args ::= exp COMMA exp COMMA exp COMMA exp COMMA TAG", -}; -#endif /* NDEBUG */ - -#if YYSTACKDEPTH<=0 -/* -** Try to increase the size of the parser stack. -*/ -static void yyGrowStack(yyParser *p){ - int newSize; - yyStackEntry *pNew; - - newSize = p->yystksz*2 + 100; - pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); - if( pNew ){ - p->yystack = pNew; - p->yystksz = newSize; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sStack grows to %d entries!\n", - yyTracePrompt, p->yystksz); - } -#endif - } -} -#endif - -/* -** This function allocates a new parser. -** The only argument is a pointer to a function which works like -** malloc. -** -** Inputs: -** A pointer to the function used to allocate memory. -** -** Outputs: -** A pointer to a parser. This pointer is used in subsequent calls -** to Parse and ParseFree. -*/ -void *ParseAlloc(void *(*mallocProc)(size_t)){ - yyParser *pParser; - pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); - if( pParser ){ - pParser->yyidx = -1; -#if YYSTACKDEPTH<=0 - yyGrowStack(pParser); -#endif - } - return pParser; -} - -/* The following function deletes the value associated with a -** symbol. The symbol can be either a terminal or nonterminal. -** "yymajor" is the symbol code, and "yypminor" is a pointer to -** the value. -*/ -static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){ - switch( yymajor ){ - /* Here is inserted the actions which take place when a - ** terminal or non-terminal is destroyed. This can happen - ** when the symbol is popped from the stack during a - ** reduce or during error processing or when a parser is - ** being destroyed before it is finished parsing. - ** - ** Note: during a reduce, the only symbols destroyed are those - ** which appear on the RHS of the rule, but which are not used - ** inside the C code. - */ - default: break; /* If no destructor action specified: do nothing */ - } -} - -/* -** Pop the parser's stack once. -** -** If there is a destructor routine associated with the token which -** is popped from the stack, then call it. -** -** Return the major token number for the symbol popped. -*/ -static int yy_pop_parser_stack(yyParser *pParser){ - YYCODETYPE yymajor; - yyStackEntry *yytos = &pParser->yystack[pParser->yyidx]; - - if( pParser->yyidx<0 ) return 0; -#ifndef NDEBUG - if( yyTraceFILE && pParser->yyidx>=0 ){ - fprintf(yyTraceFILE,"%sPopping %s\n", - yyTracePrompt, - yyTokenName[yytos->major]); - } -#endif - yymajor = yytos->major; - yy_destructor( yymajor, &yytos->minor); - pParser->yyidx--; - return yymajor; -} - -/* -** Deallocate and destroy a parser. Destructors are all called for -** all stack elements before shutting the parser down. -** -** Inputs: -**
    -**
  • A pointer to the parser. This should be a pointer -** obtained from ParseAlloc. -**
  • A pointer to a function used to reclaim memory obtained -** from malloc. -**
-*/ -void ParseFree( - void *p, /* The parser to be deleted */ - void (*freeProc)(void*) /* Function used to reclaim memory */ -){ - yyParser *pParser = (yyParser*)p; - if( pParser==0 ) return; - while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); -#if YYSTACKDEPTH<=0 - free(pParser->yystack); -#endif - (*freeProc)((void*)pParser); -} - -/* -** Find the appropriate action for a parser given the terminal -** look-ahead token iLookAhead. -** -** If the look-ahead token is YYNOCODE, then check to see if the action is -** independent of the look-ahead. If it is, return the action, otherwise -** return YY_NO_ACTION. -*/ -static int yy_find_shift_action( - yyParser *pParser, /* The parser */ - YYCODETYPE iLookAhead /* The look-ahead token */ -){ - int i; - int stateno = pParser->yystack[pParser->yyidx].stateno; - - if( stateno>YY_SHIFT_MAX || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){ - return yy_default[stateno]; - } - assert( iLookAhead!=YYNOCODE ); - i += iLookAhead; - if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ - if( iLookAhead>0 ){ -#ifdef YYFALLBACK - int iFallback; /* Fallback token */ - if( iLookAhead %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); - } -#endif - return yy_find_shift_action(pParser, iFallback); - } -#endif -#ifdef YYWILDCARD - { - int j = i - iLookAhead + YYWILDCARD; - if( j>=0 && j %s\n", - yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); - } -#endif /* NDEBUG */ - return yy_action[j]; - } - } -#endif /* YYWILDCARD */ - } - return yy_default[stateno]; - }else{ - return yy_action[i]; - } -} - -/* -** Find the appropriate action for a parser given the non-terminal -** look-ahead token iLookAhead. -** -** If the look-ahead token is YYNOCODE, then check to see if the action is -** independent of the look-ahead. If it is, return the action, otherwise -** return YY_NO_ACTION. -*/ -static int yy_find_reduce_action( - int stateno, /* Current state number */ - YYCODETYPE iLookAhead /* The look-ahead token */ -){ - int i; - if( stateno>YY_REDUCE_MAX || - (i = yy_reduce_ofst[stateno])==YY_REDUCE_USE_DFLT ){ - return yy_default[stateno]; - } - assert( i!=YY_REDUCE_USE_DFLT ); - assert( iLookAhead!=YYNOCODE ); - i += iLookAhead; - if( i<0 || i>=YY_SZ_ACTTAB || yy_lookahead[i]!=iLookAhead ){ - return yy_default[stateno]; - }else{ - return yy_action[i]; - } - return yy_action[i]; -} - -/* -** The following routine is called if the stack overflows. -*/ -static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){ - ParseARG_FETCH; - yypParser->yyidx--; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); - } -#endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will execute if the parser - ** stack every overflows */ - ParseARG_STORE; /* Suppress warning about unused %extra_argument var */ -} - -/* -** Perform a shift action. -*/ -static void yy_shift( - yyParser *yypParser, /* The parser to be shifted */ - int yyNewState, /* The new state to shift in */ - int yyMajor, /* The major token to shift in */ - YYMINORTYPE *yypMinor /* Pointer ot the minor token to shift in */ -){ - yyStackEntry *yytos; - yypParser->yyidx++; -#if YYSTACKDEPTH>0 - if( yypParser->yyidx>=YYSTACKDEPTH ){ - yyStackOverflow(yypParser, yypMinor); - return; - } -#else - if( yypParser->yyidx>=yypParser->yystksz ){ - yyGrowStack(yypParser); - if( yypParser->yyidx>=yypParser->yystksz ){ - yyStackOverflow(yypParser, yypMinor); - return; - } - } -#endif - yytos = &yypParser->yystack[yypParser->yyidx]; - yytos->stateno = yyNewState; - yytos->major = yyMajor; - yytos->minor = *yypMinor; -#ifndef NDEBUG - if( yyTraceFILE && yypParser->yyidx>0 ){ - int i; - fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState); - fprintf(yyTraceFILE,"%sStack:",yyTracePrompt); - for(i=1; i<=yypParser->yyidx; i++) - fprintf(yyTraceFILE," (%d)%s",yypParser->yystack[i].stateno,yyTokenName[yypParser->yystack[i].major]); - fprintf(yyTraceFILE,"\n"); - } -#endif -} - -/* The following table contains information about every rule that -** is used during the reduce. -*/ -static const struct { - YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ - unsigned char nrhs; /* Number of right-hand side symbols in the rule */ -} yyRuleInfo[] = { - { 49, 1 }, - { 39, 1 }, - { 39, 1 }, - { 39, 3 }, - { 39, 3 }, - { 39, 3 }, - { 39, 3 }, - { 39, 3 }, - { 39, 3 }, - { 39, 3 }, - { 39, 2 }, - { 39, 3 }, - { 50, 0 }, - { 50, 2 }, - { 51, 1 }, - { 51, 1 }, - { 51, 1 }, - { 51, 1 }, - { 51, 1 }, - { 51, 1 }, - { 51, 1 }, - { 51, 1 }, - { 54, 4 }, - { 59, 0 }, - { 59, 1 }, - { 59, 3 }, - { 60, 1 }, - { 60, 1 }, - { 60, 1 }, - { 52, 5 }, - { 53, 2 }, - { 55, 3 }, - { 61, 2 }, - { 62, 0 }, - { 62, 1 }, - { 62, 3 }, - { 63, 1 }, - { 63, 3 }, - { 58, 3 }, - { 64, 1 }, - { 64, 3 }, - { 65, 6 }, - { 65, 6 }, - { 48, 0 }, - { 48, 1 }, - { 48, 3 }, - { 56, 8 }, - { 56, 8 }, - { 57, 11 }, - { 47, 0 }, - { 47, 2 }, - { 46, 3 }, - { 45, 1 }, - { 45, 1 }, - { 45, 1 }, - { 45, 1 }, - { 45, 1 }, - { 44, 1 }, - { 44, 1 }, - { 43, 1 }, - { 43, 4 }, - { 42, 1 }, - { 42, 3 }, - { 41, 3 }, - { 40, 0 }, - { 40, 1 }, - { 40, 3 }, - { 40, 5 }, - { 40, 7 }, - { 40, 9 }, - { 40, 3 }, - { 40, 5 }, - { 40, 7 }, - { 40, 9 }, - { 40, 1 }, - { 40, 3 }, - { 40, 5 }, - { 40, 7 }, - { 40, 9 }, - { 40, 1 }, - { 40, 3 }, - { 40, 5 }, - { 40, 7 }, - { 40, 9 }, - { 40, 3 }, - { 40, 5 }, - { 40, 7 }, - { 40, 9 }, - { 40, 5 }, - { 40, 7 }, - { 40, 9 }, - { 40, 7 }, - { 40, 9 }, - { 40, 9 }, -}; - -static void yy_accept(yyParser*); /* Forward Declaration */ - -/* -** Perform a reduce action and the shift that must immediately -** follow the reduce. -*/ -static void yy_reduce( - yyParser *yypParser, /* The parser */ - int yyruleno /* Number of the rule by which to reduce */ -){ - int yygoto; /* The next state */ - int yyact; /* The next action */ - YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ - yyStackEntry *yymsp; /* The top of the parser's stack */ - int yysize; /* Amount to pop the stack */ - ParseARG_FETCH; - yymsp = &yypParser->yystack[yypParser->yyidx]; -#ifndef NDEBUG - if( yyTraceFILE && yyruleno>=0 - && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ - fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, - yyRuleName[yyruleno]); - } -#endif /* NDEBUG */ - - /* Silence complaints from purify about yygotominor being uninitialized - ** in some cases when it is copied into the stack after the following - ** switch. yygotominor is uninitialized when a rule reduces that does - ** not set the value of its left-hand side nonterminal. Leaving the - ** value of the nonterminal uninitialized is utterly harmless as long - ** as the value is never used. So really the only thing this code - ** accomplishes is to quieten purify. - ** - ** 2007-01-16: The wireshark project (www.wireshark.org) reports that - ** without this code, their parser segfaults. I'm not sure what there - ** parser is doing to make this happen. This is the second bug report - ** from wireshark this week. Clearly they are stressing Lemon in ways - ** that it has not been previously stressed... (SQLite ticket #2172) - */ - memset(&yygotominor, 0, sizeof(yygotominor)); - - - switch( yyruleno ){ - /* Beginning here are the reduction cases. A typical example - ** follows: - ** case 0: - ** #line - ** { ... } // User supplied code - ** #line - ** break; - */ - case 0: /* main ::= translation_unit */ - case 12: /*translation_unit ::= */ - case 13: /*translation_unit ::= translation_unit external_declaration */ - case 14: /*external_declaration ::= define_statement */ - case 15: /*external_declaration ::= include_statement */ - case 16: /*external_declaration ::= print_statement */ - case 17: /*external_declaration ::= enum_statement */ - case 18: /*external_declaration ::= linetype_declaration */ - case 19: /*external_declaration ::= boom_declaration */ - case 20: /*external_declaration ::= special_declaration */ - case 21: /*external_declaration ::= NOP */ - case 23: /*print_list ::= */ - case 24: /*print_list ::= print_item */ - case 25: /*print_list ::= print_item COMMA print_list */ - case 31: /*enum_statement ::= enum_open enum_list RBRACE */ - case 33: /*enum_list ::= */ - case 34: /*enum_list ::= single_enum */ - case 35: /*enum_list ::= single_enum COMMA enum_list */ - case 38: /*special_declaration ::= SPECIAL special_list SEMICOLON */ - case 39: /*special_list ::= special_def */ - case 40: /*special_list ::= special_list COMMA special_def */ - case 43: /*maybe_argcount ::= */ - case 44: /*maybe_argcount ::= exp */ - case 45: /*maybe_argcount ::= exp COMMA exp */ -#line 365 "xlat-parse.y" -{ -} -#line 1266 "xlat-parse.c" - break; - case 1: /* exp ::= NUM */ -#line 367 "xlat-parse.y" -{ yygotominor.yy64 = yymsp[0].minor.yy0.val; } -#line 1271 "xlat-parse.c" - break; - case 2: /* exp ::= SYMNUM */ -#line 368 "xlat-parse.y" -{ yygotominor.yy64 = yymsp[0].minor.yy0.symval->Value; } -#line 1276 "xlat-parse.c" - break; - case 3: /* exp ::= exp PLUS exp */ -#line 369 "xlat-parse.y" -{ yygotominor.yy64 = yymsp[-2].minor.yy64 + yymsp[0].minor.yy64; } -#line 1281 "xlat-parse.c" - break; - case 4: /* exp ::= exp MINUS exp */ -#line 370 "xlat-parse.y" -{ yygotominor.yy64 = yymsp[-2].minor.yy64 - yymsp[0].minor.yy64; } -#line 1286 "xlat-parse.c" - break; - case 5: /* exp ::= exp MULTIPLY exp */ -#line 371 "xlat-parse.y" -{ yygotominor.yy64 = yymsp[-2].minor.yy64 * yymsp[0].minor.yy64; } -#line 1291 "xlat-parse.c" - break; - case 6: /* exp ::= exp DIVIDE exp */ -#line 372 "xlat-parse.y" -{ yygotominor.yy64 = yymsp[-2].minor.yy64 / yymsp[0].minor.yy64; } -#line 1296 "xlat-parse.c" - break; - case 7: /* exp ::= exp OR exp */ -#line 373 "xlat-parse.y" -{ yygotominor.yy64 = yymsp[-2].minor.yy64 | yymsp[0].minor.yy64; } -#line 1301 "xlat-parse.c" - break; - case 8: /* exp ::= exp AND exp */ -#line 374 "xlat-parse.y" -{ yygotominor.yy64 = yymsp[-2].minor.yy64 & yymsp[0].minor.yy64; } -#line 1306 "xlat-parse.c" - break; - case 9: /* exp ::= exp XOR exp */ -#line 375 "xlat-parse.y" -{ yygotominor.yy64 = yymsp[-2].minor.yy64 ^ yymsp[0].minor.yy64; } -#line 1311 "xlat-parse.c" - break; - case 10: /* exp ::= MINUS exp */ -#line 376 "xlat-parse.y" -{ yygotominor.yy64 = -yymsp[0].minor.yy64; } -#line 1316 "xlat-parse.c" - break; - case 11: /* exp ::= LPAREN exp RPAREN */ -#line 377 "xlat-parse.y" -{ yygotominor.yy64 = yymsp[-1].minor.yy64; } -#line 1321 "xlat-parse.c" - break; - case 22: /* print_statement ::= PRINT LPAREN print_list RPAREN */ -#line 392 "xlat-parse.y" -{ - printf ("\n"); -} -#line 1328 "xlat-parse.c" - break; - case 26: /* print_item ::= STRING */ -#line 400 "xlat-parse.y" -{ printf ("%s", yymsp[0].minor.yy0.string); } -#line 1333 "xlat-parse.c" - break; - case 27: /* print_item ::= exp */ -#line 401 "xlat-parse.y" -{ printf ("%d", yymsp[0].minor.yy64); } -#line 1338 "xlat-parse.c" - break; - case 28: /* print_item ::= ENDL */ -#line 402 "xlat-parse.y" -{ printf ("\n"); } -#line 1343 "xlat-parse.c" - break; - case 29: /* define_statement ::= DEFINE SYM LPAREN exp RPAREN */ -#line 405 "xlat-parse.y" -{ - AddSym (yymsp[-3].minor.yy0.sym, yymsp[-1].minor.yy64); -} -#line 1350 "xlat-parse.c" - break; - case 30: /* include_statement ::= INCLUDE STRING */ -#line 410 "xlat-parse.y" -{ - IncludeFile (yymsp[0].minor.yy0.string); -} -#line 1357 "xlat-parse.c" - break; - case 32: /* enum_open ::= ENUM LBRACE */ -#line 417 "xlat-parse.y" -{ - EnumVal = 0; -} -#line 1364 "xlat-parse.c" - break; - case 36: /* single_enum ::= SYM */ -#line 426 "xlat-parse.y" -{ - AddSym (yymsp[0].minor.yy0.sym, EnumVal++); -} -#line 1371 "xlat-parse.c" - break; - case 37: /* single_enum ::= SYM EQUALS exp */ -#line 431 "xlat-parse.y" -{ - AddSym (yymsp[-2].minor.yy0.sym, EnumVal = yymsp[0].minor.yy64); -} -#line 1378 "xlat-parse.c" - break; - case 41: /* special_def ::= exp COLON SYM LPAREN maybe_argcount RPAREN */ -#line 444 "xlat-parse.y" -{ - AddSym (yymsp[-3].minor.yy0.sym, yymsp[-5].minor.yy64); -} -#line 1385 "xlat-parse.c" - break; - case 42: /* special_def ::= exp COLON SYMNUM LPAREN maybe_argcount RPAREN */ -#line 448 "xlat-parse.y" -{ - printf ("%s, line %d: %s is already defined\n", SourceName, SourceLine, yymsp[-3].minor.yy0.symval->Sym); -} -#line 1392 "xlat-parse.c" - break; - case 46: /* linetype_declaration ::= exp EQUALS exp COMMA exp LPAREN special_args RPAREN */ -#line 457 "xlat-parse.y" -{ - Simple[yymsp[-7].minor.yy64].NewSpecial = yymsp[-3].minor.yy64; - Simple[yymsp[-7].minor.yy64].Flags = yymsp[-5].minor.yy64 | yymsp[-1].minor.yy123.addflags; - Simple[yymsp[-7].minor.yy64].Args[0] = yymsp[-1].minor.yy123.args[0]; - Simple[yymsp[-7].minor.yy64].Args[1] = yymsp[-1].minor.yy123.args[1]; - Simple[yymsp[-7].minor.yy64].Args[2] = yymsp[-1].minor.yy123.args[2]; - Simple[yymsp[-7].minor.yy64].Args[3] = yymsp[-1].minor.yy123.args[3]; - Simple[yymsp[-7].minor.yy64].Args[4] = yymsp[-1].minor.yy123.args[4]; -} -#line 1405 "xlat-parse.c" - break; - case 47: /* linetype_declaration ::= exp EQUALS exp COMMA SYM LPAREN special_args RPAREN */ -#line 467 "xlat-parse.y" -{ - printf ("%s, line %d: %s is undefined\n", SourceName, SourceLine, yymsp[-3].minor.yy0.sym); -} -#line 1412 "xlat-parse.c" - break; - case 48: /* boom_declaration ::= LBRACKET exp RBRACKET LPAREN exp COMMA exp RPAREN LBRACE boom_body RBRACE */ -#line 472 "xlat-parse.y" -{ - if (NumBoomish == MAX_BOOMISH) - { - MoreLines *probe = yymsp[-1].minor.yy57; - - while (probe != NULL) - { - MoreLines *next = probe->next; - free (probe); - probe = next; - } - printf ("%s, line %d: Too many BOOM translators\n", SourceName, SourceLine); - } - else - { - int i; - MoreLines *probe; - - Boomish[NumBoomish].FirstLinetype = yymsp[-6].minor.yy64; - Boomish[NumBoomish].LastLinetype = yymsp[-4].minor.yy64; - Boomish[NumBoomish].NewSpecial = yymsp[-9].minor.yy64; - - for (i = 0, probe = yymsp[-1].minor.yy57; probe != NULL; i++) - { - MoreLines *next = probe->next;; - if (i < MAX_BOOMISH_EXEC) - { - Boomish[NumBoomish].Args[i] = probe->arg; - } - else if (i == MAX_BOOMISH_EXEC) - { - printf ("%s, line %d: Too many commands for this BOOM translator\n", SourceName, SourceLine); - } - free (probe); - probe = next; - } - if (i < MAX_BOOMISH_EXEC) - { - Boomish[NumBoomish].Args[i].bDefined = 0; - } - NumBoomish++; - } -} -#line 1459 "xlat-parse.c" - break; - case 49: /* boom_body ::= */ -#line 517 "xlat-parse.y" -{ - yygotominor.yy57 = NULL; -} -#line 1466 "xlat-parse.c" - break; - case 50: /* boom_body ::= boom_line boom_body */ -#line 521 "xlat-parse.y" -{ - yygotominor.yy57 = malloc (sizeof(MoreLines)); - yygotominor.yy57->next = yymsp[0].minor.yy57; - yygotominor.yy57->arg = yymsp[-1].minor.yy65; -} -#line 1475 "xlat-parse.c" - break; - case 51: /* boom_line ::= boom_selector boom_op boom_args */ -#line 528 "xlat-parse.y" -{ - yygotominor.yy65.bDefined = 1; - yygotominor.yy65.bOrExisting = (yymsp[-1].minor.yy64 == OR_EQUAL); - yygotominor.yy65.bUseConstant = (yymsp[0].minor.yy87.filters == NULL); - yygotominor.yy65.ArgNum = yymsp[-2].minor.yy64; - yygotominor.yy65.ConstantValue = yymsp[0].minor.yy87.constant; - yygotominor.yy65.AndValue = yymsp[0].minor.yy87.mask; - - if (yymsp[0].minor.yy87.filters != NULL) - { - int i; - MoreFilters *probe; - - for (i = 0, probe = yymsp[0].minor.yy87.filters; probe != NULL; i++) - { - MoreFilters *next = probe->next; - if (i < 15) - { - yygotominor.yy65.ResultFilter[i] = probe->filter.filter; - yygotominor.yy65.ResultValue[i] = probe->filter.value; - } - else if (i == 15) - { - yyerror ("Lists can only have 15 elements"); - } - free (probe); - probe = next; - } - yygotominor.yy65.ListSize = i > 15 ? 15 : i; - } -} -#line 1510 "xlat-parse.c" - break; - case 52: /* boom_selector ::= FLAGS */ -#line 560 "xlat-parse.y" -{ yygotominor.yy64 = 4; } -#line 1515 "xlat-parse.c" - break; - case 53: /* boom_selector ::= ARG2 */ -#line 561 "xlat-parse.y" -{ yygotominor.yy64 = 0; } -#line 1520 "xlat-parse.c" - break; - case 54: /* boom_selector ::= ARG3 */ -#line 562 "xlat-parse.y" -{ yygotominor.yy64 = 1; } -#line 1525 "xlat-parse.c" - break; - case 55: /* boom_selector ::= ARG4 */ -#line 563 "xlat-parse.y" -{ yygotominor.yy64 = 2; } -#line 1530 "xlat-parse.c" - break; - case 56: /* boom_selector ::= ARG5 */ -#line 564 "xlat-parse.y" -{ yygotominor.yy64 = 3; } -#line 1535 "xlat-parse.c" - break; - case 57: /* boom_op ::= EQUALS */ -#line 566 "xlat-parse.y" -{ yygotominor.yy64 = '='; } -#line 1540 "xlat-parse.c" - break; - case 58: /* boom_op ::= OR_EQUAL */ -#line 567 "xlat-parse.y" -{ yygotominor.yy64 = OR_EQUAL; } -#line 1545 "xlat-parse.c" - break; - case 59: /* boom_args ::= exp */ -#line 570 "xlat-parse.y" -{ - yygotominor.yy87.constant = yymsp[0].minor.yy64; - yygotominor.yy87.filters = NULL; -} -#line 1553 "xlat-parse.c" - break; - case 60: /* boom_args ::= exp LBRACKET arg_list RBRACKET */ -#line 575 "xlat-parse.y" -{ - yygotominor.yy87.mask = yymsp[-3].minor.yy64; - yygotominor.yy87.filters = yymsp[-1].minor.yy39; -} -#line 1561 "xlat-parse.c" - break; - case 61: /* arg_list ::= list_val */ -#line 581 "xlat-parse.y" -{ - yygotominor.yy39 = malloc (sizeof(MoreFilters)); - yygotominor.yy39->next = NULL; - yygotominor.yy39->filter = yymsp[0].minor.yy20; -} -#line 1570 "xlat-parse.c" - break; - case 62: /* arg_list ::= list_val COMMA arg_list */ -#line 587 "xlat-parse.y" -{ - yygotominor.yy39 = malloc (sizeof(MoreFilters)); - yygotominor.yy39->next = yymsp[0].minor.yy39; - yygotominor.yy39->filter = yymsp[-2].minor.yy20; -} -#line 1579 "xlat-parse.c" - break; - case 63: /* list_val ::= exp COLON exp */ -#line 594 "xlat-parse.y" -{ - yygotominor.yy20.filter = yymsp[-2].minor.yy64; - yygotominor.yy20.value = yymsp[0].minor.yy64; -} -#line 1587 "xlat-parse.c" - break; - case 64: /* special_args ::= */ -#line 600 "xlat-parse.y" -{ - yygotominor.yy123.addflags = 0; - memset (yygotominor.yy123.args, 0, 5); -} -#line 1595 "xlat-parse.c" - break; - case 65: /* special_args ::= TAG */ -#line 605 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASTAGAT1; - memset (yygotominor.yy123.args, 0, 5); -} -#line 1603 "xlat-parse.c" - break; - case 66: /* special_args ::= TAG COMMA exp */ -#line 610 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASTAGAT1; - yygotominor.yy123.args[0] = 0; - yygotominor.yy123.args[1] = yymsp[0].minor.yy64; - yygotominor.yy123.args[2] = 0; - yygotominor.yy123.args[3] = 0; - yygotominor.yy123.args[4] = 0; -} -#line 1615 "xlat-parse.c" - break; - case 67: /* special_args ::= TAG COMMA exp COMMA exp */ -#line 619 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASTAGAT1; - yygotominor.yy123.args[0] = 0; - yygotominor.yy123.args[1] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[2] = yymsp[0].minor.yy64; - yygotominor.yy123.args[3] = 0; - yygotominor.yy123.args[4] = 0; -} -#line 1627 "xlat-parse.c" - break; - case 68: /* special_args ::= TAG COMMA exp COMMA exp COMMA exp */ -#line 628 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASTAGAT1; - yygotominor.yy123.args[0] = 0; - yygotominor.yy123.args[1] = yymsp[-4].minor.yy64; - yygotominor.yy123.args[2] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[3] = yymsp[0].minor.yy64; - yygotominor.yy123.args[4] = 0; -} -#line 1639 "xlat-parse.c" - break; - case 69: /* special_args ::= TAG COMMA exp COMMA exp COMMA exp COMMA exp */ -#line 637 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASTAGAT1; - yygotominor.yy123.args[0] = 0; - yygotominor.yy123.args[1] = yymsp[-6].minor.yy64; - yygotominor.yy123.args[2] = yymsp[-4].minor.yy64; - yygotominor.yy123.args[3] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[4] = yymsp[0].minor.yy64; -} -#line 1651 "xlat-parse.c" - break; - case 70: /* special_args ::= TAG COMMA TAG */ -#line 646 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HAS2TAGS; - yygotominor.yy123.args[0] = yygotominor.yy123.args[1] = 0; - yygotominor.yy123.args[2] = 0; - yygotominor.yy123.args[3] = 0; - yygotominor.yy123.args[4] = 0; -} -#line 1662 "xlat-parse.c" - break; - case 71: /* special_args ::= TAG COMMA TAG COMMA exp */ -#line 654 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HAS2TAGS; - yygotominor.yy123.args[0] = yygotominor.yy123.args[1] = 0; - yygotominor.yy123.args[2] = yymsp[0].minor.yy64; - yygotominor.yy123.args[3] = 0; - yygotominor.yy123.args[4] = 0; -} -#line 1673 "xlat-parse.c" - break; - case 72: /* special_args ::= TAG COMMA TAG COMMA exp COMMA exp */ -#line 662 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HAS2TAGS; - yygotominor.yy123.args[0] = yygotominor.yy123.args[1] = 0; - yygotominor.yy123.args[2] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[3] = yymsp[0].minor.yy64; - yygotominor.yy123.args[4] = 0; -} -#line 1684 "xlat-parse.c" - break; - case 73: /* special_args ::= TAG COMMA TAG COMMA exp COMMA exp COMMA exp */ -#line 670 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HAS2TAGS; - yygotominor.yy123.args[0] = yygotominor.yy123.args[1] = 0; - yygotominor.yy123.args[2] = yymsp[-4].minor.yy64; - yygotominor.yy123.args[3] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[4] = yymsp[0].minor.yy64; -} -#line 1695 "xlat-parse.c" - break; - case 74: /* special_args ::= LINEID */ -#line 678 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASLINEID; - memset (yygotominor.yy123.args, 0, 5); -} -#line 1703 "xlat-parse.c" - break; - case 75: /* special_args ::= LINEID COMMA exp */ -#line 683 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASLINEID; - yygotominor.yy123.args[0] = 0; - yygotominor.yy123.args[1] = yymsp[0].minor.yy64; - yygotominor.yy123.args[2] = 0; - yygotominor.yy123.args[3] = 0; - yygotominor.yy123.args[4] = 0; -} -#line 1715 "xlat-parse.c" - break; - case 76: /* special_args ::= LINEID COMMA exp COMMA exp */ -#line 692 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASLINEID; - yygotominor.yy123.args[0] = 0; - yygotominor.yy123.args[1] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[2] = yymsp[0].minor.yy64; - yygotominor.yy123.args[3] = 0; - yygotominor.yy123.args[4] = 0; -} -#line 1727 "xlat-parse.c" - break; - case 77: /* special_args ::= LINEID COMMA exp COMMA exp COMMA exp */ -#line 701 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASLINEID; - yygotominor.yy123.args[0] = 0; - yygotominor.yy123.args[1] = yymsp[-4].minor.yy64; - yygotominor.yy123.args[2] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[3] = yymsp[0].minor.yy64; - yygotominor.yy123.args[4] = 0; -} -#line 1739 "xlat-parse.c" - break; - case 78: /* special_args ::= LINEID COMMA exp COMMA exp COMMA exp COMMA exp */ -#line 710 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASLINEID; - yygotominor.yy123.args[0] = 0; - yygotominor.yy123.args[1] = yymsp[-6].minor.yy64; - yygotominor.yy123.args[2] = yymsp[-4].minor.yy64; - yygotominor.yy123.args[3] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[4] = yymsp[0].minor.yy64; -} -#line 1751 "xlat-parse.c" - break; - case 79: /* special_args ::= exp */ -#line 719 "xlat-parse.y" -{ - yygotominor.yy123.addflags = 0; - yygotominor.yy123.args[0] = yymsp[0].minor.yy64; - yygotominor.yy123.args[1] = 0; - yygotominor.yy123.args[2] = 0; - yygotominor.yy123.args[3] = 0; - yygotominor.yy123.args[4] = 0; -} -#line 1763 "xlat-parse.c" - break; - case 80: /* special_args ::= exp COMMA exp */ -#line 728 "xlat-parse.y" -{ - yygotominor.yy123.addflags = 0; - yygotominor.yy123.args[0] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[1] = yymsp[0].minor.yy64; - yygotominor.yy123.args[2] = 0; - yygotominor.yy123.args[3] = 0; - yygotominor.yy123.args[4] = 0; -} -#line 1775 "xlat-parse.c" - break; - case 81: /* special_args ::= exp COMMA exp COMMA exp */ -#line 737 "xlat-parse.y" -{ - yygotominor.yy123.addflags = 0; - yygotominor.yy123.args[0] = yymsp[-4].minor.yy64; - yygotominor.yy123.args[1] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[2] = yymsp[0].minor.yy64; - yygotominor.yy123.args[3] = 0; - yygotominor.yy123.args[4] = 0; -} -#line 1787 "xlat-parse.c" - break; - case 82: /* special_args ::= exp COMMA exp COMMA exp COMMA exp */ -#line 746 "xlat-parse.y" -{ - yygotominor.yy123.addflags = 0; - yygotominor.yy123.args[0] = yymsp[-6].minor.yy64; - yygotominor.yy123.args[1] = yymsp[-4].minor.yy64; - yygotominor.yy123.args[2] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[3] = yymsp[0].minor.yy64; - yygotominor.yy123.args[4] = 0; -} -#line 1799 "xlat-parse.c" - break; - case 83: /* special_args ::= exp COMMA exp COMMA exp COMMA exp COMMA exp */ -#line 755 "xlat-parse.y" -{ - yygotominor.yy123.addflags = 0; - yygotominor.yy123.args[0] = yymsp[-8].minor.yy64; - yygotominor.yy123.args[1] = yymsp[-6].minor.yy64; - yygotominor.yy123.args[2] = yymsp[-4].minor.yy64; - yygotominor.yy123.args[3] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[4] = yymsp[0].minor.yy64; -} -#line 1811 "xlat-parse.c" - break; - case 84: /* special_args ::= exp COMMA TAG */ -#line 764 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASTAGAT2; - yygotominor.yy123.args[0] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[1] = 0; - yygotominor.yy123.args[2] = 0; - yygotominor.yy123.args[3] = 0; - yygotominor.yy123.args[4] = 0; -} -#line 1823 "xlat-parse.c" - break; - case 85: /* special_args ::= exp COMMA TAG COMMA exp */ -#line 773 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASTAGAT2; - yygotominor.yy123.args[0] = yymsp[-4].minor.yy64; - yygotominor.yy123.args[1] = 0; - yygotominor.yy123.args[2] = yymsp[0].minor.yy64; - yygotominor.yy123.args[3] = 0; - yygotominor.yy123.args[4] = 0; -} -#line 1835 "xlat-parse.c" - break; - case 86: /* special_args ::= exp COMMA TAG COMMA exp COMMA exp */ -#line 782 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASTAGAT2; - yygotominor.yy123.args[0] = yymsp[-6].minor.yy64; - yygotominor.yy123.args[1] = 0; - yygotominor.yy123.args[2] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[3] = yymsp[0].minor.yy64; - yygotominor.yy123.args[4] = 0; -} -#line 1847 "xlat-parse.c" - break; - case 87: /* special_args ::= exp COMMA TAG COMMA exp COMMA exp COMMA exp */ -#line 791 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASTAGAT2; - yygotominor.yy123.args[0] = yymsp[-8].minor.yy64; - yygotominor.yy123.args[1] = 0; - yygotominor.yy123.args[2] = yymsp[-4].minor.yy64; - yygotominor.yy123.args[3] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[4] = yymsp[0].minor.yy64; -} -#line 1859 "xlat-parse.c" - break; - case 88: /* special_args ::= exp COMMA exp COMMA TAG */ -#line 800 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASTAGAT3; - yygotominor.yy123.args[0] = yymsp[-4].minor.yy64; - yygotominor.yy123.args[1] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[2] = 0; - yygotominor.yy123.args[3] = 0; - yygotominor.yy123.args[4] = 0; -} -#line 1871 "xlat-parse.c" - break; - case 89: /* special_args ::= exp COMMA exp COMMA TAG COMMA exp */ -#line 809 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASTAGAT3; - yygotominor.yy123.args[0] = yymsp[-6].minor.yy64; - yygotominor.yy123.args[1] = yymsp[-4].minor.yy64; - yygotominor.yy123.args[2] = 0; - yygotominor.yy123.args[3] = yymsp[0].minor.yy64; - yygotominor.yy123.args[4] = 0; -} -#line 1883 "xlat-parse.c" - break; - case 90: /* special_args ::= exp COMMA exp COMMA TAG COMMA exp COMMA exp */ -#line 818 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASTAGAT3; - yygotominor.yy123.args[0] = yymsp[-8].minor.yy64; - yygotominor.yy123.args[1] = yymsp[-6].minor.yy64; - yygotominor.yy123.args[2] = 0; - yygotominor.yy123.args[3] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[4] = yymsp[0].minor.yy64; -} -#line 1895 "xlat-parse.c" - break; - case 91: /* special_args ::= exp COMMA exp COMMA exp COMMA TAG */ -#line 827 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASTAGAT4; - yygotominor.yy123.args[0] = yymsp[-6].minor.yy64; - yygotominor.yy123.args[1] = yymsp[-4].minor.yy64; - yygotominor.yy123.args[2] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[3] = 0; - yygotominor.yy123.args[4] = 0; -} -#line 1907 "xlat-parse.c" - break; - case 92: /* special_args ::= exp COMMA exp COMMA exp COMMA TAG COMMA exp */ -#line 836 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASTAGAT4; - yygotominor.yy123.args[0] = yymsp[-8].minor.yy64; - yygotominor.yy123.args[1] = yymsp[-6].minor.yy64; - yygotominor.yy123.args[2] = yymsp[-4].minor.yy64; - yygotominor.yy123.args[3] = 0; - yygotominor.yy123.args[4] = yymsp[0].minor.yy64; -} -#line 1919 "xlat-parse.c" - break; - case 93: /* special_args ::= exp COMMA exp COMMA exp COMMA exp COMMA TAG */ -#line 845 "xlat-parse.y" -{ - yygotominor.yy123.addflags = SIMPLE_HASTAGAT5; - yygotominor.yy123.args[0] = yymsp[-8].minor.yy64; - yygotominor.yy123.args[1] = yymsp[-6].minor.yy64; - yygotominor.yy123.args[2] = yymsp[-4].minor.yy64; - yygotominor.yy123.args[3] = yymsp[-2].minor.yy64; - yygotominor.yy123.args[4] = 0; -} -#line 1931 "xlat-parse.c" - break; - }; - yygoto = yyRuleInfo[yyruleno].lhs; - yysize = yyRuleInfo[yyruleno].nrhs; - yypParser->yyidx -= yysize; - yyact = yy_find_reduce_action(yymsp[-yysize].stateno,yygoto); - if( yyact < YYNSTATE ){ -#ifdef NDEBUG - /* If we are not debugging and the reduce action popped at least - ** one element off the stack, then we can push the new element back - ** onto the stack here, and skip the stack overflow test in yy_shift(). - ** That gives a significant speed improvement. */ - if( yysize ){ - yypParser->yyidx++; - yymsp -= yysize-1; - yymsp->stateno = yyact; - yymsp->major = yygoto; - yymsp->minor = yygotominor; - }else -#endif - { - yy_shift(yypParser,yyact,yygoto,&yygotominor); - } - }else{ - assert( yyact == YYNSTATE + YYNRULE + 1 ); - yy_accept(yypParser); - } -} - -/* -** The following code executes when the parse fails -*/ -static void yy_parse_failed( - yyParser *yypParser /* The parser */ -){ - ParseARG_FETCH; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); - } -#endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will be executed whenever the - ** parser fails */ - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} - -/* -** The following code executes when a syntax error first occurs. -*/ -static void yy_syntax_error( - yyParser *yypParser, /* The parser */ - int yymajor, /* The major type of the error token */ - YYMINORTYPE yyminor /* The minor type of the error token */ -){ - ParseARG_FETCH; -#define TOKEN (yyminor.yy0) -#line 345 "xlat-parse.y" -yyerror("syntax error"); -#line 1991 "xlat-parse.c" - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} - -/* -** The following is executed when the parser accepts -*/ -static void yy_accept( - yyParser *yypParser /* The parser */ -){ - ParseARG_FETCH; -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); - } -#endif - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); - /* Here code is inserted which will be executed whenever the - ** parser accepts */ - ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} - -/* The main parser program. -** The first argument is a pointer to a structure obtained from -** "ParseAlloc" which describes the current state of the parser. -** The second argument is the major token number. The third is -** the minor token. The fourth optional argument is whatever the -** user wants (and specified in the grammar) and is available for -** use by the action routines. -** -** Inputs: -**
    -**
  • A pointer to the parser (an opaque structure.) -**
  • The major token number. -**
  • The minor token number. -**
  • An option argument of a grammar-specified type. -**
-** -** Outputs: -** None. -*/ -void Parse( - void *yyp, /* The parser */ - int yymajor, /* The major token code number */ - ParseTOKENTYPE yyminor /* The value for the token */ - ParseARG_PDECL /* Optional %extra_argument parameter */ -){ - YYMINORTYPE yyminorunion; - int yyact; /* The parser action. */ - int yyendofinput; /* True if we are at the end of input */ -#ifdef YYERRORSYMBOL - int yyerrorhit = 0; /* True if yymajor has invoked an error */ -#endif - yyParser *yypParser; /* The parser */ - - /* (re)initialize the parser, if necessary */ - yypParser = (yyParser*)yyp; - if( yypParser->yyidx<0 ){ -#if YYSTACKDEPTH<=0 - if( yypParser->yystksz <=0 ){ - memset(&yyminorunion, 0, sizeof(yyminorunion)); - yyStackOverflow(yypParser, &yyminorunion); - return; - } -#endif - yypParser->yyidx = 0; - yypParser->yyerrcnt = -1; - yypParser->yystack[0].stateno = 0; - yypParser->yystack[0].major = 0; - } - yyminorunion.yy0 = yyminor; - yyendofinput = (yymajor==0); - ParseARG_STORE; - -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]); - } -#endif - - do{ - yyact = yy_find_shift_action(yypParser,yymajor); - if( yyactyyerrcnt--; - yymajor = YYNOCODE; - }else if( yyact < YYNSTATE + YYNRULE ){ - yy_reduce(yypParser,yyact-YYNSTATE); - }else{ -#ifdef YYERRORSYMBOL - int yymx; -#endif - assert( yyact == YY_ERROR_ACTION ); -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); - } -#endif -#ifdef YYERRORSYMBOL - /* A syntax error has occurred. - ** The response to an error depends upon whether or not the - ** grammar defines an error token "ERROR". - ** - ** This is what we do if the grammar does define ERROR: - ** - ** * Call the %syntax_error function. - ** - ** * Begin popping the stack until we enter a state where - ** it is legal to shift the error symbol, then shift - ** the error symbol. - ** - ** * Set the error count to three. - ** - ** * Begin accepting and shifting new tokens. No new error - ** processing will occur until three tokens have been - ** shifted successfully. - ** - */ - if( yypParser->yyerrcnt<0 ){ - yy_syntax_error(yypParser,yymajor,yyminorunion); - } - yymx = yypParser->yystack[yypParser->yyidx].major; - if( yymx==YYERRORSYMBOL || yyerrorhit ){ -#ifndef NDEBUG - if( yyTraceFILE ){ - fprintf(yyTraceFILE,"%sDiscard input token %s\n", - yyTracePrompt,yyTokenName[yymajor]); - } -#endif - yy_destructor(yymajor,&yyminorunion); - yymajor = YYNOCODE; - }else{ - while( - yypParser->yyidx >= 0 && - yymx != YYERRORSYMBOL && - (yyact = yy_find_reduce_action( - yypParser->yystack[yypParser->yyidx].stateno, - YYERRORSYMBOL)) >= YYNSTATE - ){ - yy_pop_parser_stack(yypParser); - } - if( yypParser->yyidx < 0 || yymajor==0 ){ - yy_destructor(yymajor,&yyminorunion); - yy_parse_failed(yypParser); - yymajor = YYNOCODE; - }else if( yymx!=YYERRORSYMBOL ){ - YYMINORTYPE u2; - u2.YYERRSYMDT = 0; - yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2); - } - } - yypParser->yyerrcnt = 3; - yyerrorhit = 1; -#else /* YYERRORSYMBOL is not defined */ - /* This is what we do if the grammar does not define ERROR: - ** - ** * Report an error message, and throw away the input token. - ** - ** * If the input token is $, then fail the parse. - ** - ** As before, subsequent error messages are suppressed until - ** three input tokens have been successfully shifted. - */ - if( yypParser->yyerrcnt<=0 ){ - yy_syntax_error(yypParser,yymajor,yyminorunion); - } - yypParser->yyerrcnt = 3; - yy_destructor(yymajor,&yyminorunion); - if( yyendofinput ){ - yy_parse_failed(yypParser); - } - yymajor = YYNOCODE; -#endif - } - }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); - return; -} diff --git a/tools/xlatcc/xlat-parse.h b/tools/xlatcc/xlat-parse.h deleted file mode 100644 index 5d0e3605a5..0000000000 --- a/tools/xlatcc/xlat-parse.h +++ /dev/null @@ -1,37 +0,0 @@ -#define OR 1 -#define XOR 2 -#define AND 3 -#define MINUS 4 -#define PLUS 5 -#define MULTIPLY 6 -#define DIVIDE 7 -#define NEG 8 -#define NUM 9 -#define SYMNUM 10 -#define LPAREN 11 -#define RPAREN 12 -#define NOP 13 -#define PRINT 14 -#define COMMA 15 -#define STRING 16 -#define ENDL 17 -#define DEFINE 18 -#define SYM 19 -#define INCLUDE 20 -#define RBRACE 21 -#define ENUM 22 -#define LBRACE 23 -#define EQUALS 24 -#define SPECIAL 25 -#define SEMICOLON 26 -#define COLON 27 -#define LBRACKET 28 -#define RBRACKET 29 -#define FLAGS 30 -#define ARG2 31 -#define ARG3 32 -#define ARG4 33 -#define ARG5 34 -#define OR_EQUAL 35 -#define TAG 36 -#define LINEID 37 diff --git a/tools/xlatcc/xlat-parse.y b/tools/xlatcc/xlat-parse.y deleted file mode 100644 index 7cd43b9344..0000000000 --- a/tools/xlatcc/xlat-parse.y +++ /dev/null @@ -1,852 +0,0 @@ -%include{ -#include "xlat.h" -#include "xlat-parse.h" -#include -#include - -int yyerror (char *s); - -typedef struct _Symbol -{ - struct _Symbol *Next; - int Value; - char Sym[1]; -} Symbol; - -static bool FindToken (char *tok, int *type); -static void AddSym (char *sym, int val); -static bool FindSym (char *sym, Symbol **val); - -static int EnumVal; - -struct ListFilter -{ - WORD filter; - BYTE value; -}; - -typedef struct _morefilters -{ - struct _morefilters *next; - struct ListFilter filter; -} MoreFilters; - -typedef struct _morelines -{ - struct _morelines *next; - BoomArg arg; -} MoreLines; - -typedef struct _specialargs -{ - BYTE addflags; - BYTE args[5]; -} SpecialArgs; - -typedef struct _boomarg -{ - BYTE constant; - WORD mask; - MoreFilters *filters; -} ParseBoomArg; - -typedef union YYSTYPE -{ - int val; - char sym[80]; - char string[80]; - Symbol *symval; -} YYSTYPE; - -#include -#include - -int yylex (YYSTYPE *yylval) -{ - char token[80]; - int toksize; - int c; - -loop: - while (Source == NULL) - { - if (!EndFile ()) - return 0; - } - while (isspace (c = fgetc (Source)) && c != EOF) - { - if (c == '\n') - SourceLine++; - } - - if (c == EOF) - { - if (EndFile ()) - goto loop; - return 0; - } - if (isdigit (c)) - { - int buildup = c - '0'; - if (c == '0') - { - c = fgetc (Source); - if (c == 'x' || c == 'X') - { - for (;;) - { - c = fgetc (Source); - if (isdigit (c)) - { - buildup = (buildup<<4) + c - '0'; - } - else if (c >= 'a' && c <= 'f') - { - buildup = (buildup<<4) + c - 'a' + 10; - } - else if (c >= 'A' && c <= 'F') - { - buildup = (buildup<<4) + c - 'A' + 10; - } - else - { - ungetc (c, Source); - yylval->val = buildup; - return NUM; - } - } - } - else - { - ungetc (c, Source); - } - } - while (isdigit (c = fgetc (Source))) - { - buildup = buildup*10 + c - '0'; - } - ungetc (c, Source); - yylval->val = buildup; - return NUM; - } - if (isalpha (c)) - { - int buildup = 0; - - token[0] = c; - toksize = 1; - while (toksize < 79 && (isalnum (c = fgetc (Source)) || c == '_')) - { - token[toksize++] = c; - } - token[toksize] = 0; - if (toksize == 79 && isalnum (c)) - { - while (isalnum (c = fgetc (Source))) - ; - } - ungetc (c, Source); - if (FindToken (token, &buildup)) - { - return buildup; - } - if (FindSym (token, &yylval->symval)) - { - return SYMNUM; - } - strcpy (yylval->sym, token); - return SYM; - } - if (c == '/') - { - c = fgetc (Source); - if (c == '*') - { - for (;;) - { - while ((c = fgetc (Source)) != '*' && c != EOF) - { - if (c == '\n') - SourceLine++; - } - if (c == EOF) - return 0; - if ((c = fgetc (Source)) == '/') - goto loop; - if (c == EOF) - return 0; - ungetc (c, Source); - } - } - else if (c == '/') - { - while ((c = fgetc (Source)) != '\n' && c != EOF) - ; - if (c == '\n') - SourceLine++; - else if (c == EOF) - return 0; - goto loop; - } - else - { - ungetc (c, Source); - return DIVIDE; - } - } - if (c == '"') - { - int tokensize = 0; - while ((c = fgetc (Source)) != '"' && c != EOF) - { - yylval->string[tokensize++] = c; - } - yylval->string[tokensize] = 0; - return STRING; - } - if (c == '|') - { - c = fgetc (Source); - if (c == '=') - return OR_EQUAL; - ungetc (c, Source); - return OR; - } - switch (c) - { - case '^': return XOR; - case '&': return AND; - case '-': return MINUS; - case '+': return PLUS; - case '*': return MULTIPLY; - case '(': return LPAREN; - case ')': return RPAREN; - case ',': return COMMA; - case '{': return LBRACE; - case '}': return RBRACE; - case '=': return EQUALS; - case ';': return SEMICOLON; - case ':': return COLON; - case '[': return LBRACKET; - case ']': return RBRACKET; - default: return 0; - } -} - -void *ParseAlloc(void *(*mallocProc)(size_t)); -void Parse(void *yyp, int yymajor, YYSTYPE yyminor); -void ParseFree(void *p, void (*freeProc)(void*)); -void ParseTrace(FILE *TraceFILE, char *zTracePrompt); - -void yyparse (void) -{ - void *pParser = ParseAlloc (malloc); - YYSTYPE token; - int tokentype; - int include_state = 0; - - while ((tokentype = yylex(&token)) != 0) - { - /* Whenever the sequence INCLUDE STRING is encountered in the token - * stream, feed a dummy NOP token to the parser so that it will - * reduce the include_statement before grabbing any more tokens - * from the current file. - */ - if (tokentype == INCLUDE && include_state == 0) - { - include_state = 1; - } - else if (tokentype == STRING && include_state == 1) - { - include_state = 2; - } - else - { - include_state = 0; - } - Parse (pParser, tokentype, token); - if (include_state == 2) - { - include_state = 0; - Parse (pParser, NOP, token); - } - } - memset (&token, 0, sizeof(token)); - Parse (pParser, 0, token); - ParseFree (pParser, free); -} - -static Symbol *FirstSym; - -static void AddSym (char *sym, int val) -{ - Symbol *syme = malloc (strlen (sym) + sizeof(Symbol)); - syme->Next = FirstSym; - syme->Value = val; - strcpy (syme->Sym, sym); - FirstSym = syme; -} - -static bool FindSym (char *sym, Symbol **val) -{ - Symbol *syme = FirstSym; - - while (syme != NULL) - { - if (strcmp (syme->Sym, sym) == 0) - { - *val = syme; - return 1; - } - syme = syme->Next; - } - return 0; -} - -static bool FindToken (char *tok, int *type) -{ - static const char tokens[][8] = - { - "endl", "print", "include", "special", "define", "enum", - "arg5", "arg4", "arg3", "arg2", "flags", "lineid", "tag" - - }; - static const short types[] = - { - ENDL, PRINT, INCLUDE, SPECIAL, DEFINE, ENUM, - ARG5, ARG4, ARG3, ARG2, FLAGS, LINEID, TAG - }; - int i; - - for (i = sizeof(tokens)/sizeof(tokens[0])-1; i >= 0; i--) - { - if (strcmp (tok, tokens[i]) == 0) - { - *type = types[i]; - return 1; - } - } - return 0; -} - -int yyerror (char *s) -{ - if (SourceName != NULL) - printf ("%s, line %d: %s\n", SourceName, SourceLine, s); - else - printf ("%s\n", s); - return 0; -} - -} - -%token_type {YYSTYPE} - -%syntax_error {yyerror("syntax error");} - -%type exp {int} -%type special_args {SpecialArgs} -%type list_val {struct ListFilter} -%type arg_list {MoreFilters *} -%type boom_args {ParseBoomArg} -%type boom_op {int} -%type boom_selector {int} -%type boom_line {BoomArg} -%type boom_body {MoreLines *} -%type maybe_argcount {int} - -%left OR. -%left XOR. -%left AND. -%left MINUS PLUS. -%left MULTIPLY DIVIDE. -%left NEG. - -main ::= translation_unit. - -exp(A) ::= NUM(B). { A = B.val; } -exp(A) ::= SYMNUM(B). { A = B.symval->Value; } -exp(A) ::= exp(B) PLUS exp(C). { A = B + C; } -exp(A) ::= exp(B) MINUS exp(C). { A = B - C; } -exp(A) ::= exp(B) MULTIPLY exp(C). { A = B * C; } -exp(A) ::= exp(B) DIVIDE exp(C). { A = B / C; } -exp(A) ::= exp(B) OR exp(C). { A = B | C; } -exp(A) ::= exp(B) AND exp(C). { A = B & C; } -exp(A) ::= exp(B) XOR exp(C). { A = B ^ C; } -exp(A) ::= MINUS exp(B). [NEG] { A = -B; } -exp(A) ::= LPAREN exp(B) RPAREN. { A = B; } - -translation_unit ::= . /* empty */ -translation_unit ::= translation_unit external_declaration. - -external_declaration ::= define_statement. -external_declaration ::= include_statement. -external_declaration ::= print_statement. -external_declaration ::= enum_statement. -external_declaration ::= linetype_declaration. -external_declaration ::= boom_declaration. -external_declaration ::= special_declaration. -external_declaration ::= NOP. - -print_statement ::= PRINT LPAREN print_list RPAREN. -{ - printf ("\n"); -} - -print_list ::= . /* EMPTY */ -print_list ::= print_item. -print_list ::= print_item COMMA print_list. - -print_item ::= STRING(A). { printf ("%s", A.string); } -print_item ::= exp(A). { printf ("%d", A); } -print_item ::= ENDL. { printf ("\n"); } - -define_statement ::= DEFINE SYM(A) LPAREN exp(B) RPAREN. -{ - AddSym (A.sym, B); -} - -include_statement ::= INCLUDE STRING(A). -{ - IncludeFile (A.string); -} - -enum_statement ::= enum_open enum_list RBRACE. - -enum_open ::= ENUM LBRACE. -{ - EnumVal = 0; -} - -enum_list ::= . /* empty */ -enum_list ::= single_enum. -enum_list ::= single_enum COMMA enum_list. - -single_enum ::= SYM(A). -{ - AddSym (A.sym, EnumVal++); -} - -single_enum ::= SYM(A) EQUALS exp(B). -{ - AddSym (A.sym, EnumVal = B); -} - -/* special declarations work just like they do for ACS, so - * specials can be defined just by including zspecial.acs - */ -special_declaration ::= SPECIAL special_list SEMICOLON. - -special_list ::= special_def. -special_list ::= special_list COMMA special_def. - -special_def ::= exp(A) COLON SYM(B) LPAREN maybe_argcount RPAREN. -{ - AddSym (B.sym, A); -} -special_def ::= exp COLON SYMNUM(B) LPAREN maybe_argcount RPAREN. -{ - printf ("%s, line %d: %s is already defined\n", SourceName, SourceLine, B.symval->Sym); -} - -maybe_argcount ::= . /* empty */ -maybe_argcount ::= exp. -maybe_argcount ::= exp COMMA exp. - -linetype_declaration ::= exp(linetype) EQUALS exp(flags) COMMA exp(special) LPAREN special_args(arg) RPAREN. -{ - Simple[linetype].NewSpecial = special; - Simple[linetype].Flags = flags | arg.addflags; - Simple[linetype].Args[0] = arg.args[0]; - Simple[linetype].Args[1] = arg.args[1]; - Simple[linetype].Args[2] = arg.args[2]; - Simple[linetype].Args[3] = arg.args[3]; - Simple[linetype].Args[4] = arg.args[4]; -} -linetype_declaration ::= exp EQUALS exp COMMA SYM(S) LPAREN special_args RPAREN. -{ - printf ("%s, line %d: %s is undefined\n", SourceName, SourceLine, S.sym); -} - -boom_declaration ::= LBRACKET exp(special) RBRACKET LPAREN exp(firsttype) COMMA exp(lasttype) RPAREN LBRACE boom_body(stores) RBRACE. -{ - if (NumBoomish == MAX_BOOMISH) - { - MoreLines *probe = stores; - - while (probe != NULL) - { - MoreLines *next = probe->next; - free (probe); - probe = next; - } - printf ("%s, line %d: Too many BOOM translators\n", SourceName, SourceLine); - } - else - { - int i; - MoreLines *probe; - - Boomish[NumBoomish].FirstLinetype = firsttype; - Boomish[NumBoomish].LastLinetype = lasttype; - Boomish[NumBoomish].NewSpecial = special; - - for (i = 0, probe = stores; probe != NULL; i++) - { - MoreLines *next = probe->next;; - if (i < MAX_BOOMISH_EXEC) - { - Boomish[NumBoomish].Args[i] = probe->arg; - } - else if (i == MAX_BOOMISH_EXEC) - { - printf ("%s, line %d: Too many commands for this BOOM translator\n", SourceName, SourceLine); - } - free (probe); - probe = next; - } - if (i < MAX_BOOMISH_EXEC) - { - Boomish[NumBoomish].Args[i].bDefined = 0; - } - NumBoomish++; - } -} - -boom_body(A) ::= . /* empty */ -{ - A = NULL; -} -boom_body(A) ::= boom_line(B) boom_body(C). -{ - A = malloc (sizeof(MoreLines)); - A->next = C; - A->arg = B; -} - -boom_line(A) ::= boom_selector(sel) boom_op(op) boom_args(args). -{ - A.bDefined = 1; - A.bOrExisting = (op == OR_EQUAL); - A.bUseConstant = (args.filters == NULL); - A.ArgNum = sel; - A.ConstantValue = args.constant; - A.AndValue = args.mask; - - if (args.filters != NULL) - { - int i; - MoreFilters *probe; - - for (i = 0, probe = args.filters; probe != NULL; i++) - { - MoreFilters *next = probe->next; - if (i < 15) - { - A.ResultFilter[i] = probe->filter.filter; - A.ResultValue[i] = probe->filter.value; - } - else if (i == 15) - { - yyerror ("Lists can only have 15 elements"); - } - free (probe); - probe = next; - } - A.ListSize = i > 15 ? 15 : i; - } -} - -boom_selector(A) ::= FLAGS. { A = 4; } -boom_selector(A) ::= ARG2. { A = 0; } -boom_selector(A) ::= ARG3. { A = 1; } -boom_selector(A) ::= ARG4. { A = 2; } -boom_selector(A) ::= ARG5. { A = 3; } - -boom_op(A) ::= EQUALS. { A = '='; } -boom_op(A) ::= OR_EQUAL. { A = OR_EQUAL; } - -boom_args(A) ::= exp(B). -{ - A.constant = B; - A.filters = NULL; -} -boom_args(A) ::= exp(B) LBRACKET arg_list(C) RBRACKET. -{ - A.mask = B; - A.filters = C; -} - -arg_list(A) ::= list_val(B). -{ - A = malloc (sizeof(MoreFilters)); - A->next = NULL; - A->filter = B; -} -arg_list(A) ::= list_val(B) COMMA arg_list(C). -{ - A = malloc (sizeof(MoreFilters)); - A->next = C; - A->filter = B; -} - -list_val(A) ::= exp(B) COLON exp(C). -{ - A.filter = B; - A.value = C; -} - -special_args(Z) ::= . /* empty */ -{ - Z.addflags = 0; - memset (Z.args, 0, 5); -} -special_args(Z) ::= TAG. -{ - Z.addflags = SIMPLE_HASTAGAT1; - memset (Z.args, 0, 5); -} -special_args(Z) ::= TAG COMMA exp(B). -{ - Z.addflags = SIMPLE_HASTAGAT1; - Z.args[0] = 0; - Z.args[1] = B; - Z.args[2] = 0; - Z.args[3] = 0; - Z.args[4] = 0; -} -special_args(Z) ::= TAG COMMA exp(B) COMMA exp(C). -{ - Z.addflags = SIMPLE_HASTAGAT1; - Z.args[0] = 0; - Z.args[1] = B; - Z.args[2] = C; - Z.args[3] = 0; - Z.args[4] = 0; -} -special_args(Z) ::= TAG COMMA exp(B) COMMA exp(C) COMMA exp(D). -{ - Z.addflags = SIMPLE_HASTAGAT1; - Z.args[0] = 0; - Z.args[1] = B; - Z.args[2] = C; - Z.args[3] = D; - Z.args[4] = 0; -} -special_args(Z) ::= TAG COMMA exp(B) COMMA exp(C) COMMA exp(D) COMMA exp(E). -{ - Z.addflags = SIMPLE_HASTAGAT1; - Z.args[0] = 0; - Z.args[1] = B; - Z.args[2] = C; - Z.args[3] = D; - Z.args[4] = E; -} -special_args(Z) ::= TAG COMMA TAG. -{ - Z.addflags = SIMPLE_HAS2TAGS; - Z.args[0] = Z.args[1] = 0; - Z.args[2] = 0; - Z.args[3] = 0; - Z.args[4] = 0; -} -special_args(Z) ::= TAG COMMA TAG COMMA exp(C). -{ - Z.addflags = SIMPLE_HAS2TAGS; - Z.args[0] = Z.args[1] = 0; - Z.args[2] = C; - Z.args[3] = 0; - Z.args[4] = 0; -} -special_args(Z) ::= TAG COMMA TAG COMMA exp(C) COMMA exp(D). -{ - Z.addflags = SIMPLE_HAS2TAGS; - Z.args[0] = Z.args[1] = 0; - Z.args[2] = C; - Z.args[3] = D; - Z.args[4] = 0; -} -special_args(Z) ::= TAG COMMA TAG COMMA exp(C) COMMA exp(D) COMMA exp(E). -{ - Z.addflags = SIMPLE_HAS2TAGS; - Z.args[0] = Z.args[1] = 0; - Z.args[2] = C; - Z.args[3] = D; - Z.args[4] = E; -} -special_args(Z) ::= LINEID. -{ - Z.addflags = SIMPLE_HASLINEID; - memset (Z.args, 0, 5); -} -special_args(Z) ::= LINEID COMMA exp(B). -{ - Z.addflags = SIMPLE_HASLINEID; - Z.args[0] = 0; - Z.args[1] = B; - Z.args[2] = 0; - Z.args[3] = 0; - Z.args[4] = 0; -} -special_args(Z) ::= LINEID COMMA exp(B) COMMA exp(C). -{ - Z.addflags = SIMPLE_HASLINEID; - Z.args[0] = 0; - Z.args[1] = B; - Z.args[2] = C; - Z.args[3] = 0; - Z.args[4] = 0; -} -special_args(Z) ::= LINEID COMMA exp(B) COMMA exp(C) COMMA exp(D). -{ - Z.addflags = SIMPLE_HASLINEID; - Z.args[0] = 0; - Z.args[1] = B; - Z.args[2] = C; - Z.args[3] = D; - Z.args[4] = 0; -} -special_args(Z) ::= LINEID COMMA exp(B) COMMA exp(C) COMMA exp(D) COMMA exp(E). -{ - Z.addflags = SIMPLE_HASLINEID; - Z.args[0] = 0; - Z.args[1] = B; - Z.args[2] = C; - Z.args[3] = D; - Z.args[4] = E; -} -special_args(Z) ::= exp(A). -{ - Z.addflags = 0; - Z.args[0] = A; - Z.args[1] = 0; - Z.args[2] = 0; - Z.args[3] = 0; - Z.args[4] = 0; -} -special_args(Z) ::= exp(A) COMMA exp(B). -{ - Z.addflags = 0; - Z.args[0] = A; - Z.args[1] = B; - Z.args[2] = 0; - Z.args[3] = 0; - Z.args[4] = 0; -} -special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C). -{ - Z.addflags = 0; - Z.args[0] = A; - Z.args[1] = B; - Z.args[2] = C; - Z.args[3] = 0; - Z.args[4] = 0; -} -special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA exp(D). -{ - Z.addflags = 0; - Z.args[0] = A; - Z.args[1] = B; - Z.args[2] = C; - Z.args[3] = D; - Z.args[4] = 0; -} -special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA exp(D) COMMA exp(E). -{ - Z.addflags = 0; - Z.args[0] = A; - Z.args[1] = B; - Z.args[2] = C; - Z.args[3] = D; - Z.args[4] = E; -} -special_args(Z) ::= exp(A) COMMA TAG. -{ - Z.addflags = SIMPLE_HASTAGAT2; - Z.args[0] = A; - Z.args[1] = 0; - Z.args[2] = 0; - Z.args[3] = 0; - Z.args[4] = 0; -} -special_args(Z) ::= exp(A) COMMA TAG COMMA exp(C). -{ - Z.addflags = SIMPLE_HASTAGAT2; - Z.args[0] = A; - Z.args[1] = 0; - Z.args[2] = C; - Z.args[3] = 0; - Z.args[4] = 0; -} -special_args(Z) ::= exp(A) COMMA TAG COMMA exp(C) COMMA exp(D). -{ - Z.addflags = SIMPLE_HASTAGAT2; - Z.args[0] = A; - Z.args[1] = 0; - Z.args[2] = C; - Z.args[3] = D; - Z.args[4] = 0; -} -special_args(Z) ::= exp(A) COMMA TAG COMMA exp(C) COMMA exp(D) COMMA exp(E). -{ - Z.addflags = SIMPLE_HASTAGAT2; - Z.args[0] = A; - Z.args[1] = 0; - Z.args[2] = C; - Z.args[3] = D; - Z.args[4] = E; -} -special_args(Z) ::= exp(A) COMMA exp(B) COMMA TAG. -{ - Z.addflags = SIMPLE_HASTAGAT3; - Z.args[0] = A; - Z.args[1] = B; - Z.args[2] = 0; - Z.args[3] = 0; - Z.args[4] = 0; -} -special_args(Z) ::= exp(A) COMMA exp(B) COMMA TAG COMMA exp(D). -{ - Z.addflags = SIMPLE_HASTAGAT3; - Z.args[0] = A; - Z.args[1] = B; - Z.args[2] = 0; - Z.args[3] = D; - Z.args[4] = 0; -} -special_args(Z) ::= exp(A) COMMA exp(B) COMMA TAG COMMA exp(D) COMMA exp(E). -{ - Z.addflags = SIMPLE_HASTAGAT3; - Z.args[0] = A; - Z.args[1] = B; - Z.args[2] = 0; - Z.args[3] = D; - Z.args[4] = E; -} -special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA TAG. -{ - Z.addflags = SIMPLE_HASTAGAT4; - Z.args[0] = A; - Z.args[1] = B; - Z.args[2] = C; - Z.args[3] = 0; - Z.args[4] = 0; -} -special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA TAG COMMA exp(E). -{ - Z.addflags = SIMPLE_HASTAGAT4; - Z.args[0] = A; - Z.args[1] = B; - Z.args[2] = C; - Z.args[3] = 0; - Z.args[4] = E; -} -special_args(Z) ::= exp(A) COMMA exp(B) COMMA exp(C) COMMA exp(D) COMMA TAG. -{ - Z.addflags = SIMPLE_HASTAGAT5; - Z.args[0] = A; - Z.args[1] = B; - Z.args[2] = C; - Z.args[3] = D; - Z.args[4] = 0; -} diff --git a/tools/xlatcc/xlat.h b/tools/xlatcc/xlat.h deleted file mode 100644 index 7f1eb896cc..0000000000 --- a/tools/xlatcc/xlat.h +++ /dev/null @@ -1,59 +0,0 @@ -#include - -typedef unsigned char BYTE; -typedef unsigned short WORD; -typedef unsigned char bool; - -#define MAX_BOOMISH 16 -#define MAX_BOOMISH_EXEC 32 - -#define SIMPLE_HASTAGAT1 (1<<5) // (tag, x, x, x, x) -#define SIMPLE_HASTAGAT2 (2<<5) // (x, tag, x, x, x) -#define SIMPLE_HASTAGAT3 (3<<5) // (x, x, tag, x, x) -#define SIMPLE_HASTAGAT4 (4<<5) // (x, x, x, tag, x) -#define SIMPLE_HASTAGAT5 (5<<5) // (x, x, x, x, tag) - -#define SIMPLE_HASLINEID (6<<5) // (tag, lineid, x, x, x, x) -#define SIMPLE_HAS2TAGS (7<<5) // (tag, tag, x, x, x) - -typedef struct -{ - BYTE Flags; - BYTE NewSpecial; - BYTE Args[5]; -} SimpleTranslator; - -typedef struct -{ - bool bDefined; - bool bOrExisting; - bool bUseConstant; - BYTE ListSize; - BYTE ArgNum; - BYTE ConstantValue; - WORD AndValue; - WORD ResultFilter[15]; - BYTE ResultValue[15]; -} BoomArg; - -typedef struct -{ - WORD FirstLinetype; - WORD LastLinetype; - BYTE NewSpecial; - BoomArg Args[MAX_BOOMISH_EXEC]; -} BoomTranslator; - -extern SimpleTranslator Simple[65536]; -extern BoomTranslator Boomish[MAX_BOOMISH]; - -extern int NumBoomish; - -extern FILE *Source; -extern char *SourceName; -extern int SourceLine; - -void IncludeFile (const char *name); -bool EndFile (); - -int yyerror (char *s); diff --git a/tools/xlatcc/xlatcc.vcproj b/tools/xlatcc/xlatcc.vcproj deleted file mode 100644 index ac0f4e7537..0000000000 --- a/tools/xlatcc/xlatcc.vcproj +++ /dev/null @@ -1,411 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/wadsrc/Makefile b/wadsrc/Makefile index ed93a89fdf..8c183509e0 100644 --- a/wadsrc/Makefile +++ b/wadsrc/Makefile @@ -10,17 +10,16 @@ RM=rm -f SLASH=/ MAKEWAD=..$(SLASH)tools$(SLASH)makewad$(SLASH)makewad -XLATCC=..$(SLASH)tools$(SLASH)xlatcc$(SLASH)xlatcc DEHSUPP=..$(SLASH)tools$(SLASH)dehsupp$(SLASH)dehsupp makethewad: wadmake Makefile2 - $(MAKE) $(NOLOGO) XLATCC=$(XLATCC) DEHSUPP=$(DEHSUPP) -f Makefile2 + $(MAKE) $(NOLOGO) DEHSUPP=$(DEHSUPP) -f Makefile2 wadmake: zdoom.lst $(MAKEWAD) -make wadmake zdoom.lst clean: - $(RM) wadmake zdoom.pk3 xlat$(SLASH)*.x dehsupp.lmp + $(RM) wadmake zdoom.pk3 dehsupp.lmp # This target is for Visual C++'s Rebuild All command nrebuild: clean diff --git a/wadsrc/Makefile2 b/wadsrc/Makefile2 index 532d76211f..0202e1bacb 100644 --- a/wadsrc/Makefile2 +++ b/wadsrc/Makefile2 @@ -1,14 +1,5 @@ include wadmake -xlat/doom.x: xlat/doomxlat.txt xlat/defines.i - $(XLATCC) xlat/doomxlat.txt xlat/doom.x - -xlat/heretic.x: xlat/hereticxlat.txt xlat/doomxlat.txt xlat/defines.i - $(XLATCC) xlat/hereticxlat.txt xlat/heretic.x - -xlat/strife.x: xlat/strifexlat.txt xlat/defines.i - $(XLATCC) xlat/strifexlat.txt xlat/strife.x - dehsupp.lmp: dehsupp.txt $(DEHSUPP) dehsupp.txt dehsupp.lmp \ No newline at end of file diff --git a/wadsrc/xlat/defines.i b/wadsrc/xlat/defines.i index b1ca451928..18e6c99349 100644 --- a/wadsrc/xlat/defines.i +++ b/wadsrc/xlat/defines.i @@ -1,23 +1,3 @@ -include "xlat/specials.i" - -// Not all specials are accessible from ACS, so define those here -special - 50:ExtraFloor_LightOnly(), - 100:Scroll_Texture_Left(), - 101:Scroll_Texture_Right(), - 102:Scroll_Texture_Up(), - 103:Scroll_Texture_Down(), - 121:Line_SetIdentification(), - 181:Plane_Align(), - 190:Static_Init(), - 209:Transfer_Heights(), - 210:Transfer_FloorLight(), - 211:Transfer_CeilingLight(), - 219:Sector_SetFriction(), - 222:Scroll_Texture_Model(), - 225:Scroll_Texture_Offsets(), - 227:PointPush_SetForce() -; // Static_Init types enum diff --git a/wadsrc/xlat/doomxlat.txt b/wadsrc/xlat/doom.txt similarity index 97% rename from wadsrc/xlat/doomxlat.txt rename to wadsrc/xlat/doom.txt index 2d0e373af9..ca13bc2445 100644 --- a/wadsrc/xlat/doomxlat.txt +++ b/wadsrc/xlat/doom.txt @@ -395,6 +395,7 @@ include "xlat/defines.i" * . */ + // Generalized crusher (tag, dnspeed, upspeed, silent, damage) [Generic_Crusher] (0x2f80, 0x2fff) { diff --git a/wadsrc/xlat/hereticxlat.txt b/wadsrc/xlat/heretic.txt similarity index 100% rename from wadsrc/xlat/hereticxlat.txt rename to wadsrc/xlat/heretic.txt diff --git a/wadsrc/xlat/specials.i b/wadsrc/xlat/specials.i deleted file mode 100644 index 5270714580..0000000000 --- a/wadsrc/xlat/specials.i +++ /dev/null @@ -1,190 +0,0 @@ -//************************************************************************** -//** -//** zspecials.acs -//** -//** This version is not kept up to date, but it has enough to make the -//** translators compile. -//** -//************************************************************************** - -special - 80:ACS_Execute(2,5), - 81:ACS_Suspend(2), - 82:ACS_Terminate(2), - 83:ACS_LockedExecute(5), - 42:Ceiling_CrushAndRaise(3), - 44:Ceiling_CrushStop(1), - 43:Ceiling_LowerAndCrush(3), - 40:Ceiling_LowerByValue(3), - 41:Ceiling_RaiseByValue(3), - 45:Ceiling_CrushRaiseAndStay(3), - 69:Ceiling_MoveToValueTimes8(4), - 10:Door_Close(2), - 11:Door_Open(2,3), - 12:Door_Raise(3,4), - 13:Door_LockedRaise(4,5), - 20:Floor_LowerByValue(3), - 36:Floor_LowerByValueTimes8(3), - 66:Floor_LowerInstant(3), - 68:Floor_MoveToValueTimes8(4), - 21:Floor_LowerToLowest(2), - 22:Floor_LowerToNearest(2), - 28:Floor_RaiseAndCrush(3), - 23:Floor_RaiseByValue(3), - 35:Floor_RaiseByValueTimes8(3), - 67:Floor_RaiseInstant(3), - 24:Floor_RaiseToHighest(2), - 25:Floor_RaiseToNearest(2), - 95:FloorAndCeiling_LowerByValue(3), - 96:FloorAndCeiling_RaiseByValue(3), - 46:Floor_CrushStop(1), - 109:Light_ForceLightning(1), - 110:Light_RaiseByValue(2), - 111:Light_LowerByValue(2), - 112:Light_ChangeToValue(2), - 113:Light_Fade(3), - 114:Light_Glow(4), - 115:Light_Flicker(3), - 116:Light_Strobe(5), - 117:Light_Stop(1), - 29:Pillar_Build(3), - 94:Pillar_BuildAndCrush(4), - 30:Pillar_Open(4), - 62:Plat_DownWaitUpStay(3), - 63:Plat_DownByValue(4), - 64:Plat_UpWaitDownStay(3), - 65:Plat_UpByValue(4), - 60:Plat_PerpetualRaise(3), - 61:Plat_Stop(1), - 6:Polyobj_MoveTimes8(4), - 4:Polyobj_Move(4), - 2:Polyobj_RotateLeft(3), - 3:Polyobj_RotateRight(3), - 7:Polyobj_DoorSwing(4), - 8:Polyobj_DoorSlide(5), - 93:Polyobj_OR_MoveTimes8(4), - 92:Polyobj_OR_Move(4), - 90:Polyobj_OR_RotateLeft(3), - 91:Polyobj_OR_RotateRight(3), - 120:Radius_Quake(5), - 140:Sector_ChangeSound(2), - 26:Stairs_BuildDown(5), - 27:Stairs_BuildUp(5), - 31:Stairs_BuildDownSync(4), - 32:Stairs_BuildUpSync(4), - 70:Teleport(1,3), - 71:Teleport_NoFog(1,3), - 74:Teleport_NewMap(2,3), - 75:Teleport_EndGame(0), - 72:ThrustThing(2,3), - 73:DamageThing(1), - 130:Thing_Activate(1), - 131:Thing_Deactivate(1), - 133:Thing_Destroy(1,2), - 134:Thing_Projectile(5), - 136:Thing_ProjectileGravity(5), - 132:Thing_Remove(1), - 135:Thing_Spawn(3,4), - 137:Thing_SpawnNoFog(3,4), - 138:Floor_Waggle(5), - - 9:Line_Horizon(0), - 14:Door_Animated(3), - 15:Autosave(0), - 33:ForceField(0), - 34:ClearForceField(1), - 38:Ceiling_Waggle(5), - 39:Teleport_ZombieChanger(2), - 49:GlassBreak(0), - 76:TeleportOther(3), - 77:TeleportGroup(5), - 78:TeleportInSector(4,5), - 84:ACS_ExecuteWithResult(1,4), - 119:Thing_Damage(2,3), - 125:Thing_Move(2), - 127:Thing_SetSpecial(5), - 128:ThrustThingZ(4), - 139:Thing_SpawnFacing(2,4), - 172:Plat_UpNearestWaitDownStay(3), - 173:NoiseAlert(2), - 174:SendToCommunicator(4), - 175:Thing_ProjectileIntercept(5), - 176:Thing_ChangeTID(2), - 177:Thing_Hate(2,3), - 178:Thing_ProjectileAimed(4,5), - 179:ChangeSkill(1), - 180:Thing_SetTranslation(2), -// 181:Plane_Align, - 182:Line_Mirror(0), - 183:Line_AlignCeiling(2), - 184:Line_AlignFloor(2), - 185:Sector_SetRotation(3), - 186:Sector_SetCeilingPanning(5), - 187:Sector_SetFloorPanning(5), - 188:Sector_SetCeilingScale(5), - 189:Sector_SetFloorScale(5), - 191:SetPlayerProperty(3), - 192:Ceiling_LowerToHighestFloor(2), - 193:Ceiling_LowerInstant(3), - 194:Ceiling_RaiseInstant(3), - 195:Ceiling_CrushRaiseAndStayA(4), - 196:Ceiling_CrushAndRaiseA(4), - 197:Ceiling_CrushAndRaiseSilentA(4), - 198:Ceiling_RaiseByValueTimes8(3), - 199:Ceiling_LowerByValueTimes8(3), - 200:Generic_Floor(5), - 201:Generic_Ceiling(5), - 202:Generic_Door(5), - 203:Generic_Lift(5), - 204:Generic_Stairs(5), - 205:Generic_Crusher(5), - 206:Plat_DownWaitUpStayLip(4,5), - 207:Plat_PerpetualRaiseLip(4), - 208:TranslucentLine(2,3), -// 209:Transfer_Heights, -// 210:Transfer_FloorLight, -// 211:Transfer_CeilingLight, - 212:Sector_SetColor(4,5), - 213:Sector_SetFade(4), - 214:Sector_SetDamage(3), - 215:Teleport_Line(2), - 216:Sector_SetGravity(3), - 217:Stairs_BuildUpDoom(5), - 218:Sector_SetWind(4), -// 219:Sector_SetFriction(4), - 220:Sector_SetCurrent(4), - 221:Scroll_Texture_Both(5), -// 222:Scroll_Texture_Model, - 223:Scroll_Floor(4), - 224:Scroll_Ceiling(4), -// 225:Scroll_Texture_Offsets, - 226:ACS_ExecuteAlways(2,5), -// 227:PointPush_SetForce, - 228:Plat_RaiseAndStayTx0(2), - 229:Thing_SetGoal(3), - 230:Plat_UpByValueStayTx(3), - 231:Plat_ToggleCeiling(1), - 232:Light_StrobeDoom(3), - 233:Light_MinNeighbor(1), - 234:Light_MaxNeighbor(1), - 235:Floor_TransferTrigger(1), - 236:Floor_TransferNumeric(1), - 237:ChangeCamera(3), - 238:Floor_RaiseToLowestCeiling(2), - 239:Floor_RaiseByValueTxTy(3), - 240:Floor_RaiseByTexture(2), - 241:Floor_LowerToLowestTxTy(2), - 242:Floor_LowerToHighest(3), - 243:Exit_Normal(1), - 244:Exit_Secret(1), - 245:Elevator_RaiseToNearest(2), - 246:Elevator_MoveToFloor(2), - 247:Elevator_LowerToNearest(2), - 248:HealThing(1,2), - 249:Door_CloseWaitOpen(3), - 250:Floor_Donut(3), - 251:FloorAndCeiling_LowerRaise(3), - 252:Ceiling_RaiseToNearest(2), - 253:Ceiling_LowerToLowest(2), - 254:Ceiling_LowerToFloor(2), - 255:Ceiling_CrushRaiseAndStaySilA(4); diff --git a/wadsrc/xlat/strifexlat.txt b/wadsrc/xlat/strife.txt similarity index 100% rename from wadsrc/xlat/strifexlat.txt rename to wadsrc/xlat/strife.txt diff --git a/wadsrc/zdoom.lst b/wadsrc/zdoom.lst index 0c6ec7d67d..49d83df1cf 100644 --- a/wadsrc/zdoom.lst +++ b/wadsrc/zdoom.lst @@ -63,14 +63,20 @@ teaminfo.txt teaminfo.txt althudcf.txt althudcf.txt sbarinfo.txt sbarinfo.txt +======== +# Doom map format translators + +xlat/doom.txt xlat/doom.txt +xlat/heretic.txt xlat/heretic.txt +xlat/strife.txt xlat/strife.txt +xlat/defines.i xlat/defines.i + + ======== # Support lumps dehsupp.lmp dehsupp.lmp -doomx.lmp xlat/doom.x -hereticx.lmp xlat/heretic.x -strifex.lmp xlat/strife.x sectorx.txt sectorx.txt animated.lmp animated.lmp diff --git a/zdoom.sln b/zdoom.sln index 1ac62dc888..35ddba98f1 100644 --- a/zdoom.sln +++ b/zdoom.sln @@ -1,13 +1,15 @@ Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 +# Visual C++ Express 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zdoom", "zdoom.vcproj", "{8049475B-5C87-46F9-9358-635218A4EF18}" ProjectSection(ProjectDependencies) = postProject - {E83FD370-2E72-4D4C-9427-FF9D9DED1E88} = {E83FD370-2E72-4D4C-9427-FF9D9DED1E88} {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466} = {AC3F5340-40CB-4C3A-8AA7-CB7158DB4466} + {1D179D4B-F008-431B-8C72-111F8372584F} = {1D179D4B-F008-431B-8C72-111F8372584F} {DA47396F-60C1-4BDE-A977-7F7DE461CF77} = {DA47396F-60C1-4BDE-A977-7F7DE461CF77} - {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} = {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} + {0F80ACBF-460E-44F0-B28E-B3272D1774A7} = {0F80ACBF-460E-44F0-B28E-B3272D1774A7} {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E} = {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E} {6077B7D6-349F-4077-B552-3BC302EF5859} = {6077B7D6-349F-4077-B552-3BC302EF5859} + {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} = {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} + {E83FD370-2E72-4D4C-9427-FF9D9DED1E88} = {E83FD370-2E72-4D4C-9427-FF9D9DED1E88} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "zlib\zlib.vcproj", "{F9D9E7D4-E1A2-4866-9E85-B1B14137EE63}" @@ -18,7 +20,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "re2c", "tools\re2c\re2c.vcp EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wadsrc", "wadsrc\wadsrc.vcproj", "{1D179D4B-F008-431B-8C72-111F8372584F}" ProjectSection(ProjectDependencies) = postProject - {3FFA68B3-9449-4B03-ADEE-194C3638623B} = {3FFA68B3-9449-4B03-ADEE-194C3638623B} {AC64EE8F-F019-4A3E-BCAF-BD1FD072B9C8} = {AC64EE8F-F019-4A3E-BCAF-BD1FD072B9C8} {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} = {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3} EndProjectSection @@ -28,8 +29,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "makewad", "tools\makewad\ma {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} = {F9D9E7D4-E1A2-4866-9E85-B1B14137EE63} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xlatcc", "tools\xlatcc\xlatcc.vcproj", "{3FFA68B3-9449-4B03-ADEE-194C3638623B}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dehsupp", "tools\dehsupp\dehsupp.vcproj", "{AC64EE8F-F019-4A3E-BCAF-BD1FD072B9C8}" ProjectSection(ProjectDependencies) = postProject {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E} = {667D2EE7-C357-49E2-9BAB-0A4A45F0F76E} @@ -100,14 +99,6 @@ Global {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Release|Win32.Build.0 = Release|Win32 {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Release|x64.ActiveCfg = Debug|x64 {24A19C02-F041-4AB0-A1A1-02E1E88EDBD3}.Release|x64.Build.0 = Debug|x64 - {3FFA68B3-9449-4B03-ADEE-194C3638623B}.Debug|Win32.ActiveCfg = Debug|Win32 - {3FFA68B3-9449-4B03-ADEE-194C3638623B}.Debug|Win32.Build.0 = Debug|Win32 - {3FFA68B3-9449-4B03-ADEE-194C3638623B}.Debug|x64.ActiveCfg = Release|Win32 - {3FFA68B3-9449-4B03-ADEE-194C3638623B}.Debug|x64.Build.0 = Release|Win32 - {3FFA68B3-9449-4B03-ADEE-194C3638623B}.Release|Win32.ActiveCfg = Release|Win32 - {3FFA68B3-9449-4B03-ADEE-194C3638623B}.Release|Win32.Build.0 = Release|Win32 - {3FFA68B3-9449-4B03-ADEE-194C3638623B}.Release|x64.ActiveCfg = Release|Win32 - {3FFA68B3-9449-4B03-ADEE-194C3638623B}.Release|x64.Build.0 = Release|Win32 {AC64EE8F-F019-4A3E-BCAF-BD1FD072B9C8}.Debug|Win32.ActiveCfg = Debug|Win32 {AC64EE8F-F019-4A3E-BCAF-BD1FD072B9C8}.Debug|Win32.Build.0 = Debug|Win32 {AC64EE8F-F019-4A3E-BCAF-BD1FD072B9C8}.Debug|x64.ActiveCfg = Release|Win32 diff --git a/zdoom.vcproj b/zdoom.vcproj index 41fd54311a..7b9b343931 100644 --- a/zdoom.vcproj +++ b/zdoom.vcproj @@ -6331,6 +6331,42 @@ + + + + + + + + + + + + + +