home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / C / YACCUNX.ZIP / DTXTRN.H < prev    next >
Encoding:
C/C++ Source or Header  |  1983-12-23  |  6.7 KB  |  308 lines

  1. /*
  2.  * DTXTRN.H  -- Original extern file for UNIX YACC.
  3.  *
  4.  * Modified to call in "decus" or "vax11c" .H files to set up
  5.  * parameters as appropriate.
  6.  */
  7.  
  8. #include <stdio.h>
  9. #include "system.h"
  10.  
  11. /*  MANIFEST CONSTANT DEFINITIONS */
  12.  
  13. /* base of nonterminal internal numbers */
  14. #define NTBASE 010000
  15.  
  16. /* internal codes for error and accept actions */
  17.  
  18. #define ERRCODE  8190
  19. #define ACCEPTCODE 8191
  20.  
  21. /* sizes and limits */
  22.  
  23. #ifdef HUGETAB
  24. #define ACTSIZE 12000
  25. #define MEMSIZE 12000
  26. #define NSTATES 750
  27. #define NTERMS 127
  28. #define NPROD 600
  29. #define NNONTERM 300
  30. #define TEMPSIZE 1200
  31. #define CNAMSZ 5000
  32. #define LSETSIZE 600
  33. #define WSETSIZE 350
  34. #endif
  35.  
  36. #ifdef MEDTAB
  37. #define ACTSIZE 4000
  38. #define MEMSIZE 5200
  39. #define NSTATES 600
  40. #define NTERMS 127
  41. #define NPROD 400
  42. #define NNONTERM 200
  43. #define TEMPSIZE 800
  44. #define CNAMSZ 4000
  45. #define LSETSIZE 450
  46. #define WSETSIZE 250
  47. #endif
  48.  
  49. #ifdef SMALLTAB
  50. #define ACTSIZE 1000
  51. #define MEMSIZE 1500
  52. #define NSTATES 450
  53. #define NTERMS 127
  54. #define NPROD 200
  55. #define NNONTERM 100
  56. #define TEMPSIZE 600
  57.  
  58. #define CNAMSZ 1000
  59. #define LSETSIZE 200
  60. #define WSETSIZE 125
  61. #endif
  62.  
  63. #define NAMESIZE 50
  64. #define NTYPES 63
  65.  
  66. #ifdef WORD32
  67. #define TBITSET ((32+NTERMS)/32)
  68.  
  69. /* bit packing macros (may be machine dependent) */
  70. #define BIT(a,i) ((a)[(i)>>5] & (1<<((i)&037)))
  71. #define SETBIT(a,i) ((a)[(i)>>5] |= (1<<((i)&037)))
  72.  
  73. /* number of words needed to hold n+1 bits */
  74. #define NWORDS(n) (((n)+32)/32)
  75.  
  76. #else
  77.  
  78. #define TBITSET ((16+NTERMS)/16)
  79.  
  80. /* bit packing macros (may be machine dependent) */
  81. #define BIT(a,i) ((a)[(i)>>4] & (1<<((i)&017)))
  82. #define SETBIT(a,i) ((a)[(i)>>4] |= (1<<((i)&017)))
  83.  
  84. /* number of words needed to hold n+1 bits */
  85. #define NWORDS(n) (((n)+16)/16)
  86. #endif
  87.  
  88. /* relationships which must hold:
  89.         TBITSET ints must hold NTERMS+1 bits...
  90.         WSETSIZE >= NNONTERM
  91.         LSETSIZE >= NNONTERM
  92.         TEMPSIZE >= NTERMS + NNONTERMs + 1
  93.         TEMPSIZE >= NSTATES
  94.         */
  95.  
  96. /* associativities */
  97.  
  98. #define NOASC 0  /* no assoc. */
  99. #define LASC 1  /* left assoc. */
  100. #define RASC 2  /* right assoc. */
  101. #define BASC 3  /* binary assoc. */
  102.  
  103. /* flags for state generation */
  104.  
  105. #define DONE 0
  106. #define MUSTDO 1
  107. #define MUSTLOOKAHEAD 2
  108.  
  109. /* flags for a rule having an action, and being reduced */
  110.  
  111. #define ACTFLAG 04
  112. #define REDFLAG 010
  113.  
  114. /* output parser flags */
  115. #define YYFLAG1 (-1000)
  116.  
  117. /* macros for getting associativity and precedence levels */
  118.  
  119. #define ASSOC(i) ((i)&03)
  120.  
  121. #define PLEVEL(i) (((i)>>4)&077)
  122. #define TYPE(i)  ((i>>10)&077)
  123.  
  124. /* macros for setting associativity and precedence levels */
  125.  
  126. #define SETASC(i,j) i|=j
  127. #define SETPLEV(i,j) i |= (j<<4)
  128. #define SETTYPE(i,j) i |= (j<<10)
  129.  
  130. /* looping macros */
  131.  
  132. #define TLOOP(i) for(i=1;i<=ntokens;++i)
  133. #define NTLOOP(i) for(i=0;i<=nnonter;++i)
  134. #define PLOOP(s,i) for(i=s;i<nprod;++i)
  135. #define SLOOP(i) for(i=0;i<nstate;++i)
  136. #define WSBUMP(x) ++x
  137. #define WSLOOP(s,j) for(j=s;j<cwp;++j)
  138. #define ITMLOOP(i,p,q) q=pstate[i+1];for(p=pstate[i];p<q;++p)
  139. #define SETLOOP(i) for(i=0;i<tbitset;++i)
  140.  
  141. /* I/O descriptors */
  142.  
  143. #ifndef y2imp
  144. extern FILE * finput;           /* input file */
  145. extern FILE * faction;          /* file for saving actions */
  146. extern FILE *fdefine;           /* file for #defines */
  147. extern FILE * ftable;           /* y.tab.c file */
  148. extern FILE * ftemp;            /* tempfile to pass 2 */
  149. extern FILE * foutput;          /* y.output file */
  150. #endif
  151.  
  152. /* structure declarations */
  153.  
  154. struct looksets
  155.    {
  156.    int lset[TBITSET];
  157.    };
  158.  
  159. struct item
  160.    {
  161.    int *pitem;
  162.    struct looksets *look;
  163.    };
  164.  
  165. struct toksymb
  166.    {
  167.    char *name;
  168.    int value;
  169.    };
  170.  
  171. struct ntsymb
  172.    {
  173.    char *name;
  174.    int tvalue;
  175.    };
  176.  
  177. struct wset
  178.    {
  179.    int *pitem;
  180.    int flag;
  181.    struct looksets ws;
  182.    };
  183.  
  184. #ifndef y2imp
  185. /* token information */
  186.  
  187. extern int ntokens ;    /* number of tokens */
  188. extern struct toksymb tokset[];
  189. extern int toklev[];    /* vector with the precedence of the terminals */
  190. #endif
  191.  
  192. /* nonterminal information */
  193.  
  194. #ifndef y2imp
  195. extern int nnonter ;    /* the number of nonterminals */
  196. extern struct ntsymb nontrst[];
  197. #endif
  198.  
  199. /* grammar rule information */
  200. #ifndef y2imp
  201. extern int nprod ;      /* number of productions */
  202. extern int *prdptr[];   /* pointers to descriptions of productions */
  203. extern int levprd[] ;   /* contains production levels to break conflicts */
  204. #endif
  205.  
  206. /* state information */
  207.  
  208. #ifndef y1imp
  209. extern int nstate ;             /* number of states */
  210. extern struct item *pstate[];   /* pointers to the descriptions of the states */
  211. extern int tystate[];   /* contains type information about the states */
  212. #ifndef y3imp
  213. extern int defact[];    /* the default action of the state */
  214. #endif
  215. extern int tstates[];   /* the states deriving each token */
  216. extern int ntstates[];  /* the states deriving each nonterminal */
  217. extern int mstates[];   /* the continuation of the chains begun in tstates and ntstates */
  218. #endif
  219.  
  220. /* lookahead set information */
  221.  
  222. #ifndef y1imp
  223. extern struct looksets lkst[];
  224. extern int nolook;  /* flag to turn off lookahead computations */
  225. #endif
  226.  
  227. /* working set information */
  228.  
  229. #ifndef y1imp
  230. extern struct wset wsets[];
  231. extern struct wset *cwp;
  232. #endif
  233.  
  234. /* storage for productions */
  235. #ifndef y2imp
  236. extern int mem0[];
  237. extern int *mem;
  238. #endif
  239.  
  240. /* storage for action table */
  241.  
  242. #ifndef y1imp
  243. extern int amem[];  /* action table storage */
  244. extern int *memp ;              /* next free action table position */
  245. extern int indgo[];             /* index to the stored goto table */
  246.  
  247. /* temporary vector, indexable by states, terms, or ntokens */
  248.  
  249. extern int temp1[];
  250. extern int lineno; /* current line number */
  251.  
  252. /* statistics collection variables */
  253.  
  254. extern int zzgoent ;
  255. extern int zzgobest ;
  256. extern int zzacent ;
  257. extern int zzexcp ;
  258. extern int zzclose ;
  259. extern int zzrrconf ;
  260. extern int zzsrconf ;
  261. #endif
  262.  
  263. /* define functions with strange types... */
  264.  
  265. extern char *cstash();
  266. extern struct looksets *flset();
  267. extern char *symnam();
  268. extern char *writem();
  269.  
  270. /* default settings for a number of macros */
  271.  
  272. #define ISIZE 400       /* Specific for static in cpres() */
  273.  
  274. /* name of yacc tempfiles */
  275.  
  276. #ifndef TEMPNAME
  277. #define TEMPNAME "yacc.tmp"
  278. #endif
  279.  
  280. #ifndef ACTNAME
  281. #define ACTNAME "yacc.act"
  282. #endif
  283.  
  284. /* output file name */
  285.  
  286. #ifndef OFILE
  287. #define OFILE "ytab.c"
  288. #endif
  289.  
  290. /* user output file name */
  291.  
  292. #ifndef FILEU
  293. #define FILEU "y.out"
  294. #endif
  295.  
  296. /* output file for #defines */
  297.  
  298. #ifndef FILED
  299. #define FILED "ytab.h"
  300. #endif
  301.  
  302. /* Size of complete filespec */
  303. #ifndef FNAMESIZE
  304. #define FNAMESIZE 32
  305. #endif
  306.  
  307. /* command to clobber tempfiles after use */
  308.  
  309. #ifndef ZAPFILE
  310. #define ZAPFILE(x) unlink(x)
  311. #endif
  312.