xref: /csrg-svn/old/lex/once.c (revision 14491)
1*14491Ssam /*	once.c	4.1	83/08/11	*/
2*14491Ssam 	/* because of external definitions, this code should occur only once */
3*14491Ssam # ifdef ASCII
4*14491Ssam int ctable[2*NCH] = {
5*14491Ssam   0,  1,  2,  3,  4,  5,  6,  7,  8,  9,
6*14491Ssam  10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
7*14491Ssam  20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
8*14491Ssam  30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
9*14491Ssam  40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
10*14491Ssam  50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
11*14491Ssam  60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
12*14491Ssam  70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
13*14491Ssam  80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
14*14491Ssam  90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
15*14491Ssam 100,101,102,103,104,105,106,107,108,109,
16*14491Ssam 110,111,112,113,114,115,116,117,118,119,
17*14491Ssam 120,121,122,123,124,125,126,127};
18*14491Ssam # endif
19*14491Ssam # ifdef EBCDIC
20*14491Ssam int ctable[2*NCH] = {
21*14491Ssam   0,  1,  2,  3,  4,  5,  6,  7,  8,  9,
22*14491Ssam  10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
23*14491Ssam  20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
24*14491Ssam  30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
25*14491Ssam  40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
26*14491Ssam  50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
27*14491Ssam  60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
28*14491Ssam  70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
29*14491Ssam  80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
30*14491Ssam  90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
31*14491Ssam 100,101,102,103,104,105,106,107,108,109,
32*14491Ssam 110,111,112,113,114,115,116,117,118,119,
33*14491Ssam 120,121,122,123,124,125,126,127,128,129,
34*14491Ssam 130,131,132,133,134,135,136,137,138,139,
35*14491Ssam 140,141,142,143,144,145,146,147,148,149,
36*14491Ssam 150,151,152,153,154,155,156,157,158,159,
37*14491Ssam 160,161,162,163,164,165,166,167,168,169,
38*14491Ssam 170,171,172,173,174,175,176,177,178,179,
39*14491Ssam 180,181,182,183,184,185,186,187,188,189,
40*14491Ssam 190,191,192,193,194,195,196,197,198,199,
41*14491Ssam 200,201,202,203,204,205,206,207,208,209,
42*14491Ssam 210,211,212,213,214,215,216,217,218,219,
43*14491Ssam 220,221,222,223,224,225,226,227,228,229,
44*14491Ssam 230,231,232,233,234,235,236,237,238,239,
45*14491Ssam 240,241,242,243,244,245,246,247,248,249,
46*14491Ssam 250,251,252,253,254,255};
47*14491Ssam # endif
48*14491Ssam int ZCH = NCH;
49*14491Ssam FILE *fout = NULL, *errorf = {stdout};
50*14491Ssam int sect = DEFSECTION;
51*14491Ssam int prev = '\n';	/* previous input character */
52*14491Ssam int pres = '\n';	/* present input character */
53*14491Ssam int peek = '\n';	/* next input character */
54*14491Ssam char *pushptr = pushc;
55*14491Ssam char *slptr = slist;
56*14491Ssam 
57*14491Ssam # if (unix || ibm)
58*14491Ssam char *cname = "/usr/lib/lex/ncform";
59*14491Ssam char *ratname = "/usr/lib/lex/nrform";
60*14491Ssam # endif
61*14491Ssam 
62*14491Ssam # ifdef gcos
63*14491Ssam char *cname = "pounce/lexcform";
64*14491Ssam char *ratname = "pounce/lexrform";
65*14491Ssam # endif
66*14491Ssam int ccount = 1;
67*14491Ssam int casecount = 1;
68*14491Ssam int aptr = 1;
69*14491Ssam int nstates = NSTATES, maxpos = MAXPOS;
70*14491Ssam int treesize = TREESIZE, ntrans = NTRANS;
71*14491Ssam int yytop;
72*14491Ssam int outsize = NOUTPUT;
73*14491Ssam int sptr = 1;
74*14491Ssam int optim = TRUE;
75*14491Ssam int report = 2;
76*14491Ssam int debug;		/* 1 = on */
77*14491Ssam int charc;
78*14491Ssam int sargc;
79*14491Ssam char **sargv;
80*14491Ssam char buf[520];
81*14491Ssam int ratfor;		/* 1 = ratfor, 0 = C */
82*14491Ssam int yyline;		/* line number of file */
83*14491Ssam int eof;
84*14491Ssam int lgatflg;
85*14491Ssam int divflg;
86*14491Ssam int funcflag;
87*14491Ssam int pflag;
88*14491Ssam int chset;	/* 1 = char set modified */
89*14491Ssam FILE *fin, *fother;
90*14491Ssam int fptr;
91*14491Ssam int *name;
92*14491Ssam int *left;
93*14491Ssam int *right;
94*14491Ssam int *parent;
95*14491Ssam char *nullstr;
96*14491Ssam int tptr;
97*14491Ssam char pushc[TOKENSIZE];
98*14491Ssam char slist[STARTSIZE];
99*14491Ssam char **def, **subs, *dchar;
100*14491Ssam char **sname, *schar;
101*14491Ssam char *ccl;
102*14491Ssam char *ccptr;
103*14491Ssam char *dp, *sp;
104*14491Ssam int dptr;
105*14491Ssam char *bptr;		/* store input position */
106*14491Ssam char *tmpstat;
107*14491Ssam int count;
108*14491Ssam int **foll;
109*14491Ssam int *nxtpos;
110*14491Ssam int *positions;
111*14491Ssam int *gotof;
112*14491Ssam int *nexts;
113*14491Ssam char *nchar;
114*14491Ssam int **state;
115*14491Ssam int *sfall;		/* fallback state num */
116*14491Ssam char *cpackflg;		/* true if state has been character packed */
117*14491Ssam int *atable;
118*14491Ssam int nptr;
119*14491Ssam char symbol[NCH];
120*14491Ssam char cindex[NCH];
121*14491Ssam int xstate;
122*14491Ssam int stnum;
123*14491Ssam char match[NCH];
124*14491Ssam char extra[NACTIONS];
125*14491Ssam char *pchar, *pcptr;
126*14491Ssam int pchlen = TOKENSIZE;
127*14491Ssam  long rcount;
128*14491Ssam int *verify, *advance, *stoff;
129*14491Ssam int scon;
130*14491Ssam char *psave;
131*14491Ssam int buserr(), segviol();
132