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]
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 */
32 #pragma ident "%Z%%M% %I% %E% SMI"
50 /* MANIFEST CONSTANT DEFINITIONS */
51 #if u3b || u3b15 || u3b2 || vax || uts || sparc
56 /* base of nonterminal internal numbers */
58 #define NTBASE (10000000)
60 /* internal codes for error and accept actions */
63 #define ACCEPTCODE 8191
65 /* sizes and limits */
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)
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)
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 */
123 #define MUSTLOOKAHEAD 2
125 /* flags for a rule having an action, and being reduced */
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)
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
{
172 typedef struct item
{
177 typedef struct toksymb
{
182 typedef struct mbclit
{
184 int tvalue
; /* token issued for the character */
187 typedef struct ntsymb
{
192 typedef struct wset
{
198 /* token information */
200 extern int ntokens
; /* number of tokens */
201 extern TOKSYMB
*tokset
;
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 */
235 /* lookahead set information */
238 extern LOOKSETS
*lkst
;
239 extern int nolook
; /* flag to turn off lookahead computations */
241 /* working set information */
245 /* storage for productions */
249 extern int *tracemem
;
250 extern int new_memsize
;
252 /* storage for action table */
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 */
262 extern int lineno
; /* current line number */
264 /* statistics collection variables */
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 */
304 /* default settings for a number of macros */
306 /* name of yacc tempfiles */
309 #define TEMPNAME "yacc.tmp"
313 #define ACTNAME "yacc.acts"
317 #define DEBUGNAME "yacc.debug"
320 /* command to clobber tempfiles after use */
323 #define ZAPFILE(x) (void)unlink(x)
327 #define PARSER "/usr/share/lib/ccs/yaccpar"
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
338 * When lint is able to handle %ws, it would be appropriate
339 * to come back through and remove the use of this macro.
342 static const char *lint_ws_fmt
= "";
343 #define WSFMT(_fmt) lint_ws_fmt
345 #define WSFMT(_fmt) _fmt
352 #endif /* _DEXTERN_H */