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