home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / compcomp / yacc / dtxtrn.h next >
Encoding:
C/C++ Source or Header  |  1979-12-31  |  8.8 KB  |  301 lines

  1. /************************************************************************/
  2. /*                dtXtrn.h                */
  3. /*                                                                      */
  4. /* Original extern file for UNIX YACC.                    */
  5. /*                                                                      */
  6. /* Modified to call in "decus" or "vax11c" .H files to set up        */
  7. /* parameters as appropriate.                        */
  8. /************************************************************************/   
  9.  
  10. /************************************************************************/
  11. /*                              history                                 */ 
  12. /*                                                                      */ 
  13. /*                                                                      */ 
  14. /* 86Jan01 CrT    MAXtERMINALsTATES 127->255, MAXy1lOOKAHEADsETS 450->200 */
  15. /* 85Nov14 CrT    Decrypted constants and macros.             */
  16. /* 85Nov11 CrT    Cosmetics.                        */
  17. /* 7?????? SCJ    Created.                        */
  18. /*                                    */
  19. /*                credits                 */
  20. /*      CrT=CrT                                                         */  
  21. /*      RBD=Bob Denny                                                   */  
  22. /*      SCJ=Steven C Johnson.                                           */  
  23. /*      SG =Scott Guthery                                               */  
  24. /************************************************************************/ 
  25.   
  26.  
  27.  
  28. /*  MANIFEST CONSTANT DEFINITIONS */
  29.  
  30. /* Base of nonterminal internal numbers: */
  31. #define FIRSTnONTERMINAL 010000
  32.  
  33. /* Internal codes for error and accept actions: */
  34. #define ERRORaCTION    8190
  35. #define ACCEPTaCTION   8191
  36.  
  37. /* Sizes and limits: */
  38.  
  39. #ifdef HUGETAB
  40. #define MAXaCTIONS        12000
  41. #define MAXy2POOL          12000
  42. #define MAXsTATES          750
  43. #define MAXtERMINALsTATES     127
  44. #define MAXpRODUCTIONS          600
  45. #define MAXnONTERMINALsTATES  300
  46. #define MAXy1TEMP         1200
  47. #define MAXy2TEXT         5000
  48. #define MAXy1lOOKAHEADsETS    600
  49. #define MAXy1wORKINGsET       350
  50. #endif
  51.  
  52. #ifdef MEDTAB
  53. #define MAXaCTIONS         4000
  54. #define MAXy2POOL           5200
  55. #define MAXsTATES          600
  56. /*#define MAXtERMINALsTATES    127*/
  57. #define MAXtERMINALsTATES     255
  58. #define MAXpRODUCTIONS          400
  59. #define MAXnONTERMINALsTATES  200
  60. #define MAXy1TEMP          800
  61. #define MAXy2TEXT         4000
  62. /*#define MAXy1lOOKAHEADsETS    450*/
  63. #define MAXy1lOOKAHEADsETS    200
  64. #define MAXy1wORKINGsET       250
  65. #endif
  66.  
  67. #ifdef SMALLTAB
  68. #define MAXaCTIONS         1000
  69. #define MAXy2POOL           1500
  70. #define MAXsTATES          450
  71. #define MAXtERMINALsTATES     127
  72. #define MAXpRODUCTIONS          200
  73. #define MAXnONTERMINALsTATES  100
  74. #define MAXy1TEMP          600
  75. #define MAXy2TEXT         1000
  76. #define MAXy1lOOKAHEADsETS    200
  77. #define MAXy1wORKINGsET       125
  78. #endif
  79.  
  80. #define NAMEsIZE   50
  81. #define MAXtYPES   63
  82.  
  83. #ifdef WORD32
  84. #define MAXlOOKAHEADsET ((32+MAXtERMINALsTATES)/32)
  85.  
  86. /* Bit packing macros (may be machine dependent): */
  87. #define GETBIT(a,i) ((a)[(i)>>5] &  (1<<((i)&037)))
  88. #define SETBIT(a,i) ((a)[(i)>>5] |= (1<<((i)&037)))
  89.  
  90. /* Number of words needed to hold n+1 bits: */
  91. #define NWORDS(n) (((n)+32)/32)
  92.  
  93. #else
  94.  
  95. #define MAXlOOKAHEADsET ((16+MAXtERMINALsTATES)/16)
  96.  
  97. /* Bit packing macros (may be machine dependent): */
  98. #define GETBIT(a,i) ((a)[(i)>>4] &  (1<<((i)&017)))
  99. #define SETBIT(a,i) ((a)[(i)>>4] |= (1<<((i)&017)))
  100.  
  101. /* Number of words needed to hold n+1 bits: */
  102. #define NWORDS(n) (((n)+16)/16)
  103. #endif
  104.  
  105. /******************************************************************/
  106. /*            CONSTRAINTS                  */
  107. /*    MAXlOOKAHEADsET ints must hold MAXtERMINALsTATES+1 bits.  */
  108. /*    MAXy1wORKINGsET    >= MAXnONTERMINALsTATES          */
  109. /*    MAXy1lOOKAHEADsETS >= MAXnONTERMINALsTATES          */
  110. /*    MAXy1TEMP >= MAXtERMINALsTATES + MAXnONTERMINALsTATES +1  */
  111. /*    MAXy1TEMP >= MAXsTATES                      */
  112. /******************************************************************/
  113.  
  114. /* Associativities: */
  115. #ifdef XYZZY
  116. #define NOTaSSOCIATIVE      0    /* No assoc.     */
  117. #endif
  118. #define LEFTaSSOCIATIVE   1    /* Left assoc.     */
  119. #define RIGHTaSSOCIATIVE  2    /* Right assoc.  */
  120. #define BINARYaSSOCIATIVE 3    /* Binary assoc. */
  121.  
  122. /* Flags for state generation: */
  123. #define DONEsTATE       0
  124. #define MUSTdOsTATE       1
  125. #define MUSTlOOKaHEADsTATE 2
  126.  
  127. /* Flags for a rule having an action, and being reduced: */
  128. #define RULEhASaCTION        04
  129. #define RULEhASbEENrEDUCED 010
  130.  
  131. /* Output parser flags: */
  132. #define YYFLAG1 (-1000)
  133.  
  134. /* Macros for getting associativity and precedence levels: */
  135. #define ASSOCIATIVITY(i)    ((i)    &03)
  136. #define PRECEDENCElEVEL(i) (((i)>>4)&077)
  137. #define TYPE(i)         ((i>>10)&077)
  138.  
  139. /* Macros for setting associativity and precedence levels: */
  140. #define SETaSSOCIATIVITYtO(i,j)     i |=  j
  141. #define SETpRECEDENCElEVELtO(i,j)   i |= (j<<4)
  142. #define SETtYPEtO(i,j)            i |= (j<<10)
  143.  
  144. /* Looping macros: */
  145. #define NEXTwORKINGsET(x)       ++x
  146. #define FORaLLtERMINALS(i)       for(i=1;i<=y2NextTerminal;++i)
  147. #define FORaLLnONTERMINALS(i)       for(i=0;i<=y2LastNonterminal;++i)
  148. #define FORaLLpRODUCTIONS(s,i)       for(i=s;i<y2ThisProduction;++i)
  149. #define FORaLLsTATES(i)        for(i=0;i<y1NextState;++i)
  150. #define FORaLLwORKINGsETS(s,j)       for(j=s;j<y1ThisWorkingSet;++j)
  151. #define FORaLLiTEMS(i,p,q)       q=y1StateItem[i+1];for(p=y1StateItem[i];p<q;++p)
  152. #define FORaLLlOOKAHEADwORDS(i)    for(i=0;i<y1MaxLookaheadSet;++i)
  153.  
  154. /* I/O descriptors: */
  155. extern FILE * y2InputFD;       /* Input file.               */
  156. extern FILE * y2ActionFD;       /* File to save actions in.           */
  157. extern FILE * y2DefineFD;       /* File for #defines.           */
  158. extern FILE * y2ytabcFD;       /* y.tab.c file.               */
  159. extern FILE * y2TempFileFD;       /* Temp. file to pass 2.           */
  160. extern FILE * y2OutputFD;       /* y.output file.               */
  161.  
  162.  
  163.  
  164. /* Structure declarations: */
  165.  
  166. /* Bit-vector sets of terminals: */
  167. struct looksets {
  168.     int lset[ MAXlOOKAHEADsET ];
  169. };
  170. #undef MAXlOOKAHEADsET
  171.  
  172. /* LR(1) "items" consist of a grammar rule, a position */
  173. /* within that rule, and a lookahead set of terminals: */
  174. struct item {
  175.     int *pitem;         /* Pointer into a grammar rule.     */
  176.     struct looksets *look;    /* Lookahead set.            */
  177. };
  178.  
  179. /* Terminal symbol: */
  180. struct toksymb {
  181.     char *name;         /* Pointer to name of terminal.     */
  182.     int value;            /* Internal integer name for it.    */
  183. };
  184.  
  185. /* Nonterminal symbol: */
  186. struct ntsymb {
  187.     char *name;         /* Pointer to name of nonterminal.  */
  188.     int tvalue;         /* Internal integer name for it.    */
  189. };
  190.  
  191. /* WorkingSet is a scratch version of Item: */
  192. struct wset {
  193.     int *pitem;         /* Pointer into grammar rule.        */
  194.     int flag;            /* Flag to trigger later processing.*/
  195.     struct looksets ws;     /* Lookahead set.            */
  196. };
  197.  
  198.  
  199.  
  200. /* Token information: */
  201. extern int        y2NextTerminal ;
  202. extern int        y2TerminalProperties[];
  203. extern struct toksymb    y2Terminal[];
  204.  
  205. /* Nonterminal information: */
  206. extern int        y2LastNonterminal ;
  207. extern struct ntsymb    y2NonterminalState[];
  208.  
  209. /* Grammar rule information: */
  210. extern int        y2ThisProduction ;
  211. extern int *        y2Production[];
  212. extern int        y2ProductionProperties[] ;
  213.  
  214. /* State information: */
  215. extern int        y1NextState ;
  216. extern struct item *    y1StateItem[];
  217. extern int        y1StateType[];
  218. extern int        y1TerminalState[];
  219. extern int        y1NonterminalState[];
  220.  
  221. /* Lookahead set information: */
  222. extern struct looksets    y1LookaheadSet[];
  223. extern int        y1NoLookahead;
  224.  
  225. /* Working set information: */
  226. extern struct wset    y1WorkingSet[];
  227. extern struct wset *    y1ThisWorkingSet;
  228.  
  229. /* Storage for productions: */
  230. extern int        y2Pool[];
  231. extern int *        y2FreePool;
  232.  
  233. /* Storage for action table: */
  234. extern int        y1Action[];
  235. extern int *        y1NextAction ;
  236. extern int        y1GotoIndex[];
  237.  
  238. /* Temporary vector, indexable by states, terms, or y2NextTerminal: */
  239. extern int        y1Temp[];
  240. extern int        y1LineNumber;
  241.  
  242. /* Statistics collection variables */
  243. extern int        y1GotoEntries ;
  244. extern int        y1GotosSavedByDefault ;
  245. extern int        y1ShiftEntries ;
  246. extern int        y1Exceptions ;
  247. extern int        y1ReduceReduceConflicts ;
  248. extern int        y1ShiftReduceConflicts ;
  249.  
  250. /* Define functions with strange types: */
  251. extern struct looksets *y1Lookahead();
  252. extern char           *y1SymbolName();
  253. extern char           *y1WriteItem();
  254. extern char            *y2EnterSymbol();
  255.  
  256. /* Default settings for a number of macros */
  257. #define ISIZE 400    /* Specific for static in cpres() */
  258.  
  259.  
  260.  
  261. /* Names of yacc tempfiles: */
  262.  
  263. #ifndef TEMPNAME
  264. #define TEMPNAME "yacc.tmp"
  265. #endif
  266.  
  267. #ifndef ACTNAME
  268. #define ACTNAME "yacc.act"
  269. #endif
  270.  
  271. /* Output filename: */
  272. #ifndef OFILE
  273. #define OFILE "ytab.c"
  274. #endif
  275.  
  276. /* User output filename: */
  277. #ifndef FILEU
  278. #define FILEU "y.out"
  279. #endif
  280.  
  281. /* Output file for #defines: */
  282. #ifndef FILED
  283. #define FILED "ytab.h"
  284. #endif
  285.  
  286. /* Size of complete filespec: */
  287. #ifndef FNAMESIZE
  288. #define FNAMESIZE 32
  289. #endif
  290.  
  291. /* Command to delete tempfiles after use: */
  292. #ifndef ZAPFILE
  293. #define ZAPFILE(x) unlink(x)
  294. #endif
  295.  
  296.  
  297.  
  298. /* Allow "loop { ..." in place of "while (TRUE) { ...": */
  299. #define loop while(1)
  300.  
  301.