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