]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/TianoTools/Pccts/antlr/egman.c
Restructuring for better separation of Tool packages.
[mirror_edk2.git] / Tools / Source / TianoTools / Pccts / antlr / egman.c
diff --git a/Tools/Source/TianoTools/Pccts/antlr/egman.c b/Tools/Source/TianoTools/Pccts/antlr/egman.c
deleted file mode 100644 (file)
index c8a633f..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-/*\r
- * egman.c\r
- *\r
- * SOFTWARE RIGHTS\r
- *\r
- * We reserve no LEGAL rights to the Purdue Compiler Construction Tool\r
- * Set (PCCTS) -- PCCTS is in the public domain.  An individual or\r
- * company may do whatever they wish with source code distributed with\r
- * PCCTS or the code generated by PCCTS, including the incorporation of\r
- * PCCTS, or its output, into commerical software.\r
- *\r
- * We encourage users to develop software with PCCTS.  However, we do ask\r
- * that credit is given to us for developing PCCTS.  By "credit",\r
- * we mean that if you incorporate our source code into one of your\r
- * programs (commercial product, research project, or otherwise) that you\r
- * acknowledge this fact somewhere in the documentation, research report,\r
- * etc...  If you like PCCTS and have developed a nice tool with the\r
- * output, please mention that you developed it using PCCTS.  In\r
- * addition, we ask that this header remain intact in our source code.\r
- * As long as these guidelines are kept, we expect to continue enhancing\r
- * this system and expect to make other tools available as they are\r
- * completed.\r
- *\r
- * ANTLR 1.33MR10\r
- * 2001\r
- *\r
- */\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-\r
-#include "set.h"\r
-#include "syn.h"\r
-#include "hash.h"\r
-#include "generic.h"\r
-#include "proto.h"\r
-\r
-static ExceptionGroup **egArray=NULL;   /* ExceptionGroup by BlkLevel */\r
-static LabelEntry     **leArray=NULL;   /* LabelEntry by BlkLevel     */\r
-static Junction       **altArray=NULL;  /* start of alternates        */\r
-static int              arraySize=0;\r
-static int              highWater=0;\r
-static ExceptionGroup *lastEG=NULL;     /* used in altFixup()         */\r
-static int             lastBlkLevel=0;  /* used in altFixup()         */\r
-\r
-#ifdef __USE_PROTOS\r
-static void arrayCheck(void);\r
-#else\r
-static void arrayCheck();\r
-#endif\r
-\r
-/* Called to add an exception group for an alternative EG */\r
-\r
-#ifdef __USE_PROTOS\r
-void egAdd(ExceptionGroup * eg)\r
-#else\r
-void egAdd(eg)\r
-ExceptionGroup *eg;\r
-#endif\r
-{\r
-  int               i;\r
-\r
-  ExceptionGroup    *nextEG;\r
-  ExceptionGroup    *innerEG;\r
-\r
-  LabelEntry        *nextLE;\r
-  LabelEntry        *innerLE;\r
-\r
-  Junction          *nextAlt;\r
-  Junction          *innerAlt;\r
-\r
-  lastEG=eg;\r
-  lastBlkLevel=BlkLevel;\r
-\r
-  arrayCheck();\r
-  eg->pendingLink=egArray[BlkLevel];\r
-  egArray[BlkLevel]=eg;\r
-\r
-  /* EG for alternates already have their altID filled in      */\r
-\r
-  for (i=BlkLevel+1; i<=highWater ; i++) {\r
-    for (innerEG=egArray[i]; innerEG != NULL ; innerEG=nextEG) {\r
-      nextEG=innerEG->pendingLink;\r
-      innerEG->pendingLink=NULL;\r
-      innerEG->outerEG=eg;\r
-    };\r
-    egArray[i]=NULL;\r
-  };\r
-\r
-  /*\r
-   *  for patching up the LabelEntry you might use an EG for the\r
-   *  current alternative - unlike patching up an alternative EG\r
-   *    i.e. start the loop at BlkLevel rather than (BlkLevel+1)\r
-   *  fill it in only if the EG and the LE are for the very\r
-   *    same alternative if they're at the same BlkLevel\r
-   *  it's easier to leave the LE on this list (filled in) rather than\r
-   *    trying to selectively remove it.  It will eventually be\r
-   *    removed anyway when the BlkLevel gets small enough.\r
-   */\r
-\r
-  for (i=BlkLevel; i<=highWater ; i++) {\r
-    for (innerLE=leArray[i]; innerLE != NULL ; innerLE=nextLE) {\r
-      nextLE=innerLE->pendingLink;\r
-      if (BlkLevel != i ||\r
-        innerLE->curAltNum == CurAltNum_array[BlkLevel]) {\r
-        if (innerLE->outerEG == NULL) {\r
-          innerLE->outerEG=eg;\r
-        };\r
-      };\r
-    };\r
-    if (BlkLevel != i) leArray[i]=NULL;\r
-  };\r
-\r
-/*\r
- * For the start of alternatives it is necessary to make a\r
- * distinction between the exception group for the current\r
- * alternative and the "fallback" EG for the block which\r
- * contains the alternative\r
- *\r
- * The fallback outerEG is used to handle the case where\r
- * no alternative of a block matches.  In that case the\r
- * signal is "NoViableAlt" (or "NoSemViableAlt" and the\r
- * generator needs the EG of the block CONTAINING the\r
- * current one.\r
- *\r
- *      rule: ( ( ( a\r
- *                | b\r
- *                )\r
- *              | c\r
- *              )\r
- *            | d\r
- *            );\r
- */\r
-\r
-  for (i=BlkLevel; i <= highWater ; i++) {\r
-    for (innerAlt=altArray[i]; innerAlt != NULL ; innerAlt=nextAlt) {\r
-      nextAlt=innerAlt->pendingLink;\r
-\r
-      /*  first fill in the EG for the current alternative         */\r
-      /*  but leave it on the list in order to get the fallback EG */\r
-      /*  if the EG is at the same LEVEL as the alternative then   */\r
-      /*    fill it in only if in the very same alternative        */\r
-      /*                                                           */\r
-      /*        rule: ( a                                          */\r
-      /*              | b                                          */\r
-      /*              | c  exception ...                           */\r
-      /*              )                                            */\r
-      /*                                                           */\r
-      /*  if the EG is outside the alternative (e.g. BlkLevel < i) */\r
-      /*    then it doesn't matter about the alternative           */\r
-      /*                                                           */\r
-      /*        rule: ( a                                          */\r
-      /*              | b                                          */\r
-      /*              | c                                          */\r
-      /*              )   exception ...                            */\r
-      /*                                                           */\r
-\r
-#if 0\r
-      printf("BlkLevel=%d i=%d altnum=%d CurAltNum=%d altID=%s\n",\r
-        BlkLevel,i,innerAlt->curAltNum,CurAltNum_array[BlkLevel],eg->altID);\r
-#endif\r
-      if (BlkLevel != i ||\r
-          innerAlt->curAltNum == CurAltNum_array[BlkLevel]) {\r
-        if (innerAlt->exception_label == NULL) {\r
-          innerAlt->exception_label=eg->altID;\r
-        };\r
-      };\r
-\r
-      /*  ocurs at a later pass then for the exception_label       */\r
-      /*  if an outerEG has been found then fill in the outer EG   */\r
-      /*  remove if from the list when the BlkLevel gets smaller   */\r
-\r
-      if (BlkLevel != i) {\r
-        if (innerAlt->outerEG == NULL) {\r
-          innerAlt->outerEG=eg;\r
-        };\r
-      };\r
-    };\r
-    if (BlkLevel != i) altArray[i]=NULL;\r
-  };\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void leAdd(LabelEntry * le)\r
-#else\r
-void leAdd(le)\r
-LabelEntry *le;\r
-#endif\r
-\r
-{\r
-  arrayCheck();\r
-  le->pendingLink=leArray[BlkLevel];\r
-  le->curAltNum=CurAltNum_array[BlkLevel];\r
-  leArray[BlkLevel]=le;\r
-}\r
-\r
-#ifdef __USE_PROTOS\r
-void altAdd(Junction *alt)\r
-#else\r
-void altAdd(alt)\r
-Junction *alt;\r
-#endif\r
-\r
-{\r
-  arrayCheck();\r
-#if 0\r
-  printf("BlkLevel=%d CurAltNum=%d\n",\r
-            BlkLevel,CurAltNum_array[BlkLevel]);\r
-#endif\r
-  alt->curAltNum=CurAltNum_array[BlkLevel];\r
-  alt->pendingLink=altArray[BlkLevel];\r
-  altArray[BlkLevel]=alt;\r
-}\r
-\r
-static void \r
-#ifdef __USE_PROTOS\r
-arrayCheck(void)\r
-#else\r
-arrayCheck()\r
-#endif\r
-{\r
-  ExceptionGroup    **egArrayNew;\r
-  LabelEntry        **leArrayNew;\r
-  Junction          **altArrayNew;\r
-  int               arraySizeNew;\r
-  int               i;\r
-\r
-  if (BlkLevel > highWater) highWater=BlkLevel;\r
-\r
-  if (BlkLevel >= arraySize) {\r
-    arraySizeNew=BlkLevel+5;   /* MR20 */\r
-    egArrayNew=(ExceptionGroup **)\r
-        calloc(arraySizeNew,sizeof(ExceptionGroup *));\r
-    leArrayNew=(LabelEntry **)\r
-        calloc(arraySizeNew,sizeof(LabelEntry *));\r
-    altArrayNew=(Junction **)\r
-        calloc(arraySizeNew,sizeof(Junction *));\r
-    for (i=0; i<arraySize ; i++) {\r
-      egArrayNew[i]=egArray[i];\r
-      leArrayNew[i]=leArray[i];\r
-      altArrayNew[i]=altArray[i];\r
-    };\r
-    arraySize=arraySizeNew;\r
-    if (egArray != NULL) free( (char *) egArray);\r
-    if (leArray != NULL) free( (char *) leArray);\r
-    if (altArray != NULL) free( (char *) altArray);\r
-    egArray=egArrayNew;\r
-    leArray=leArrayNew;\r
-    altArray=altArrayNew;\r
-  };\r
-}\r
-\r
-/* always call leFixup() BEFORE egFixup() */\r
-\r
-void \r
-#ifdef __USE_PROTOS\r
-egFixup(void) \r
-#else\r
-egFixup()\r
-#endif\r
-{\r
-  int               i;\r
-  ExceptionGroup    *nextEG;\r
-  ExceptionGroup    *innerEG;\r
-\r
-  for (i=1; i<=highWater ; i++) {\r
-    for (innerEG=egArray[i]; innerEG != NULL ; innerEG=nextEG) {\r
-      nextEG=innerEG->pendingLink;\r
-      innerEG->pendingLink=NULL;\r
-    };\r
-    egArray[i]=NULL;\r
-  };\r
-  lastEG=NULL;\r
-  lastBlkLevel=0;\r
-}\r
-\r
-/* always call leFixup() BEFORE egFixup() */\r
-\r
-#ifdef __USE_PROTOS\r
-void leFixup(void) \r
-#else\r
-void leFixup() \r
-#endif\r
-{\r
-\r
-  int               i;\r
-  LabelEntry        *nextLE;\r
-  LabelEntry        *innerLE;\r
-\r
-  for (i=BlkLevel; i<=highWater ; i++) {\r
-    for (innerLE=leArray[i]; innerLE != NULL ; innerLE=nextLE) {\r
-      nextLE=innerLE->pendingLink;\r
-      innerLE->pendingLink=NULL;\r
-    };\r
-    leArray[i]=NULL;\r
-  };\r
-}\r
-\r
-/* always call altFixup() BEFORE egFixup() */\r
-\r
-#ifdef __USE_PROTOS\r
-void altFixup(void)\r
-#else\r
-void altFixup() \r
-#endif\r
-{\r
-\r
-  int               i;\r
-  Junction          *nextAlt;\r
-  Junction          *innerAlt;\r
-\r
-  for (i=BlkLevel; i<=highWater ; i++) {\r
-    for (innerAlt=altArray[i]; innerAlt != NULL ; innerAlt=nextAlt) {\r
-\r
-      /*  if an outerEG has been found then fill in the outer EG   */\r
-\r
-      if (lastBlkLevel <= i) {\r
-        if (innerAlt->outerEG == NULL) {\r
-          innerAlt->outerEG=lastEG;\r
-        };\r
-      };\r
-      nextAlt=innerAlt->pendingLink;\r
-      innerAlt->pendingLink=NULL;\r
-    };\r
-    altArray[i]=NULL;\r
-  };\r
-}\r
-\r