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