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