dextern.h revision 100:56ddb8295b81
1193323Sed/*
2193323Sed * CDDL HEADER START
3193323Sed *
4193323Sed * The contents of this file are subject to the terms of the
5193323Sed * Common Development and Distribution License, Version 1.0 only
6193323Sed * (the "License").  You may not use this file except in compliance
7193323Sed * with the License.
8193323Sed *
9193323Sed * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10193323Sed * or http://www.opensolaris.org/os/licensing.
11193323Sed * See the License for the specific language governing permissions
12193323Sed * and limitations under the License.
13193323Sed *
14193323Sed * When distributing Covered Code, include this CDDL HEADER in each
15193323Sed * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16193323Sed * If applicable, add the following below this CDDL HEADER, with the
17193323Sed * fields enclosed by brackets "[]" replaced with your own identifying
18193323Sed * information: Portions Copyright [yyyy] [name of copyright owner]
19193323Sed *
20224145Sdim * CDDL HEADER END
21224145Sdim */
22224145Sdim/*
23193323Sed * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24193323Sed * Use is subject to license terms.
25193323Sed */
26193323Sed
27193323Sed/* Copyright (c) 1988 AT&T */
28193323Sed/* All Rights Reserved */
29193323Sed
30193323Sed#ifndef _DEXTERN_H
31221345Sdim#define	_DEXTERN_H
32193323Sed
33193323Sed#pragma ident	"%Z%%M%	%I%	%E% SMI"
34193323Sed
35193323Sed#include <stdio.h>
36193323Sed#include <inttypes.h>
37193323Sed#include <ctype.h>
38193323Sed#include <memory.h>
39198090Srdivacky#include <string.h>
40193323Sed#include <malloc.h>
41193323Sed#include <values.h>
42193323Sed#include <widec.h>
43193323Sed#include <unistd.h>
44193323Sed#include <stdlib.h>
45193323Sed#include <wctype.h>
46193323Sed
47193323Sed#ifdef	__cplusplus
48193323Sedextern "C" {
49193323Sed#endif
50193323Sed
51193323Sed	/*  MANIFEST CONSTANT DEFINITIONS */
52193323Sed#if u3b || u3b15 || u3b2 || vax || uts || sparc
53193323Sed#define	WORD32
54212904Sdim#endif
55212904Sdim#include <libintl.h>
56193323Sed
57193323Sed	/* base of nonterminal internal numbers */
58193323Sed
59193323Sed#define	NTBASE (10000000)
60193323Sed
61199481Srdivacky	/* internal codes for error and accept actions */
62193323Sed
63193323Sed#define	ERRCODE  8190
64193323Sed#define	ACCEPTCODE 8191
65193323Sed
66193323Sed	/* sizes and limits */
67193323Sed
68223017Sdim#define	ACTSIZE 4000
69193323Sed#define	MEMSIZE 2000
70193323Sed#define	PSTSIZE 1024
71193323Sed#define	NSTATES 1000
72193323Sed#define	NTERMS 127
73193323Sed#define	NPROD 300
74#define	NNONTERM 600
75#define	TEMPSIZE 800
76#define	CNAMSZ 1000
77#define	LSETSIZE 950
78#define	WSETSIZE 850
79
80#define	NAMESIZE 50
81#define	NTYPES 1000
82
83#define	NMBCHARSZ 100
84#define	LKFACTOR 5
85
86#ifdef WORD32
87	/* bit packing macros (may be machine dependent) */
88#define	BIT(a, i) ((a)[(i)>>5] & (1<<((i)&037)))
89#define	SETBIT(a, i) ((a)[(i)>>5] |= (1<<((i)&037)))
90
91	/* number of words needed to hold n+1 bits */
92#define	NWORDS(n) (((n)+32)/32)
93
94#else
95
96	/* bit packing macros (may be machine dependent) */
97#define	BIT(a, i) ((a)[(i)>>4] & (1<<((i)&017)))
98#define	SETBIT(a, i) ((a)[(i)>>4] |= (1<<((i)&017)))
99
100	/* number of words needed to hold n+1 bits */
101#define	NWORDS(n) (((n)+16)/16)
102#endif
103
104	/*
105	 * relationships which must hold:
106	 * TBITSET ints must hold NTERMS+1 bits...
107	 * WSETSIZE >= NNONTERM
108	 * LSETSIZE >= NNONTERM
109	 * TEMPSIZE >= NTERMS + NNONTERMs + 1
110	 * TEMPSIZE >= NSTATES
111	 */
112
113	/* associativities */
114
115#define	NOASC 0  /* no assoc. */
116#define	LASC 1  /* left assoc. */
117#define	RASC 2  /* right assoc. */
118#define	BASC 3  /* binary assoc. */
119
120	/* flags for state generation */
121
122#define	DONE 0
123#define	MUSTDO 1
124#define	MUSTLOOKAHEAD 2
125
126	/* flags for a rule having an action, and being reduced */
127
128#define	ACTFLAG 04
129#define	REDFLAG 010
130
131	/* output parser flags */
132#define	YYFLAG1 (-10000000)
133
134	/* macros for getting associativity and precedence levels */
135
136#define	ASSOC(i) ((i)&07)
137#define	PLEVEL(i) (((i)>>4)&077)
138#define	TYPE(i)  ((i>>10)&077)
139
140	/* macros for setting associativity and precedence levels */
141
142#define	SETASC(i, j) i |= j
143#define	SETPLEV(i, j) i |= (j<<4)
144#define	SETTYPE(i, j) i |= (j<<10)
145
146	/* looping macros */
147
148#define	TLOOP(i) for (i = 1; i <= ntokens; ++i)
149#define	NTLOOP(i) for (i = 0; i <= nnonter; ++i)
150#define	PLOOP(s, i) for (i = s; i < nprod; ++i)
151#define	SLOOP(i) for (i = 0; i < nstate; ++i)
152#define	WSBUMP(x) ++x
153#define	WSLOOP(s, j) for (j = s; j < &wsets[cwp]; ++j)
154#define	ITMLOOP(i, p, q) q = pstate[i+1]; for (p = pstate[i]; p < q; ++p)
155#define	SETLOOP(i) for (i = 0; i < tbitset; ++i)
156
157	/* I/O descriptors */
158
159extern FILE *finput;		/* input file */
160extern FILE *faction;		/* file for saving actions */
161extern FILE *fdefine;		/* file for #defines */
162extern FILE *ftable;		/* y.tab.c file */
163extern FILE *ftemp;		/* tempfile to pass 2 */
164extern FILE *fdebug;		/* tempfile for two debugging info arrays */
165extern FILE *foutput;		/* y.output file */
166
167	/* structure declarations */
168
169typedef struct looksets {
170	int *lset;
171} LOOKSETS;
172
173typedef struct item {
174	int *pitem;
175	LOOKSETS *look;
176} ITEM;
177
178typedef struct toksymb {
179	wchar_t *name;
180	int value;
181} TOKSYMB;
182
183typedef struct mbclit {
184	wchar_t character;
185	int tvalue; /* token issued for the character */
186} MBCLIT;
187
188typedef struct ntsymb {
189	wchar_t *name;
190	int tvalue;
191} NTSYMB;
192
193typedef struct wset {
194	int *pitem;
195	int flag;
196	LOOKSETS ws;
197} WSET;
198
199	/* token information */
200
201extern int ntokens;	/* number of tokens */
202extern TOKSYMB *tokset;
203extern int ntoksz;
204
205	/*
206	 * multibyte (c > 255) character literals are
207	 * handled as though they were tokens except
208	 * that it generates a separate mapping table.
209	 */
210extern int nmbchars;	/* number of mb literals */
211extern MBCLIT *mbchars;
212extern int nmbcharsz;
213
214	/* nonterminal information */
215
216extern int nnonter;	/* the number of nonterminals */
217extern NTSYMB *nontrst;
218extern int nnontersz;
219
220	/* grammar rule information */
221
222extern int nprod;	/* number of productions */
223extern int **prdptr;	/* pointers to descriptions of productions */
224extern int *levprd;	/* contains production levels to break conflicts */
225extern wchar_t *had_act; /* set if reduction has associated action code */
226
227	/* state information */
228
229extern int nstate;		/* number of states */
230extern ITEM **pstate;	/* pointers to the descriptions of the states */
231extern int *tystate;	/* contains type information about the states */
232extern int *defact;	/* the default action of the state */
233
234extern int size;
235
236	/* lookahead set information */
237
238extern int TBITSET;
239extern LOOKSETS *lkst;
240extern int nolook;  /* flag to turn off lookahead computations */
241
242	/* working set information */
243
244extern WSET *wsets;
245
246	/* storage for productions */
247
248extern int *mem0;
249extern int *mem;
250extern int *tracemem;
251extern int new_memsize;
252
253	/* storage for action table */
254
255extern int *amem;
256extern int *memp;		/* next free action table position */
257extern int *indgo;		/* index to the stored goto table */
258extern int new_actsize;
259
260	/* temporary vector, indexable by states, terms, or ntokens */
261
262extern int *temp1;
263extern int lineno; /* current line number */
264
265	/* statistics collection variables */
266
267extern int zzgoent;
268extern int zzgobest;
269extern int zzacent;
270extern int zzexcp;
271extern int zzrrconf;
272extern int zzsrconf;
273
274	/* define external functions */
275
276extern void setup(int, char *[]);
277extern void closure(int);
278extern void output(void);
279extern void aryfil(int *, int, int);
280extern void error(char *, ...);
281extern void warning(int, char *, ...);
282extern void putitem(int *, LOOKSETS *);
283extern void go2out(void);
284extern void hideprod(void);
285extern void callopt(void);
286extern void warray(wchar_t *, int *, int);
287extern wchar_t *symnam(int);
288extern wchar_t *writem(int *);
289extern void exp_mem(int);
290extern void exp_act(int **);
291extern int apack(int *, int);
292extern int state(int);
293extern void fprintf3(FILE *, const char *, const wchar_t *, const char *, ...);
294extern void error3(const char *, const wchar_t *, const char *, ...);
295
296extern wchar_t *wscpy(wchar_t *, const wchar_t *);
297extern size_t wslen(const wchar_t *);
298extern int wscmp(const wchar_t *, const wchar_t *);
299
300
301	/* yaccpar location */
302
303extern char *parser;
304
305	/* default settings for a number of macros */
306
307	/* name of yacc tempfiles */
308
309#ifndef TEMPNAME
310#define	TEMPNAME "yacc.tmp"
311#endif
312
313#ifndef ACTNAME
314#define	ACTNAME "yacc.acts"
315#endif
316
317#ifndef DEBUGNAME
318#define	DEBUGNAME "yacc.debug"
319#endif
320
321	/* command to clobber tempfiles after use */
322
323#ifndef ZAPFILE
324#define	ZAPFILE(x) (void)unlink(x)
325#endif
326
327#ifndef PARSER
328#define	PARSER "/usr/ccs/lib/yaccpar"
329#endif
330
331#ifdef	__cplusplus
332}
333#endif
334
335#endif /* _DEXTERN_H */
336