17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 567298654Sdamico * Common Development and Distribution License (the "License"). 667298654Sdamico * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*1dd08564Sab * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */ 277c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 287c478bd9Sstevel@tonic-gate 29e29394bdSmike_s #ifndef _DEXTERN_H 30e29394bdSmike_s #define _DEXTERN_H 31e29394bdSmike_s 327c478bd9Sstevel@tonic-gate #include <stdio.h> 33e29394bdSmike_s #include <inttypes.h> 347c478bd9Sstevel@tonic-gate #include <ctype.h> 357c478bd9Sstevel@tonic-gate #include <memory.h> 367c478bd9Sstevel@tonic-gate #include <string.h> 377c478bd9Sstevel@tonic-gate #include <malloc.h> 387c478bd9Sstevel@tonic-gate #include <values.h> 39e29394bdSmike_s #include <widec.h> 40e29394bdSmike_s #include <unistd.h> 417c478bd9Sstevel@tonic-gate #include <stdlib.h> 427c478bd9Sstevel@tonic-gate #include <wctype.h> 43e29394bdSmike_s 44e29394bdSmike_s #ifdef __cplusplus 45e29394bdSmike_s extern "C" { 46e29394bdSmike_s #endif 47e29394bdSmike_s 487c478bd9Sstevel@tonic-gate /* MANIFEST CONSTANT DEFINITIONS */ 497c478bd9Sstevel@tonic-gate #if u3b || u3b15 || u3b2 || vax || uts || sparc 507c478bd9Sstevel@tonic-gate #define WORD32 517c478bd9Sstevel@tonic-gate #endif 527c478bd9Sstevel@tonic-gate #include <libintl.h> 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate /* base of nonterminal internal numbers */ 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate #define NTBASE (10000000) 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* internal codes for error and accept actions */ 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate #define ERRCODE 8190 617c478bd9Sstevel@tonic-gate #define ACCEPTCODE 8191 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate /* sizes and limits */ 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate #define ACTSIZE 4000 667c478bd9Sstevel@tonic-gate #define MEMSIZE 2000 677c478bd9Sstevel@tonic-gate #define PSTSIZE 1024 687c478bd9Sstevel@tonic-gate #define NSTATES 1000 697c478bd9Sstevel@tonic-gate #define NTERMS 127 707c478bd9Sstevel@tonic-gate #define NPROD 300 717c478bd9Sstevel@tonic-gate #define NNONTERM 600 727c478bd9Sstevel@tonic-gate #define TEMPSIZE 800 737c478bd9Sstevel@tonic-gate #define CNAMSZ 1000 747c478bd9Sstevel@tonic-gate #define LSETSIZE 950 757c478bd9Sstevel@tonic-gate #define WSETSIZE 850 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate #define NAMESIZE 50 787c478bd9Sstevel@tonic-gate #define NTYPES 1000 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate #define NMBCHARSZ 100 817c478bd9Sstevel@tonic-gate #define LKFACTOR 5 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate #ifdef WORD32 847c478bd9Sstevel@tonic-gate /* bit packing macros (may be machine dependent) */ 857c478bd9Sstevel@tonic-gate #define BIT(a, i) ((a)[(i)>>5] & (1<<((i)&037))) 867c478bd9Sstevel@tonic-gate #define SETBIT(a, i) ((a)[(i)>>5] |= (1<<((i)&037))) 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate /* number of words needed to hold n+1 bits */ 897c478bd9Sstevel@tonic-gate #define NWORDS(n) (((n)+32)/32) 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate #else 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* bit packing macros (may be machine dependent) */ 947c478bd9Sstevel@tonic-gate #define BIT(a, i) ((a)[(i)>>4] & (1<<((i)&017))) 957c478bd9Sstevel@tonic-gate #define SETBIT(a, i) ((a)[(i)>>4] |= (1<<((i)&017))) 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* number of words needed to hold n+1 bits */ 987c478bd9Sstevel@tonic-gate #define NWORDS(n) (((n)+16)/16) 997c478bd9Sstevel@tonic-gate #endif 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate /* 1027c478bd9Sstevel@tonic-gate * relationships which must hold: 1037c478bd9Sstevel@tonic-gate * TBITSET ints must hold NTERMS+1 bits... 1047c478bd9Sstevel@tonic-gate * WSETSIZE >= NNONTERM 1057c478bd9Sstevel@tonic-gate * LSETSIZE >= NNONTERM 1067c478bd9Sstevel@tonic-gate * TEMPSIZE >= NTERMS + NNONTERMs + 1 1077c478bd9Sstevel@tonic-gate * TEMPSIZE >= NSTATES 1087c478bd9Sstevel@tonic-gate */ 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate /* associativities */ 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate #define NOASC 0 /* no assoc. */ 1137c478bd9Sstevel@tonic-gate #define LASC 1 /* left assoc. */ 1147c478bd9Sstevel@tonic-gate #define RASC 2 /* right assoc. */ 1157c478bd9Sstevel@tonic-gate #define BASC 3 /* binary assoc. */ 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate /* flags for state generation */ 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate #define DONE 0 1207c478bd9Sstevel@tonic-gate #define MUSTDO 1 1217c478bd9Sstevel@tonic-gate #define MUSTLOOKAHEAD 2 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate /* flags for a rule having an action, and being reduced */ 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate #define ACTFLAG 04 1267c478bd9Sstevel@tonic-gate #define REDFLAG 010 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate /* output parser flags */ 1297c478bd9Sstevel@tonic-gate #define YYFLAG1 (-10000000) 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate /* macros for getting associativity and precedence levels */ 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate #define ASSOC(i) ((i)&07) 1347c478bd9Sstevel@tonic-gate #define PLEVEL(i) (((i)>>4)&077) 1357c478bd9Sstevel@tonic-gate #define TYPE(i) ((i>>10)&077) 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate /* macros for setting associativity and precedence levels */ 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate #define SETASC(i, j) i |= j 1407c478bd9Sstevel@tonic-gate #define SETPLEV(i, j) i |= (j<<4) 1417c478bd9Sstevel@tonic-gate #define SETTYPE(i, j) i |= (j<<10) 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate /* looping macros */ 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate #define TLOOP(i) for (i = 1; i <= ntokens; ++i) 1467c478bd9Sstevel@tonic-gate #define NTLOOP(i) for (i = 0; i <= nnonter; ++i) 1477c478bd9Sstevel@tonic-gate #define PLOOP(s, i) for (i = s; i < nprod; ++i) 1487c478bd9Sstevel@tonic-gate #define SLOOP(i) for (i = 0; i < nstate; ++i) 1497c478bd9Sstevel@tonic-gate #define WSBUMP(x) ++x 1507c478bd9Sstevel@tonic-gate #define WSLOOP(s, j) for (j = s; j < &wsets[cwp]; ++j) 1517c478bd9Sstevel@tonic-gate #define ITMLOOP(i, p, q) q = pstate[i+1]; for (p = pstate[i]; p < q; ++p) 1527c478bd9Sstevel@tonic-gate #define SETLOOP(i) for (i = 0; i < tbitset; ++i) 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate /* I/O descriptors */ 1557c478bd9Sstevel@tonic-gate 156e29394bdSmike_s extern FILE *finput; /* input file */ 157e29394bdSmike_s extern FILE *faction; /* file for saving actions */ 158e29394bdSmike_s extern FILE *fdefine; /* file for #defines */ 159e29394bdSmike_s extern FILE *ftable; /* y.tab.c file */ 160e29394bdSmike_s extern FILE *ftemp; /* tempfile to pass 2 */ 161e29394bdSmike_s extern FILE *fdebug; /* tempfile for two debugging info arrays */ 162e29394bdSmike_s extern FILE *foutput; /* y.output file */ 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate /* structure declarations */ 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate typedef struct looksets { 1677c478bd9Sstevel@tonic-gate int *lset; 1687c478bd9Sstevel@tonic-gate } LOOKSETS; 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate typedef struct item { 1717c478bd9Sstevel@tonic-gate int *pitem; 1727c478bd9Sstevel@tonic-gate LOOKSETS *look; 1737c478bd9Sstevel@tonic-gate } ITEM; 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate typedef struct toksymb { 1767c478bd9Sstevel@tonic-gate wchar_t *name; 1777c478bd9Sstevel@tonic-gate int value; 1787c478bd9Sstevel@tonic-gate } TOKSYMB; 1797c478bd9Sstevel@tonic-gate 1807c478bd9Sstevel@tonic-gate typedef struct mbclit { 1817c478bd9Sstevel@tonic-gate wchar_t character; 1827c478bd9Sstevel@tonic-gate int tvalue; /* token issued for the character */ 1837c478bd9Sstevel@tonic-gate } MBCLIT; 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate typedef struct ntsymb { 1867c478bd9Sstevel@tonic-gate wchar_t *name; 1877c478bd9Sstevel@tonic-gate int tvalue; 1887c478bd9Sstevel@tonic-gate } NTSYMB; 1897c478bd9Sstevel@tonic-gate 1907c478bd9Sstevel@tonic-gate typedef struct wset { 1917c478bd9Sstevel@tonic-gate int *pitem; 1927c478bd9Sstevel@tonic-gate int flag; 1937c478bd9Sstevel@tonic-gate LOOKSETS ws; 1947c478bd9Sstevel@tonic-gate } WSET; 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate /* token information */ 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gate extern int ntokens; /* number of tokens */ 1997c478bd9Sstevel@tonic-gate extern TOKSYMB *tokset; 2007c478bd9Sstevel@tonic-gate extern int ntoksz; 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate /* 2037c478bd9Sstevel@tonic-gate * multibyte (c > 255) character literals are 2047c478bd9Sstevel@tonic-gate * handled as though they were tokens except 2057c478bd9Sstevel@tonic-gate * that it generates a separate mapping table. 2067c478bd9Sstevel@tonic-gate */ 2077c478bd9Sstevel@tonic-gate extern int nmbchars; /* number of mb literals */ 2087c478bd9Sstevel@tonic-gate extern MBCLIT *mbchars; 2097c478bd9Sstevel@tonic-gate extern int nmbcharsz; 2107c478bd9Sstevel@tonic-gate 2117c478bd9Sstevel@tonic-gate /* nonterminal information */ 2127c478bd9Sstevel@tonic-gate 2137c478bd9Sstevel@tonic-gate extern int nnonter; /* the number of nonterminals */ 2147c478bd9Sstevel@tonic-gate extern NTSYMB *nontrst; 2157c478bd9Sstevel@tonic-gate extern int nnontersz; 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate /* grammar rule information */ 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate extern int nprod; /* number of productions */ 2207c478bd9Sstevel@tonic-gate extern int **prdptr; /* pointers to descriptions of productions */ 2217c478bd9Sstevel@tonic-gate extern int *levprd; /* contains production levels to break conflicts */ 2227c478bd9Sstevel@tonic-gate extern wchar_t *had_act; /* set if reduction has associated action code */ 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate /* state information */ 2257c478bd9Sstevel@tonic-gate 2267c478bd9Sstevel@tonic-gate extern int nstate; /* number of states */ 2277c478bd9Sstevel@tonic-gate extern ITEM **pstate; /* pointers to the descriptions of the states */ 2287c478bd9Sstevel@tonic-gate extern int *tystate; /* contains type information about the states */ 2297c478bd9Sstevel@tonic-gate extern int *defact; /* the default action of the state */ 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate extern int size; 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate /* lookahead set information */ 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate extern int TBITSET; 2367c478bd9Sstevel@tonic-gate extern LOOKSETS *lkst; 2377c478bd9Sstevel@tonic-gate extern int nolook; /* flag to turn off lookahead computations */ 2387c478bd9Sstevel@tonic-gate 2397c478bd9Sstevel@tonic-gate /* working set information */ 2407c478bd9Sstevel@tonic-gate 2417c478bd9Sstevel@tonic-gate extern WSET *wsets; 2427c478bd9Sstevel@tonic-gate 2437c478bd9Sstevel@tonic-gate /* storage for productions */ 2447c478bd9Sstevel@tonic-gate 2457c478bd9Sstevel@tonic-gate extern int *mem0; 2467c478bd9Sstevel@tonic-gate extern int *mem; 2477c478bd9Sstevel@tonic-gate extern int *tracemem; 2487c478bd9Sstevel@tonic-gate extern int new_memsize; 2497c478bd9Sstevel@tonic-gate 2507c478bd9Sstevel@tonic-gate /* storage for action table */ 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate extern int *amem; 2537c478bd9Sstevel@tonic-gate extern int *memp; /* next free action table position */ 2547c478bd9Sstevel@tonic-gate extern int *indgo; /* index to the stored goto table */ 2557c478bd9Sstevel@tonic-gate extern int new_actsize; 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate /* temporary vector, indexable by states, terms, or ntokens */ 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate extern int *temp1; 2607c478bd9Sstevel@tonic-gate extern int lineno; /* current line number */ 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gate /* statistics collection variables */ 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate extern int zzgoent; 2657c478bd9Sstevel@tonic-gate extern int zzgobest; 2667c478bd9Sstevel@tonic-gate extern int zzacent; 2677c478bd9Sstevel@tonic-gate extern int zzexcp; 2687c478bd9Sstevel@tonic-gate extern int zzrrconf; 2697c478bd9Sstevel@tonic-gate extern int zzsrconf; 2707c478bd9Sstevel@tonic-gate 2717c478bd9Sstevel@tonic-gate /* define external functions */ 2727c478bd9Sstevel@tonic-gate 273e29394bdSmike_s extern void setup(int, char *[]); 2747c478bd9Sstevel@tonic-gate extern void closure(int); 2757c478bd9Sstevel@tonic-gate extern void output(void); 2767c478bd9Sstevel@tonic-gate extern void aryfil(int *, int, int); 2777c478bd9Sstevel@tonic-gate extern void error(char *, ...); 2787c478bd9Sstevel@tonic-gate extern void warning(int, char *, ...); 2797c478bd9Sstevel@tonic-gate extern void putitem(int *, LOOKSETS *); 2807c478bd9Sstevel@tonic-gate extern void go2out(void); 2817c478bd9Sstevel@tonic-gate extern void hideprod(void); 2827c478bd9Sstevel@tonic-gate extern void callopt(void); 2837c478bd9Sstevel@tonic-gate extern void warray(wchar_t *, int *, int); 2847c478bd9Sstevel@tonic-gate extern wchar_t *symnam(int); 2857c478bd9Sstevel@tonic-gate extern wchar_t *writem(int *); 2867c478bd9Sstevel@tonic-gate extern void exp_mem(int); 2877c478bd9Sstevel@tonic-gate extern void exp_act(int **); 288e29394bdSmike_s extern int apack(int *, int); 2897c478bd9Sstevel@tonic-gate extern int state(int); 2907c478bd9Sstevel@tonic-gate extern void fprintf3(FILE *, const char *, const wchar_t *, const char *, ...); 2917c478bd9Sstevel@tonic-gate extern void error3(const char *, const wchar_t *, const char *, ...); 2927c478bd9Sstevel@tonic-gate 2937c478bd9Sstevel@tonic-gate extern wchar_t *wscpy(wchar_t *, const wchar_t *); 2947c478bd9Sstevel@tonic-gate extern size_t wslen(const wchar_t *); 2957c478bd9Sstevel@tonic-gate extern int wscmp(const wchar_t *, const wchar_t *); 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate 2987c478bd9Sstevel@tonic-gate /* yaccpar location */ 2997c478bd9Sstevel@tonic-gate 3007c478bd9Sstevel@tonic-gate extern char *parser; 3017c478bd9Sstevel@tonic-gate 3027c478bd9Sstevel@tonic-gate /* default settings for a number of macros */ 3037c478bd9Sstevel@tonic-gate 3047c478bd9Sstevel@tonic-gate /* name of yacc tempfiles */ 3057c478bd9Sstevel@tonic-gate 3067c478bd9Sstevel@tonic-gate #ifndef TEMPNAME 3077c478bd9Sstevel@tonic-gate #define TEMPNAME "yacc.tmp" 3087c478bd9Sstevel@tonic-gate #endif 3097c478bd9Sstevel@tonic-gate 3107c478bd9Sstevel@tonic-gate #ifndef ACTNAME 3117c478bd9Sstevel@tonic-gate #define ACTNAME "yacc.acts" 3127c478bd9Sstevel@tonic-gate #endif 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate #ifndef DEBUGNAME 3157c478bd9Sstevel@tonic-gate #define DEBUGNAME "yacc.debug" 3167c478bd9Sstevel@tonic-gate #endif 3177c478bd9Sstevel@tonic-gate 3187c478bd9Sstevel@tonic-gate /* command to clobber tempfiles after use */ 3197c478bd9Sstevel@tonic-gate 3207c478bd9Sstevel@tonic-gate #ifndef ZAPFILE 3217c478bd9Sstevel@tonic-gate #define ZAPFILE(x) (void)unlink(x) 3227c478bd9Sstevel@tonic-gate #endif 3237c478bd9Sstevel@tonic-gate 3247c478bd9Sstevel@tonic-gate #ifndef PARSER 32567298654Sdamico #define PARSER "/usr/share/lib/ccs/yaccpar" 3267c478bd9Sstevel@tonic-gate #endif 327e29394bdSmike_s 328e29394bdSmike_s #ifdef __cplusplus 329e29394bdSmike_s } 330e29394bdSmike_s #endif 331e29394bdSmike_s 332e29394bdSmike_s #endif /* _DEXTERN_H */ 333