dextern.h revision 4538:844098db2e81
154359Sroberto/* 254359Sroberto * CDDL HEADER START 354359Sroberto * 454359Sroberto * The contents of this file are subject to the terms of the 554359Sroberto * Common Development and Distribution License (the "License"). 654359Sroberto * You may not use this file except in compliance with the License. 754359Sroberto * 854359Sroberto * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 954359Sroberto * or http://www.opensolaris.org/os/licensing. 1054359Sroberto * See the License for the specific language governing permissions 1154359Sroberto * and limitations under the License. 1254359Sroberto * 1354359Sroberto * When distributing Covered Code, include this CDDL HEADER in each 1454359Sroberto * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1554359Sroberto * 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 _DEXTERN_H 30#define _DEXTERN_H 31 32#pragma ident "%Z%%M% %I% %E% SMI" 33 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> 45 46#ifdef __cplusplus 47extern "C" { 48#endif 49 50 /* MANIFEST CONSTANT DEFINITIONS */ 51#if u3b || u3b15 || u3b2 || vax || uts || sparc 52#define WORD32 53#endif 54#include <libintl.h> 55 56 /* base of nonterminal internal numbers */ 57 58#define NTBASE (10000000) 59 60 /* internal codes for error and accept actions */ 61 62#define ERRCODE 8190 63#define ACCEPTCODE 8191 64 65 /* sizes and limits */ 66 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 78 79#define NAMESIZE 50 80#define NTYPES 1000 81 82#define NMBCHARSZ 100 83#define LKFACTOR 5 84 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))) 89 90 /* number of words needed to hold n+1 bits */ 91#define NWORDS(n) (((n)+32)/32) 92 93#else 94 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))) 98 99 /* number of words needed to hold n+1 bits */ 100#define NWORDS(n) (((n)+16)/16) 101#endif 102 103 /* 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 110 */ 111 112 /* associativities */ 113 114#define NOASC 0 /* no assoc. */ 115#define LASC 1 /* left assoc. */ 116#define RASC 2 /* right assoc. */ 117#define BASC 3 /* binary assoc. */ 118 119 /* flags for state generation */ 120 121#define DONE 0 122#define MUSTDO 1 123#define MUSTLOOKAHEAD 2 124 125 /* flags for a rule having an action, and being reduced */ 126 127#define ACTFLAG 04 128#define REDFLAG 010 129 130 /* output parser flags */ 131#define YYFLAG1 (-10000000) 132 133 /* macros for getting associativity and precedence levels */ 134 135#define ASSOC(i) ((i)&07) 136#define PLEVEL(i) (((i)>>4)&077) 137#define TYPE(i) ((i>>10)&077) 138 139 /* macros for setting associativity and precedence levels */ 140 141#define SETASC(i, j) i |= j 142#define SETPLEV(i, j) i |= (j<<4) 143#define SETTYPE(i, j) i |= (j<<10) 144 145 /* looping macros */ 146 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) 155 156 /* I/O descriptors */ 157 158extern FILE *finput; /* input file */ 159extern FILE *faction; /* file for saving actions */ 160extern FILE *fdefine; /* file for #defines */ 161extern FILE *ftable; /* y.tab.c file */ 162extern FILE *ftemp; /* tempfile to pass 2 */ 163extern FILE *fdebug; /* tempfile for two debugging info arrays */ 164extern FILE *foutput; /* y.output file */ 165 166 /* structure declarations */ 167 168typedef struct looksets { 169 int *lset; 170} LOOKSETS; 171 172typedef struct item { 173 int *pitem; 174 LOOKSETS *look; 175} ITEM; 176 177typedef struct toksymb { 178 wchar_t *name; 179 int value; 180} TOKSYMB; 181 182typedef struct mbclit { 183 wchar_t character; 184 int tvalue; /* token issued for the character */ 185} MBCLIT; 186 187typedef struct ntsymb { 188 wchar_t *name; 189 int tvalue; 190} NTSYMB; 191 192typedef struct wset { 193 int *pitem; 194 int flag; 195 LOOKSETS ws; 196} WSET; 197 198 /* token information */ 199 200extern int ntokens; /* number of tokens */ 201extern TOKSYMB *tokset; 202extern int ntoksz; 203 204 /* 205 * multibyte (c > 255) character literals are 206 * handled as though they were tokens except 207 * that it generates a separate mapping table. 208 */ 209extern int nmbchars; /* number of mb literals */ 210extern MBCLIT *mbchars; 211extern int nmbcharsz; 212 213 /* nonterminal information */ 214 215extern int nnonter; /* the number of nonterminals */ 216extern NTSYMB *nontrst; 217extern int nnontersz; 218 219 /* grammar rule information */ 220 221extern int nprod; /* number of productions */ 222extern int **prdptr; /* pointers to descriptions of productions */ 223extern int *levprd; /* contains production levels to break conflicts */ 224extern wchar_t *had_act; /* set if reduction has associated action code */ 225 226 /* state information */ 227 228extern int nstate; /* number of states */ 229extern ITEM **pstate; /* pointers to the descriptions of the states */ 230extern int *tystate; /* contains type information about the states */ 231extern int *defact; /* the default action of the state */ 232 233extern int size; 234 235 /* lookahead set information */ 236 237extern int TBITSET; 238extern LOOKSETS *lkst; 239extern int nolook; /* flag to turn off lookahead computations */ 240 241 /* working set information */ 242 243extern WSET *wsets; 244 245 /* storage for productions */ 246 247extern int *mem0; 248extern int *mem; 249extern int *tracemem; 250extern int new_memsize; 251 252 /* storage for action table */ 253 254extern int *amem; 255extern int *memp; /* next free action table position */ 256extern int *indgo; /* index to the stored goto table */ 257extern int new_actsize; 258 259 /* temporary vector, indexable by states, terms, or ntokens */ 260 261extern int *temp1; 262extern int lineno; /* current line number */ 263 264 /* statistics collection variables */ 265 266extern int zzgoent; 267extern int zzgobest; 268extern int zzacent; 269extern int zzexcp; 270extern int zzrrconf; 271extern int zzsrconf; 272 273 /* define external functions */ 274 275extern void setup(int, char *[]); 276extern void closure(int); 277extern void output(void); 278extern void aryfil(int *, int, int); 279extern void error(char *, ...); 280extern void warning(int, char *, ...); 281extern void putitem(int *, LOOKSETS *); 282extern void go2out(void); 283extern void hideprod(void); 284extern void callopt(void); 285extern void warray(wchar_t *, int *, int); 286extern wchar_t *symnam(int); 287extern wchar_t *writem(int *); 288extern void exp_mem(int); 289extern void exp_act(int **); 290extern int apack(int *, int); 291extern int state(int); 292extern void fprintf3(FILE *, const char *, const wchar_t *, const char *, ...); 293extern void error3(const char *, const wchar_t *, const char *, ...); 294 295extern wchar_t *wscpy(wchar_t *, const wchar_t *); 296extern size_t wslen(const wchar_t *); 297extern int wscmp(const wchar_t *, const wchar_t *); 298 299 300 /* yaccpar location */ 301 302extern char *parser; 303 304 /* default settings for a number of macros */ 305 306 /* name of yacc tempfiles */ 307 308#ifndef TEMPNAME 309#define TEMPNAME "yacc.tmp" 310#endif 311 312#ifndef ACTNAME 313#define ACTNAME "yacc.acts" 314#endif 315 316#ifndef DEBUGNAME 317#define DEBUGNAME "yacc.debug" 318#endif 319 320 /* command to clobber tempfiles after use */ 321 322#ifndef ZAPFILE 323#define ZAPFILE(x) (void)unlink(x) 324#endif 325 326#ifndef PARSER 327#define PARSER "/usr/share/lib/ccs/yaccpar" 328#endif 329 330#ifdef __cplusplus 331} 332#endif 333 334#endif /* _DEXTERN_H */ 335