xref: /titanic_52/usr/src/cmd/sgs/lex/common/ldefs.h (revision 672986541be54a7a471bb088e60780c37e371d7e)
1*67298654Sdamico /*
2*67298654Sdamico  * CDDL HEADER START
3*67298654Sdamico  *
4*67298654Sdamico  * The contents of this file are subject to the terms of the
5*67298654Sdamico  * Common Development and Distribution License (the "License").
6*67298654Sdamico  * You may not use this file except in compliance with the License.
7*67298654Sdamico  *
8*67298654Sdamico  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*67298654Sdamico  * or http://www.opensolaris.org/os/licensing.
10*67298654Sdamico  * See the License for the specific language governing permissions
11*67298654Sdamico  * and limitations under the License.
12*67298654Sdamico  *
13*67298654Sdamico  * When distributing Covered Code, include this CDDL HEADER in each
14*67298654Sdamico  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*67298654Sdamico  * If applicable, add the following below this CDDL HEADER, with the
16*67298654Sdamico  * fields enclosed by brackets "[]" replaced with your own identifying
17*67298654Sdamico  * information: Portions Copyright [yyyy] [name of copyright owner]
18*67298654Sdamico  *
19*67298654Sdamico  * CDDL HEADER END
20*67298654Sdamico  */
21*67298654Sdamico /*
22*67298654Sdamico  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*67298654Sdamico  * Use is subject to license terms.
24*67298654Sdamico  */
25*67298654Sdamico 
26*67298654Sdamico /*	Copyright (c) 1988 AT&T	*/
27*67298654Sdamico /*	All Rights Reserved	*/
28*67298654Sdamico 
29*67298654Sdamico #ifndef	_LDEFS_H
30*67298654Sdamico #define	_LDEFS_H
31*67298654Sdamico 
32*67298654Sdamico #pragma ident	"%Z%%M%	%I%	%E% SMI"
33*67298654Sdamico 
34*67298654Sdamico #include <stdio.h>
35*67298654Sdamico #include <stdlib.h>
36*67298654Sdamico 
37*67298654Sdamico #include <widec.h>
38*67298654Sdamico #include <wctype.h>
39*67298654Sdamico #include "sgs.h"
40*67298654Sdamico 
41*67298654Sdamico #define	CHR wchar_t
42*67298654Sdamico #define	BYTE char
43*67298654Sdamico #define	Boolean char
44*67298654Sdamico #define	LONG_WCHAR_T 1
45*67298654Sdamico 
46*67298654Sdamico #define	PP 1
47*67298654Sdamico #ifdef u370
48*67298654Sdamico #define	CWIDTH 8
49*67298654Sdamico #define	CMASK 0377
50*67298654Sdamico #define	ASCII 1
51*67298654Sdamico #else
52*67298654Sdamico 
53*67298654Sdamico #ifdef unix
54*67298654Sdamico #define	CWIDTH 7
55*67298654Sdamico #define	CMASK 0177
56*67298654Sdamico #define	ASCII 1
57*67298654Sdamico #endif
58*67298654Sdamico 
59*67298654Sdamico #ifdef gcos
60*67298654Sdamico #define	CWIDTH 9
61*67298654Sdamico #define	CMASK 0777
62*67298654Sdamico #define	ASCII 1
63*67298654Sdamico #endif
64*67298654Sdamico 
65*67298654Sdamico #ifdef ibm
66*67298654Sdamico #define	CWIDTH 8
67*67298654Sdamico #define	CMASK 0377
68*67298654Sdamico #define	EBCDIC 1
69*67298654Sdamico #endif
70*67298654Sdamico #endif
71*67298654Sdamico 
72*67298654Sdamico #define	NCH 256
73*67298654Sdamico #define	TOKENSIZE 10000
74*67298654Sdamico #define	DEFSIZE 1000
75*67298654Sdamico #define	DEFCHAR 2000
76*67298654Sdamico #define	BUF_SIZ 2000
77*67298654Sdamico #define	STARTCHAR 2560
78*67298654Sdamico #define	STARTSIZE 256
79*67298654Sdamico #define	CCLSIZE 20000
80*67298654Sdamico 
81*67298654Sdamico 
82*67298654Sdamico #ifdef SMALL
83*67298654Sdamico #define	TREESIZE 600
84*67298654Sdamico #define	NTRANS 1500
85*67298654Sdamico #define	NSTATES 300
86*67298654Sdamico #define	MAXPOS 1500
87*67298654Sdamico #define	MAXPOSSTATE 500
88*67298654Sdamico #define	NOUTPUT 1500
89*67298654Sdamico #endif
90*67298654Sdamico 
91*67298654Sdamico #ifndef SMALL
92*67298654Sdamico #define	TREESIZE 1000
93*67298654Sdamico #define	NSTATES 500
94*67298654Sdamico #define	MAXPOS 2500
95*67298654Sdamico #define	MAXPOSSTATE 4*1000
96*67298654Sdamico #define	NTRANS 2000
97*67298654Sdamico #define	NOUTPUT 4*3000
98*67298654Sdamico #endif
99*67298654Sdamico #define	NACTIONS 4*1000
100*67298654Sdamico #define	ALITTLEEXTRA 300
101*67298654Sdamico 
102*67298654Sdamico #define	RCCL		0x4000
103*67298654Sdamico #define	RNCCL		0x4001
104*67298654Sdamico #define	RSTR		0x4002
105*67298654Sdamico #define	RSCON		0x4003
106*67298654Sdamico /* XCU4: add RXSCON */
107*67298654Sdamico #define	RXSCON		0x4011
108*67298654Sdamico #define	RNEWE		0x4004
109*67298654Sdamico #define	FINAL		0x4005
110*67298654Sdamico #define	RNULLS		0x4006
111*67298654Sdamico #define	RCAT		0x4007
112*67298654Sdamico #define	STAR		0x4008
113*67298654Sdamico #define	PLUS		0x4009
114*67298654Sdamico #define	QUEST		0x400a
115*67298654Sdamico #define	DIV		0x400b
116*67298654Sdamico #define	BAR		0x400c
117*67298654Sdamico #define	CARAT		0x400d
118*67298654Sdamico #define	S1FINAL		0x400e
119*67298654Sdamico #define	S2FINAL		0x400f
120*67298654Sdamico #define	DOT		0x4010
121*67298654Sdamico #define	ISOPERATOR(n)	((n & 0xc080) == 0x4000)
122*67298654Sdamico 
123*67298654Sdamico /*
124*67298654Sdamico  * New to JLE; this is not really a node tag.
125*67298654Sdamico  * This is used in a string pointed to by
126*67298654Sdamico  * the leaf of an RCCL or RNCCL node as a
127*67298654Sdamico  * special prefix code that substitutes
128*67298654Sdamico  * the infix '-' range operator.  For
129*67298654Sdamico  * example, a lex character class "[_0-9a-zA-Z]"
130*67298654Sdamico  * would be translated to the intermidiate
131*67298654Sdamico  * form:
132*67298654Sdamico  *   	RCCL
133*67298654Sdamico  *	 |
134*67298654Sdamico  *	 |
135*67298654Sdamico  *	 v
136*67298654Sdamico  *       "_<RANGE>09<RANGE>a-z<RANGE>A-Z"
137*67298654Sdamico  */
138*67298654Sdamico #define	RANGE		0x40ff
139*67298654Sdamico 
140*67298654Sdamico #define	MAXNCG 1000
141*67298654Sdamico extern int ncgidtbl;
142*67298654Sdamico extern int ncg; /* ncg == ncgidtbl * 2 */
143*67298654Sdamico typedef unsigned long lchar;
144*67298654Sdamico extern lchar yycgidtbl[];
145*67298654Sdamico extern int yycgid(wchar_t);
146*67298654Sdamico extern Boolean handleeuc; /* TRUE iff -w or -e option is specified. */
147*67298654Sdamico extern Boolean widecio; /* TRUE iff -w option is specified. */
148*67298654Sdamico 
149*67298654Sdamico #define	DEFSECTION 1
150*67298654Sdamico #define	RULESECTION 2
151*67298654Sdamico #define	ENDSECTION 5
152*67298654Sdamico 
153*67298654Sdamico #define	PC 1
154*67298654Sdamico #define	PS 1
155*67298654Sdamico 
156*67298654Sdamico #ifdef DEBUG
157*67298654Sdamico #define	LINESIZE 110
158*67298654Sdamico extern int yydebug;
159*67298654Sdamico extern int debug;		/* 1 = on */
160*67298654Sdamico extern int charc;
161*67298654Sdamico #endif
162*67298654Sdamico 
163*67298654Sdamico #ifndef DEBUG
164*67298654Sdamico #define	freturn(s) s
165*67298654Sdamico #endif
166*67298654Sdamico 
167*67298654Sdamico 
168*67298654Sdamico extern int optind;
169*67298654Sdamico extern int no_input;
170*67298654Sdamico extern int sargc;
171*67298654Sdamico extern char **sargv;
172*67298654Sdamico extern char *v_stmp;
173*67298654Sdamico extern char *release_string;
174*67298654Sdamico extern CHR buf[];
175*67298654Sdamico extern int ratfor;		/* 1 = ratfor, 0 = C */
176*67298654Sdamico extern int fatal;
177*67298654Sdamico extern int n_error;
178*67298654Sdamico extern int copy_line;
179*67298654Sdamico extern int yyline;		/* line number of file */
180*67298654Sdamico extern int sect;
181*67298654Sdamico extern int eof;
182*67298654Sdamico extern int lgatflg;
183*67298654Sdamico extern int divflg;
184*67298654Sdamico extern int funcflag;
185*67298654Sdamico extern int pflag;
186*67298654Sdamico extern int casecount;
187*67298654Sdamico extern int chset;	/* 1 = CHR set modified */
188*67298654Sdamico extern FILE *fin, *fout, *fother, *errorf;
189*67298654Sdamico extern int fptr;
190*67298654Sdamico extern int prev;	/* previous input character */
191*67298654Sdamico extern int pres;	/* present input character */
192*67298654Sdamico extern int peek;	/* next input character */
193*67298654Sdamico extern int *name;
194*67298654Sdamico extern int *left;
195*67298654Sdamico extern int *right;
196*67298654Sdamico extern int *parent;
197*67298654Sdamico extern Boolean *nullstr;
198*67298654Sdamico extern int tptr;
199*67298654Sdamico extern CHR pushc[TOKENSIZE];
200*67298654Sdamico extern CHR *pushptr;
201*67298654Sdamico extern CHR slist[STARTSIZE];
202*67298654Sdamico extern CHR *slptr;
203*67298654Sdamico extern CHR **def, **subs, *dchar;
204*67298654Sdamico extern CHR **sname, *schar;
205*67298654Sdamico /* XCU4: %x exclusive start */
206*67298654Sdamico extern int *exclusive;
207*67298654Sdamico extern CHR *ccl;
208*67298654Sdamico extern CHR *ccptr;
209*67298654Sdamico extern CHR *dp, *sp;
210*67298654Sdamico extern int dptr, sptr;
211*67298654Sdamico extern CHR *bptr;		/* store input position */
212*67298654Sdamico extern CHR *tmpstat;
213*67298654Sdamico extern int count;
214*67298654Sdamico extern int **foll;
215*67298654Sdamico extern int *nxtpos;
216*67298654Sdamico extern int *positions;
217*67298654Sdamico extern int *gotof;
218*67298654Sdamico extern int *nexts;
219*67298654Sdamico extern CHR *nchar;
220*67298654Sdamico extern int **state;
221*67298654Sdamico extern int *sfall;		/* fallback state num */
222*67298654Sdamico extern Boolean *cpackflg;	/* true if state has been character packed */
223*67298654Sdamico extern int *atable, aptr;
224*67298654Sdamico extern int nptr;
225*67298654Sdamico extern Boolean symbol[MAXNCG];
226*67298654Sdamico extern CHR cindex[MAXNCG];
227*67298654Sdamico extern int xstate;
228*67298654Sdamico extern int stnum;
229*67298654Sdamico extern int ctable[];
230*67298654Sdamico extern int ZCH;
231*67298654Sdamico extern int ccount;
232*67298654Sdamico extern CHR match[MAXNCG];
233*67298654Sdamico extern BYTE extra[];
234*67298654Sdamico extern CHR *pcptr, *pchar;
235*67298654Sdamico extern int pchlen;
236*67298654Sdamico extern int nstates, maxpos;
237*67298654Sdamico extern int yytop;
238*67298654Sdamico extern int report;
239*67298654Sdamico extern int ntrans, treesize, outsize;
240*67298654Sdamico extern long rcount;
241*67298654Sdamico extern int optim;
242*67298654Sdamico extern int *verify, *advance, *stoff;
243*67298654Sdamico extern int scon;
244*67298654Sdamico extern CHR *psave;
245*67298654Sdamico extern CHR *getl();
246*67298654Sdamico extern BYTE *myalloc();
247*67298654Sdamico 
248*67298654Sdamico void phead1(void);
249*67298654Sdamico void phead2(void);
250*67298654Sdamico void ptail(void);
251*67298654Sdamico void statistics(void);
252*67298654Sdamico void error_tail(void) __NORETURN;
253*67298654Sdamico void error();
254*67298654Sdamico void warning();
255*67298654Sdamico void lgate(void);
256*67298654Sdamico void scopy(CHR *s, CHR *t);
257*67298654Sdamico void cclinter(int sw);
258*67298654Sdamico void cpycom(CHR *p);
259*67298654Sdamico void munput(int t, CHR *p);
260*67298654Sdamico void cfoll(int v);
261*67298654Sdamico void cgoto(void);
262*67298654Sdamico void mkmatch(void);
263*67298654Sdamico void layout(void);
264*67298654Sdamico void remch(wchar_t c);
265*67298654Sdamico void sortcgidtbl(void);
266*67298654Sdamico void repbycgid(void);
267*67298654Sdamico int gch(void);
268*67298654Sdamico int slength(CHR *s);
269*67298654Sdamico int yyparse(void);
270*67298654Sdamico int scomp(CHR *x, CHR *y);
271*67298654Sdamico int space(int ch);
272*67298654Sdamico int siconv(CHR *t);
273*67298654Sdamico int digit(int c);
274*67298654Sdamico int ctrans(CHR **ss);
275*67298654Sdamico int cpyact(void);
276*67298654Sdamico int lookup(CHR *s, CHR **t);
277*67298654Sdamico int usescape(int c);
278*67298654Sdamico int alpha(int c);
279*67298654Sdamico int mn2(int a, int d, int c);
280*67298654Sdamico int mn1(int a, int d);
281*67298654Sdamico int mn0(int a);
282*67298654Sdamico int dupl(int n);
283*67298654Sdamico 
284*67298654Sdamico extern int isArray;		/* XCU4: for %array %pointer */
285*67298654Sdamico 
286*67298654Sdamico #endif	/* _LDEFS_H */
287