xref: /illumos-gate/usr/src/cmd/sgs/lex/common/once.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
26*7c478bd9Sstevel@tonic-gate  */
27*7c478bd9Sstevel@tonic-gate 
28*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
29*7c478bd9Sstevel@tonic-gate /*	All Rights Reserved	*/
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate #include "ldefs.c"
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate /* once.c */
36*7c478bd9Sstevel@tonic-gate 	/* because of external definitions, this code should occur only once */
37*7c478bd9Sstevel@tonic-gate int	ctable[2*NCH] = {
38*7c478bd9Sstevel@tonic-gate 	0,   1,   2,   3,   4,   5,   6,   7,   8,   9,
39*7c478bd9Sstevel@tonic-gate 	10,  11,  12,  13,  14,  15,  16,  17,  18,  19,
40*7c478bd9Sstevel@tonic-gate 	20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
41*7c478bd9Sstevel@tonic-gate 	30,  31,  32,  33,  34,  35,  36,  37,  38,  39,
42*7c478bd9Sstevel@tonic-gate 	40,  41,  42,  43,  44,  45,  46,  47,  48,  49,
43*7c478bd9Sstevel@tonic-gate 	50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
44*7c478bd9Sstevel@tonic-gate 	60,  61,  62,  63,  64,  65,  66,  67,  68,  69,
45*7c478bd9Sstevel@tonic-gate 	70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
46*7c478bd9Sstevel@tonic-gate 	80,  81,  82,  83,  84,  85,  86,  87,  88,  89,
47*7c478bd9Sstevel@tonic-gate 	90,  91,  92,  93,  94,  95,  96,  97,  98,  99,
48*7c478bd9Sstevel@tonic-gate 	100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
49*7c478bd9Sstevel@tonic-gate 	110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
50*7c478bd9Sstevel@tonic-gate 	120, 121, 122, 123, 124, 125, 126, 127, 128, 129,
51*7c478bd9Sstevel@tonic-gate 	130, 131, 132, 133, 134, 135, 136, 137, 138, 139,
52*7c478bd9Sstevel@tonic-gate 	140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
53*7c478bd9Sstevel@tonic-gate 	150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
54*7c478bd9Sstevel@tonic-gate 	160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
55*7c478bd9Sstevel@tonic-gate 	170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
56*7c478bd9Sstevel@tonic-gate 	180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
57*7c478bd9Sstevel@tonic-gate 	190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
58*7c478bd9Sstevel@tonic-gate 	200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
59*7c478bd9Sstevel@tonic-gate 	210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
60*7c478bd9Sstevel@tonic-gate 	220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
61*7c478bd9Sstevel@tonic-gate 	230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
62*7c478bd9Sstevel@tonic-gate 	240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
63*7c478bd9Sstevel@tonic-gate 	250, 251, 252, 253, 254, 255
64*7c478bd9Sstevel@tonic-gate };
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate int	ZCH = NCH;
67*7c478bd9Sstevel@tonic-gate FILE	*fout = NULL, *errorf = {stderr};
68*7c478bd9Sstevel@tonic-gate int	sect = DEFSECTION;
69*7c478bd9Sstevel@tonic-gate int	prev = '\n';	/* previous input character */
70*7c478bd9Sstevel@tonic-gate int	pres = '\n';	/* present input character */
71*7c478bd9Sstevel@tonic-gate int	peek = '\n';	/* next input character */
72*7c478bd9Sstevel@tonic-gate CHR	*pushptr = pushc;
73*7c478bd9Sstevel@tonic-gate CHR	*slptr = slist;
74*7c478bd9Sstevel@tonic-gate 
75*7c478bd9Sstevel@tonic-gate #ifndef CNAME
76*7c478bd9Sstevel@tonic-gate #define	CNAME "./ncform"
77*7c478bd9Sstevel@tonic-gate #endif
78*7c478bd9Sstevel@tonic-gate #ifndef RATNAME
79*7c478bd9Sstevel@tonic-gate #define	RATNAME "./nrform"
80*7c478bd9Sstevel@tonic-gate #endif
81*7c478bd9Sstevel@tonic-gate char	*cname = CNAME;
82*7c478bd9Sstevel@tonic-gate char	*ratname = RATNAME;
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate int ccount = 1;
85*7c478bd9Sstevel@tonic-gate int casecount = 1;
86*7c478bd9Sstevel@tonic-gate int aptr = 1;
87*7c478bd9Sstevel@tonic-gate int nstates = NSTATES, maxpos = MAXPOS;
88*7c478bd9Sstevel@tonic-gate int treesize = TREESIZE, ntrans = NTRANS;
89*7c478bd9Sstevel@tonic-gate int yytop;
90*7c478bd9Sstevel@tonic-gate int outsize = NOUTPUT;
91*7c478bd9Sstevel@tonic-gate int sptr = 1;
92*7c478bd9Sstevel@tonic-gate int optim = TRUE;
93*7c478bd9Sstevel@tonic-gate int report = 2;
94*7c478bd9Sstevel@tonic-gate int debug;		/* 1 = on */
95*7c478bd9Sstevel@tonic-gate int charc;
96*7c478bd9Sstevel@tonic-gate char *v_stmp = "n";
97*7c478bd9Sstevel@tonic-gate int no_input;
98*7c478bd9Sstevel@tonic-gate int copy_line;
99*7c478bd9Sstevel@tonic-gate int n_error = 0;
100*7c478bd9Sstevel@tonic-gate int fatal = 1;
101*7c478bd9Sstevel@tonic-gate int sargc;
102*7c478bd9Sstevel@tonic-gate char **sargv;
103*7c478bd9Sstevel@tonic-gate CHR buf[BUF_SIZ];
104*7c478bd9Sstevel@tonic-gate int ratfor;		/* 1 = ratfor, 0 = C */
105*7c478bd9Sstevel@tonic-gate int yyline;		/* line number of file */
106*7c478bd9Sstevel@tonic-gate int eof;
107*7c478bd9Sstevel@tonic-gate int lgatflg;
108*7c478bd9Sstevel@tonic-gate int divflg;
109*7c478bd9Sstevel@tonic-gate int funcflag;
110*7c478bd9Sstevel@tonic-gate int pflag;
111*7c478bd9Sstevel@tonic-gate int chset;	/* 1 = char set modified */
112*7c478bd9Sstevel@tonic-gate FILE *fin, *fother;
113*7c478bd9Sstevel@tonic-gate int fptr;
114*7c478bd9Sstevel@tonic-gate int *name;
115*7c478bd9Sstevel@tonic-gate int *left;
116*7c478bd9Sstevel@tonic-gate int *right;
117*7c478bd9Sstevel@tonic-gate int *parent;
118*7c478bd9Sstevel@tonic-gate Boolean *nullstr;
119*7c478bd9Sstevel@tonic-gate int tptr;
120*7c478bd9Sstevel@tonic-gate CHR pushc[TOKENSIZE];
121*7c478bd9Sstevel@tonic-gate CHR slist[STARTSIZE];
122*7c478bd9Sstevel@tonic-gate CHR **def, **subs, *dchar;
123*7c478bd9Sstevel@tonic-gate /* XCU4: %x exclusive start */
124*7c478bd9Sstevel@tonic-gate int *exclusive;
125*7c478bd9Sstevel@tonic-gate CHR **sname, *schar;
126*7c478bd9Sstevel@tonic-gate CHR *ccl;
127*7c478bd9Sstevel@tonic-gate CHR *ccptr;
128*7c478bd9Sstevel@tonic-gate CHR *dp, *sp;
129*7c478bd9Sstevel@tonic-gate int dptr;
130*7c478bd9Sstevel@tonic-gate CHR *bptr;		/* store input position */
131*7c478bd9Sstevel@tonic-gate CHR *tmpstat;
132*7c478bd9Sstevel@tonic-gate int count;
133*7c478bd9Sstevel@tonic-gate int **foll;
134*7c478bd9Sstevel@tonic-gate int *nxtpos;
135*7c478bd9Sstevel@tonic-gate int *positions;
136*7c478bd9Sstevel@tonic-gate int *gotof;
137*7c478bd9Sstevel@tonic-gate int *nexts;
138*7c478bd9Sstevel@tonic-gate CHR *nchar;
139*7c478bd9Sstevel@tonic-gate int **state;
140*7c478bd9Sstevel@tonic-gate int *sfall;		/* fallback state num */
141*7c478bd9Sstevel@tonic-gate Boolean *cpackflg;		/* true if state has been character packed */
142*7c478bd9Sstevel@tonic-gate int *atable;
143*7c478bd9Sstevel@tonic-gate int nptr;
144*7c478bd9Sstevel@tonic-gate Boolean symbol[MAXNCG];
145*7c478bd9Sstevel@tonic-gate CHR cindex[MAXNCG];
146*7c478bd9Sstevel@tonic-gate int xstate;
147*7c478bd9Sstevel@tonic-gate int stnum;
148*7c478bd9Sstevel@tonic-gate CHR match[MAXNCG];
149*7c478bd9Sstevel@tonic-gate BYTE extra[NACTIONS];
150*7c478bd9Sstevel@tonic-gate CHR *pchar, *pcptr;
151*7c478bd9Sstevel@tonic-gate int pchlen = TOKENSIZE;
152*7c478bd9Sstevel@tonic-gate long rcount;
153*7c478bd9Sstevel@tonic-gate int *verify, *advance, *stoff;
154*7c478bd9Sstevel@tonic-gate int scon;
155*7c478bd9Sstevel@tonic-gate CHR *psave;
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate Boolean handleeuc = FALSE;
158*7c478bd9Sstevel@tonic-gate Boolean widecio = FALSE;
159*7c478bd9Sstevel@tonic-gate 
160*7c478bd9Sstevel@tonic-gate int	isArray = 1;	/* XCU4: for %array %pointer */
161