home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* dtXtrn.h */
- /* */
- /* Original extern file for UNIX YACC. */
- /* */
- /* Modified to call in "decus" or "vax11c" .H files to set up */
- /* parameters as appropriate. */
- /************************************************************************/
-
- /************************************************************************/
- /* history */
- /* */
- /* */
- /* 86Jan01 CrT MAXtERMINALsTATES 127->255, MAXy1lOOKAHEADsETS 450->200 */
- /* 85Nov14 CrT Decrypted constants and macros. */
- /* 85Nov11 CrT Cosmetics. */
- /* 7?????? SCJ Created. */
- /* */
- /* credits */
- /* CrT=CrT */
- /* RBD=Bob Denny */
- /* SCJ=Steven C Johnson. */
- /* SG =Scott Guthery */
- /************************************************************************/
-
-
-
- /* MANIFEST CONSTANT DEFINITIONS */
-
- /* Base of nonterminal internal numbers: */
- #define FIRSTnONTERMINAL 010000
-
- /* Internal codes for error and accept actions: */
- #define ERRORaCTION 8190
- #define ACCEPTaCTION 8191
-
- /* Sizes and limits: */
-
- #ifdef HUGETAB
- #define MAXaCTIONS 12000
- #define MAXy2POOL 12000
- #define MAXsTATES 750
- #define MAXtERMINALsTATES 127
- #define MAXpRODUCTIONS 600
- #define MAXnONTERMINALsTATES 300
- #define MAXy1TEMP 1200
- #define MAXy2TEXT 5000
- #define MAXy1lOOKAHEADsETS 600
- #define MAXy1wORKINGsET 350
- #endif
-
- #ifdef MEDTAB
- #define MAXaCTIONS 4000
- #define MAXy2POOL 5200
- #define MAXsTATES 600
- /*#define MAXtERMINALsTATES 127*/
- #define MAXtERMINALsTATES 255
- #define MAXpRODUCTIONS 400
- #define MAXnONTERMINALsTATES 200
- #define MAXy1TEMP 800
- #define MAXy2TEXT 4000
- /*#define MAXy1lOOKAHEADsETS 450*/
- #define MAXy1lOOKAHEADsETS 200
- #define MAXy1wORKINGsET 250
- #endif
-
- #ifdef SMALLTAB
- #define MAXaCTIONS 1000
- #define MAXy2POOL 1500
- #define MAXsTATES 450
- #define MAXtERMINALsTATES 127
- #define MAXpRODUCTIONS 200
- #define MAXnONTERMINALsTATES 100
- #define MAXy1TEMP 600
- #define MAXy2TEXT 1000
- #define MAXy1lOOKAHEADsETS 200
- #define MAXy1wORKINGsET 125
- #endif
-
- #define NAMEsIZE 50
- #define MAXtYPES 63
-
- #ifdef WORD32
- #define MAXlOOKAHEADsET ((32+MAXtERMINALsTATES)/32)
-
- /* Bit packing macros (may be machine dependent): */
- #define GETBIT(a,i) ((a)[(i)>>5] & (1<<((i)&037)))
- #define SETBIT(a,i) ((a)[(i)>>5] |= (1<<((i)&037)))
-
- /* Number of words needed to hold n+1 bits: */
- #define NWORDS(n) (((n)+32)/32)
-
- #else
-
- #define MAXlOOKAHEADsET ((16+MAXtERMINALsTATES)/16)
-
- /* Bit packing macros (may be machine dependent): */
- #define GETBIT(a,i) ((a)[(i)>>4] & (1<<((i)&017)))
- #define SETBIT(a,i) ((a)[(i)>>4] |= (1<<((i)&017)))
-
- /* Number of words needed to hold n+1 bits: */
- #define NWORDS(n) (((n)+16)/16)
- #endif
-
- /******************************************************************/
- /* CONSTRAINTS */
- /* MAXlOOKAHEADsET ints must hold MAXtERMINALsTATES+1 bits. */
- /* MAXy1wORKINGsET >= MAXnONTERMINALsTATES */
- /* MAXy1lOOKAHEADsETS >= MAXnONTERMINALsTATES */
- /* MAXy1TEMP >= MAXtERMINALsTATES + MAXnONTERMINALsTATES +1 */
- /* MAXy1TEMP >= MAXsTATES */
- /******************************************************************/
-
- /* Associativities: */
- #ifdef XYZZY
- #define NOTaSSOCIATIVE 0 /* No assoc. */
- #endif
- #define LEFTaSSOCIATIVE 1 /* Left assoc. */
- #define RIGHTaSSOCIATIVE 2 /* Right assoc. */
- #define BINARYaSSOCIATIVE 3 /* Binary assoc. */
-
- /* Flags for state generation: */
- #define DONEsTATE 0
- #define MUSTdOsTATE 1
- #define MUSTlOOKaHEADsTATE 2
-
- /* Flags for a rule having an action, and being reduced: */
- #define RULEhASaCTION 04
- #define RULEhASbEENrEDUCED 010
-
- /* Output parser flags: */
- #define YYFLAG1 (-1000)
-
- /* Macros for getting associativity and precedence levels: */
- #define ASSOCIATIVITY(i) ((i) &03)
- #define PRECEDENCElEVEL(i) (((i)>>4)&077)
- #define TYPE(i) ((i>>10)&077)
-
- /* Macros for setting associativity and precedence levels: */
- #define SETaSSOCIATIVITYtO(i,j) i |= j
- #define SETpRECEDENCElEVELtO(i,j) i |= (j<<4)
- #define SETtYPEtO(i,j) i |= (j<<10)
-
- /* Looping macros: */
- #define NEXTwORKINGsET(x) ++x
- #define FORaLLtERMINALS(i) for(i=1;i<=y2NextTerminal;++i)
- #define FORaLLnONTERMINALS(i) for(i=0;i<=y2LastNonterminal;++i)
- #define FORaLLpRODUCTIONS(s,i) for(i=s;i<y2ThisProduction;++i)
- #define FORaLLsTATES(i) for(i=0;i<y1NextState;++i)
- #define FORaLLwORKINGsETS(s,j) for(j=s;j<y1ThisWorkingSet;++j)
- #define FORaLLiTEMS(i,p,q) q=y1StateItem[i+1];for(p=y1StateItem[i];p<q;++p)
- #define FORaLLlOOKAHEADwORDS(i) for(i=0;i<y1MaxLookaheadSet;++i)
-
- /* I/O descriptors: */
- extern FILE * y2InputFD; /* Input file. */
- extern FILE * y2ActionFD; /* File to save actions in. */
- extern FILE * y2DefineFD; /* File for #defines. */
- extern FILE * y2ytabcFD; /* y.tab.c file. */
- extern FILE * y2TempFileFD; /* Temp. file to pass 2. */
- extern FILE * y2OutputFD; /* y.output file. */
-
-
-
- /* Structure declarations: */
-
- /* Bit-vector sets of terminals: */
- struct looksets {
- int lset[ MAXlOOKAHEADsET ];
- };
- #undef MAXlOOKAHEADsET
-
- /* LR(1) "items" consist of a grammar rule, a position */
- /* within that rule, and a lookahead set of terminals: */
- struct item {
- int *pitem; /* Pointer into a grammar rule. */
- struct looksets *look; /* Lookahead set. */
- };
-
- /* Terminal symbol: */
- struct toksymb {
- char *name; /* Pointer to name of terminal. */
- int value; /* Internal integer name for it. */
- };
-
- /* Nonterminal symbol: */
- struct ntsymb {
- char *name; /* Pointer to name of nonterminal. */
- int tvalue; /* Internal integer name for it. */
- };
-
- /* WorkingSet is a scratch version of Item: */
- struct wset {
- int *pitem; /* Pointer into grammar rule. */
- int flag; /* Flag to trigger later processing.*/
- struct looksets ws; /* Lookahead set. */
- };
-
-
-
- /* Token information: */
- extern int y2NextTerminal ;
- extern int y2TerminalProperties[];
- extern struct toksymb y2Terminal[];
-
- /* Nonterminal information: */
- extern int y2LastNonterminal ;
- extern struct ntsymb y2NonterminalState[];
-
- /* Grammar rule information: */
- extern int y2ThisProduction ;
- extern int * y2Production[];
- extern int y2ProductionProperties[] ;
-
- /* State information: */
- extern int y1NextState ;
- extern struct item * y1StateItem[];
- extern int y1StateType[];
- extern int y1TerminalState[];
- extern int y1NonterminalState[];
-
- /* Lookahead set information: */
- extern struct looksets y1LookaheadSet[];
- extern int y1NoLookahead;
-
- /* Working set information: */
- extern struct wset y1WorkingSet[];
- extern struct wset * y1ThisWorkingSet;
-
- /* Storage for productions: */
- extern int y2Pool[];
- extern int * y2FreePool;
-
- /* Storage for action table: */
- extern int y1Action[];
- extern int * y1NextAction ;
- extern int y1GotoIndex[];
-
- /* Temporary vector, indexable by states, terms, or y2NextTerminal: */
- extern int y1Temp[];
- extern int y1LineNumber;
-
- /* Statistics collection variables */
- extern int y1GotoEntries ;
- extern int y1GotosSavedByDefault ;
- extern int y1ShiftEntries ;
- extern int y1Exceptions ;
- extern int y1ReduceReduceConflicts ;
- extern int y1ShiftReduceConflicts ;
-
- /* Define functions with strange types: */
- extern struct looksets *y1Lookahead();
- extern char *y1SymbolName();
- extern char *y1WriteItem();
- extern char *y2EnterSymbol();
-
- /* Default settings for a number of macros */
- #define ISIZE 400 /* Specific for static in cpres() */
-
-
-
- /* Names of yacc tempfiles: */
-
- #ifndef TEMPNAME
- #define TEMPNAME "yacc.tmp"
- #endif
-
- #ifndef ACTNAME
- #define ACTNAME "yacc.act"
- #endif
-
- /* Output filename: */
- #ifndef OFILE
- #define OFILE "ytab.c"
- #endif
-
- /* User output filename: */
- #ifndef FILEU
- #define FILEU "y.out"
- #endif
-
- /* Output file for #defines: */
- #ifndef FILED
- #define FILED "ytab.h"
- #endif
-
- /* Size of complete filespec: */
- #ifndef FNAMESIZE
- #define FNAMESIZE 32
- #endif
-
- /* Command to delete tempfiles after use: */
- #ifndef ZAPFILE
- #define ZAPFILE(x) unlink(x)
- #endif
-
-
-
- /* Allow "loop { ..." in place of "while (TRUE) { ...": */
- #define loop while(1)
-
-