8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / sgs / yacc / common / dextern.h
blobe90aa60468b2f69513f09ab4aeaa2423da58ca52
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 /* Copyright (c) 1988 AT&T */
27 /* All Rights Reserved */
29 #ifndef _DEXTERN_H
30 #define _DEXTERN_H
32 #pragma ident "%Z%%M% %I% %E% SMI"
34 #include <stdio.h>
35 #include <inttypes.h>
36 #include <ctype.h>
37 #include <memory.h>
38 #include <string.h>
39 #include <malloc.h>
40 #include <values.h>
41 #include <widec.h>
42 #include <unistd.h>
43 #include <stdlib.h>
44 #include <wctype.h>
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
50 /* MANIFEST CONSTANT DEFINITIONS */
51 #if u3b || u3b15 || u3b2 || vax || uts || sparc
52 #define WORD32
53 #endif
54 #include <libintl.h>
56 /* base of nonterminal internal numbers */
58 #define NTBASE (10000000)
60 /* internal codes for error and accept actions */
62 #define ERRCODE 8190
63 #define ACCEPTCODE 8191
65 /* sizes and limits */
67 #define ACTSIZE 4000
68 #define MEMSIZE 2000
69 #define PSTSIZE 1024
70 #define NSTATES 1000
71 #define NTERMS 127
72 #define NPROD 300
73 #define NNONTERM 600
74 #define TEMPSIZE 800
75 #define CNAMSZ 1000
76 #define LSETSIZE 950
77 #define WSETSIZE 850
79 #define NAMESIZE 50
80 #define NTYPES 1000
82 #define NMBCHARSZ 100
83 #define LKFACTOR 5
85 #ifdef WORD32
86 /* bit packing macros (may be machine dependent) */
87 #define BIT(a, i) ((a)[(i)>>5] & (1<<((i)&037)))
88 #define SETBIT(a, i) ((a)[(i)>>5] |= (1<<((i)&037)))
90 /* number of words needed to hold n+1 bits */
91 #define NWORDS(n) (((n)+32)/32)
93 #else
95 /* bit packing macros (may be machine dependent) */
96 #define BIT(a, i) ((a)[(i)>>4] & (1<<((i)&017)))
97 #define SETBIT(a, i) ((a)[(i)>>4] |= (1<<((i)&017)))
99 /* number of words needed to hold n+1 bits */
100 #define NWORDS(n) (((n)+16)/16)
101 #endif
104 * relationships which must hold:
105 * TBITSET ints must hold NTERMS+1 bits...
106 * WSETSIZE >= NNONTERM
107 * LSETSIZE >= NNONTERM
108 * TEMPSIZE >= NTERMS + NNONTERMs + 1
109 * TEMPSIZE >= NSTATES
112 /* associativities */
114 #define NOASC 0 /* no assoc. */
115 #define LASC 1 /* left assoc. */
116 #define RASC 2 /* right assoc. */
117 #define BASC 3 /* binary assoc. */
119 /* flags for state generation */
121 #define DONE 0
122 #define MUSTDO 1
123 #define MUSTLOOKAHEAD 2
125 /* flags for a rule having an action, and being reduced */
127 #define ACTFLAG 04
128 #define REDFLAG 010
130 /* output parser flags */
131 #define YYFLAG1 (-10000000)
133 /* macros for getting associativity and precedence levels */
135 #define ASSOC(i) ((i)&07)
136 #define PLEVEL(i) (((i)>>4)&077)
137 #define TYPE(i) ((i>>10)&077)
139 /* macros for setting associativity and precedence levels */
141 #define SETASC(i, j) i |= j
142 #define SETPLEV(i, j) i |= (j<<4)
143 #define SETTYPE(i, j) i |= (j<<10)
145 /* looping macros */
147 #define TLOOP(i) for (i = 1; i <= ntokens; ++i)
148 #define NTLOOP(i) for (i = 0; i <= nnonter; ++i)
149 #define PLOOP(s, i) for (i = s; i < nprod; ++i)
150 #define SLOOP(i) for (i = 0; i < nstate; ++i)
151 #define WSBUMP(x) ++x
152 #define WSLOOP(s, j) for (j = s; j < &wsets[cwp]; ++j)
153 #define ITMLOOP(i, p, q) q = pstate[i+1]; for (p = pstate[i]; p < q; ++p)
154 #define SETLOOP(i) for (i = 0; i < tbitset; ++i)
156 /* I/O descriptors */
158 extern FILE *finput; /* input file */
159 extern FILE *faction; /* file for saving actions */
160 extern FILE *fdefine; /* file for #defines */
161 extern FILE *ftable; /* y.tab.c file */
162 extern FILE *ftemp; /* tempfile to pass 2 */
163 extern FILE *fdebug; /* tempfile for two debugging info arrays */
164 extern FILE *foutput; /* y.output file */
166 /* structure declarations */
168 typedef struct looksets {
169 int *lset;
170 } LOOKSETS;
172 typedef struct item {
173 int *pitem;
174 LOOKSETS *look;
175 } ITEM;
177 typedef struct toksymb {
178 wchar_t *name;
179 int value;
180 } TOKSYMB;
182 typedef struct mbclit {
183 wchar_t character;
184 int tvalue; /* token issued for the character */
185 } MBCLIT;
187 typedef struct ntsymb {
188 wchar_t *name;
189 int tvalue;
190 } NTSYMB;
192 typedef struct wset {
193 int *pitem;
194 int flag;
195 LOOKSETS ws;
196 } WSET;
198 /* token information */
200 extern int ntokens; /* number of tokens */
201 extern TOKSYMB *tokset;
202 extern int ntoksz;
205 * multibyte (c > 255) character literals are
206 * handled as though they were tokens except
207 * that it generates a separate mapping table.
209 extern int nmbchars; /* number of mb literals */
210 extern MBCLIT *mbchars;
211 extern int nmbcharsz;
213 /* nonterminal information */
215 extern int nnonter; /* the number of nonterminals */
216 extern NTSYMB *nontrst;
217 extern int nnontersz;
219 /* grammar rule information */
221 extern int nprod; /* number of productions */
222 extern int **prdptr; /* pointers to descriptions of productions */
223 extern int *levprd; /* contains production levels to break conflicts */
224 extern wchar_t *had_act; /* set if reduction has associated action code */
226 /* state information */
228 extern int nstate; /* number of states */
229 extern ITEM **pstate; /* pointers to the descriptions of the states */
230 extern int *tystate; /* contains type information about the states */
231 extern int *defact; /* the default action of the state */
233 extern int size;
235 /* lookahead set information */
237 extern int TBITSET;
238 extern LOOKSETS *lkst;
239 extern int nolook; /* flag to turn off lookahead computations */
241 /* working set information */
243 extern WSET *wsets;
245 /* storage for productions */
247 extern int *mem0;
248 extern int *mem;
249 extern int *tracemem;
250 extern int new_memsize;
252 /* storage for action table */
254 extern int *amem;
255 extern int *memp; /* next free action table position */
256 extern int *indgo; /* index to the stored goto table */
257 extern int new_actsize;
259 /* temporary vector, indexable by states, terms, or ntokens */
261 extern int *temp1;
262 extern int lineno; /* current line number */
264 /* statistics collection variables */
266 extern int zzgoent;
267 extern int zzgobest;
268 extern int zzacent;
269 extern int zzexcp;
270 extern int zzrrconf;
271 extern int zzsrconf;
273 /* define external functions */
275 extern void setup(int, char *[]);
276 extern void closure(int);
277 extern void output(void);
278 extern void aryfil(int *, int, int);
279 extern void error(char *, ...);
280 extern void warning(int, char *, ...);
281 extern void putitem(int *, LOOKSETS *);
282 extern void go2out(void);
283 extern void hideprod(void);
284 extern void callopt(void);
285 extern void warray(wchar_t *, int *, int);
286 extern wchar_t *symnam(int);
287 extern wchar_t *writem(int *);
288 extern void exp_mem(int);
289 extern void exp_act(int **);
290 extern int apack(int *, int);
291 extern int state(int);
292 extern void fprintf3(FILE *, const char *, const wchar_t *, const char *, ...);
293 extern void error3(const char *, const wchar_t *, const char *, ...);
295 extern wchar_t *wscpy(wchar_t *, const wchar_t *);
296 extern size_t wslen(const wchar_t *);
297 extern int wscmp(const wchar_t *, const wchar_t *);
300 /* yaccpar location */
302 extern char *parser;
304 /* default settings for a number of macros */
306 /* name of yacc tempfiles */
308 #ifndef TEMPNAME
309 #define TEMPNAME "yacc.tmp"
310 #endif
312 #ifndef ACTNAME
313 #define ACTNAME "yacc.acts"
314 #endif
316 #ifndef DEBUGNAME
317 #define DEBUGNAME "yacc.debug"
318 #endif
320 /* command to clobber tempfiles after use */
322 #ifndef ZAPFILE
323 #define ZAPFILE(x) (void)unlink(x)
324 #endif
326 #ifndef PARSER
327 #define PARSER "/usr/share/lib/ccs/yaccpar"
328 #endif
331 * Lint is unable to properly handle formats with wide strings
332 * (e.g. %ws) and misdiagnoses them as being malformed.
333 * This macro is used to work around that, by substituting
334 * a pointer to a null string when compiled by lint. This
335 * trick works because lint is not able to evaluate the
336 * variable.
338 * When lint is able to handle %ws, it would be appropriate
339 * to come back through and remove the use of this macro.
341 #if defined(__lint)
342 static const char *lint_ws_fmt = "";
343 #define WSFMT(_fmt) lint_ws_fmt
344 #else
345 #define WSFMT(_fmt) _fmt
346 #endif
348 #ifdef __cplusplus
350 #endif
352 #endif /* _DEXTERN_H */