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
139extern int ncgidtbl;
140extern int ncg; /* ncg == ncgidtbl * 2 */
141typedef unsigned long lchar;
142extern lchar yycgidtbl[];
143extern int yycgid(wchar_t);
144extern Boolean handleeuc; /* TRUE iff -w or -e option is specified. */
145extern 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
156extern int yydebug;
157extern int debug;		/* 1 = on */
158extern int charc;
159#endif
160
161#ifndef DEBUG
162#define	freturn(s) s
163#endif
164
165
166extern int optind;
167extern int no_input;
168extern int sargc;
169extern char **sargv;
170extern char *v_stmp;
171extern char *release_string;
172extern CHR buf[];
173extern int ratfor;		/* 1 = ratfor, 0 = C */
174extern int fatal;
175extern int n_error;
176extern int copy_line;
177extern int yyline;		/* line number of file */
178extern int sect;
179extern int eof;
180extern int lgatflg;
181extern int divflg;
182extern int funcflag;
183extern int pflag;
184extern int casecount;
185extern int chset;	/* 1 = CHR set modified */
186extern FILE *fin, *fout, *fother, *errorf;
187extern int fptr;
188extern int prev;	/* previous input character */
189extern int pres;	/* present input character */
190extern int peek;	/* next input character */
191extern int *name;
192extern int *left;
193extern int *right;
194extern int *parent;
195extern Boolean *nullstr;
196extern int tptr;
197extern CHR pushc[TOKENSIZE];
198extern CHR *pushptr;
199extern CHR slist[STARTSIZE];
200extern CHR *slptr;
201extern CHR **def, **subs, *dchar;
202extern CHR **sname, *schar;
203/* XCU4: %x exclusive start */
204extern int *exclusive;
205extern CHR *ccl;
206extern CHR *ccptr;
207extern CHR *dp, *sp;
208extern int dptr, sptr;
209extern CHR *bptr;		/* store input position */
210extern CHR *tmpstat;
211extern int count;
212extern int **foll;
213extern int *nxtpos;
214extern int *positions;
215extern int *gotof;
216extern int *nexts;
217extern CHR *nchar;
218extern int **state;
219extern int *sfall;		/* fallback state num */
220extern Boolean *cpackflg;	/* true if state has been character packed */
221extern int *atable, aptr;
222extern int nptr;
223extern Boolean symbol[MAXNCG];
224extern CHR cindex[MAXNCG];
225extern int xstate;
226extern int stnum;
227extern int ctable[];
228extern int ZCH;
229extern int ccount;
230extern CHR match[MAXNCG];
231extern BYTE extra[];
232extern CHR *pcptr, *pchar;
233extern int pchlen;
234extern int nstates, maxpos;
235extern int yytop;
236extern int report;
237extern int ntrans, treesize, outsize;
238extern long rcount;
239extern int optim;
240extern int *verify, *advance, *stoff;
241extern int scon;
242extern CHR *psave;
243extern CHR *getl();
244extern BYTE *myalloc();
245
246void phead1(void);
247void phead2(void);
248void ptail(void);
249void statistics(void);
250void error_tail(void) __NORETURN;
251void error(char *, ...);
252void warning(char *, ...);
253void lgate(void);
254void scopy(CHR *s, CHR *t);
255void cclinter(int sw);
256void cpycom(CHR *p);
257void munput(int t, CHR *p);
258void cfoll(int v);
259void cgoto(void);
260void mkmatch(void);
261void layout(void);
262void remch(wchar_t c);
263void sortcgidtbl(void);
264void repbycgid(void);
265int gch(void);
266int slength(CHR *s);
267int yyparse(void);
268int scomp(CHR *x, CHR *y);
269int space(int ch);
270int siconv(CHR *t);
271int digit(int c);
272int ctrans(CHR **ss);
273int cpyact(void);
274int lookup(CHR *s, CHR **t);
275int usescape(int c);
276int alpha(int c);
277int mn2(int a, int d, int c);
278int mn1(int a, int d);
279int mn0(int a);
280int dupl(int n);
281
282extern int isArray;		/* XCU4: for %array %pointer */
283
284#endif	/* _LDEFS_H */
285