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