xref: /onnv-gate/usr/src/lib/libpp/common/pp.h (revision 10898:1883b621b3ea)
14887Schin /***********************************************************************
24887Schin *                                                                      *
34887Schin *               This software is part of the ast package               *
4*10898Sroland.mainz@nrubsig.org *          Copyright (c) 1986-2009 AT&T Intellectual Property          *
54887Schin *                      and is licensed under the                       *
64887Schin *                  Common Public License, Version 1.0                  *
78462SApril.Chin@Sun.COM *                    by AT&T Intellectual Property                     *
84887Schin *                                                                      *
94887Schin *                A copy of the License is available at                 *
104887Schin *            http://www.opensource.org/licenses/cpl1.0.txt             *
114887Schin *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
124887Schin *                                                                      *
134887Schin *              Information and Software Systems Research               *
144887Schin *                            AT&T Research                             *
154887Schin *                           Florham Park NJ                            *
164887Schin *                                                                      *
174887Schin *                 Glenn Fowler <gsf@research.att.com>                  *
184887Schin *                                                                      *
194887Schin ***********************************************************************/
204887Schin #pragma prototyped
214887Schin /*
224887Schin  * Glenn Fowler
234887Schin  * AT&T Research
244887Schin  *
254887Schin  * preprocessor library public definitions
264887Schin  */
274887Schin 
284887Schin #ifndef _PP_H
294887Schin #define _PP_H
304887Schin 
314887Schin #ifdef ppsymbol
324887Schin /*
334887Schin  * undo old nmake cpp name-space intrusion
344887Schin  * this disables __LINE__, __FILE__, __DATE__ and __TIME__
354887Schin  */
364887Schin #undef	ppsymbol
374887Schin #undef	__LINE__
384887Schin #define __LINE__	0
394887Schin #undef	__FILE__
404887Schin #define __FILE__	"libpp"
414887Schin #undef	__DATE__
424887Schin #define __DATE__	"MMM DD YYYY"
434887Schin #undef	__TIME__
444887Schin #define __TIME__	"HH:MM:SS"
454887Schin #endif
464887Schin 
474887Schin 
484887Schin #if PROTOMAIN
494887Schin #define HASH_HEADER	int	hash_header
504887Schin #define Hash_table_t	char
514887Schin #define Sfio_t		char
524887Schin #define CC_bel		(('A'==0301)?0057:0007)
534887Schin #define CC_esc		(('A'==0301)?0047:0033)
544887Schin #define CC_vt		0013
554887Schin #else
564887Schin #include <limits.h>
574887Schin #include <hash.h>
584887Schin #include <error.h>
594887Schin #include <ccode.h>
604887Schin #endif
614887Schin 
624887Schin #define PPDEFAULT	"pp_default.h"		/* runtime definitions	*/
634887Schin #define PPPROBE		"cc"			/* default probe key	*/
644887Schin #define PPSTANDARD	"/usr/include"		/* standard include dir	*/
654887Schin 
664887Schin #define PPBLKSIZ	1024			/* unit block size	*/
674887Schin #define PPBAKSIZ	(1*PPBLKSIZ)		/* input pushback size	*/
684887Schin #define PPBUFSIZ	(32*PPBLKSIZ)		/* io buffer size	*/
694887Schin #define PPTOKSIZ	((PPBUFSIZ/2)-1)	/* max token size	*/
704887Schin 
718462SApril.Chin@Sun.COM #define PPWRITE(n)	do{if(write(1,pp.outbuf,n)!=(n))pperror(ERROR_SYSTEM|3,"%s: write error",pp.outfile);pp.offset+=(n);pp.lastout=pp.outbuf[(n)-1];}while(0)
724887Schin 
734887Schin #define pplastout()	((pp.outp>pp.outbuf)?*(pp.outp-1):pp.lastout)
744887Schin #define ppoffset()	(pp.offset+pppendout())
754887Schin #define pppendout()	(pp.outp-pp.outbuf)
764887Schin #define ppputchar(c)	(*pp.outp++=(c))
774887Schin #define ppflushout()	do{if(pp.outp>pp.outbuf){PPWRITE(pp.outp-pp.outbuf);pp.outp=pp.outbuf;}}while(0)
784887Schin #define ppcheckout()	do{if(pp.outp>pp.oute){PPWRITE(PPBUFSIZ);if(pp.outbuf==pp.outb){pp.outbuf+=PPBUFSIZ;pp.oute+=PPBUFSIZ;}else{pp.outbuf-=PPBUFSIZ;memcpy(pp.outbuf,pp.oute,pp.outp-pp.oute);pp.oute-=PPBUFSIZ;pp.outp-=2*PPBUFSIZ;}}}while(0)
794887Schin 
804887Schin #define ppsymget(t,n)	(struct ppsymbol*)hashlook(t,n,HASH_LOOKUP,NiL)
814887Schin #define ppsymref(t,n)	(struct ppsymbol*)hashlook(t,n,pp.truncate?HASH_LOOKUP:HASH_LOOKUP|HASH_INTERNAL,NiL)
824887Schin #define ppsymset(t,n)	(struct ppsymbol*)hashlook(t,n,HASH_CREATE|HASH_SIZE(sizeof(struct ppsymbol)),NiL)
834887Schin 
844887Schin #if CHAR_MIN < 0
85*10898Sroland.mainz@nrubsig.org #define pptype		(ppctype-(CHAR_MIN))
864887Schin #else
874887Schin #define pptype		(ppctype)
884887Schin #endif
894887Schin 
904887Schin #define C_ID		(1<<0)
914887Schin #define C_DIG		(1<<1)
924887Schin #define C_SPLICE	(1<<2)
934887Schin 
944887Schin #define ppisdig(c)	((pptype)[c]&C_DIG)
954887Schin #define ppisid(c)	((pptype)[c]&C_ID)
964887Schin #define ppisidig(c)	((pptype)[c]&(C_ID|C_DIG))
974887Schin #define ppismac(c)	((pptype)[c]&(C_ID|C_DIG|C_SPLICE))
984887Schin #define ppissplice(c)	((pptype)[c]&C_SPLICE)
994887Schin 
1004887Schin #define setid(c)	((pptype)[c]|=C_ID)
1014887Schin #define clrid(c)	((pptype)[c]&=~C_ID)
1024887Schin #define setdig(c)	((pptype)[c]|=C_DIG)
1034887Schin #define setsplice(c)	((pptype)[c]|=C_SPLICE)
1044887Schin 
1054887Schin #define REF_CREATE	(REF_NORMAL+1)	/* include wrapper (internal)	*/
1064887Schin #define REF_DELETE	(REF_NORMAL+2)	/* macro definition (internal)	*/
1074887Schin #define REF_NORMAL	0		/* normal macro reference	*/
1084887Schin #define REF_IF		(-1)		/* if, ifdef, ifndef, elif	*/
1094887Schin #define REF_UNDEF	(-2)		/* undef			*/
1104887Schin 
1114887Schin #define SYM_ACTIVE	(1L<<0)		/* active macro lock		*/
1124887Schin #define SYM_BUILTIN	(1L<<1)		/* builtin macro		*/
1134887Schin #define SYM_DISABLED	(1L<<2)		/* macro expansion disabled	*/
1144887Schin #define SYM_EMPTY	(1L<<3)		/* allow empty/missing actuals	*/
1154887Schin #define SYM_FINAL	(1L<<4)		/* final hosted value		*/
1164887Schin #define SYM_FUNCTION	(1L<<5)		/* macro with args		*/
1174887Schin #define SYM_INIT	(1L<<6)		/* initialization macro		*/
1184887Schin #define SYM_INITIAL	(1L<<7)		/* initial hosted value		*/
1194887Schin #define SYM_KEYWORD	(1L<<8)		/* keyword identifier		*/
1204887Schin #define SYM_LEX		(1L<<9)		/* ppsymkey with lex field	*/
1214887Schin #define SYM_MULTILINE	(1L<<10)	/* multi-line macro		*/
1224887Schin #define SYM_NOEXPAND	(1L<<11)	/* no identifiers in macro body	*/
1234887Schin #define SYM_NOTICED	(1L<<12)	/* symbol noticed in output	*/
1244887Schin #define SYM_PREDEFINED	(1L<<13)	/* predefined macro		*/
1254887Schin #define SYM_PREDICATE	(1L<<14)	/* also a predicate		*/
1264887Schin #define SYM_READONLY	(1L<<15)	/* readonly macro		*/
1274887Schin #define SYM_REDEFINE	(1L<<16)	/* ok to redefine		*/
1284887Schin #define SYM_VARIADIC	(1L<<17)	/* variadic macro with args	*/
1294887Schin #define SYM_UNUSED	24		/* first unused symbol flag bit	*/
1304887Schin 
1314887Schin #define PP_ASSERT		1	/* preassert symbol		*/
1324887Schin #define PP_BUILTIN		2	/* #(<id>) handler		*/
1334887Schin #define PP_CDIR			3	/* C (vs. C++) file dirs follow	*/
1344887Schin #define PP_CHOP			4	/* include prefix chop		*/
1354887Schin #define PP_COMMENT		5	/* passed comment handler	*/
1364887Schin #define PP_COMPATIBILITY	6	/* old (Reiser) dialect		*/
1374887Schin #define PP_COMPILE		7	/* tokenize for front end	*/
1384887Schin #define PP_DEBUG		8	/* set debug trace level	*/
1394887Schin #define PP_DEFINE		9	/* predefine symbol		*/
1404887Schin #define PP_DEFAULT		10	/* read default include files	*/
1414887Schin #define PP_DIRECTIVE		11	/* initialization directive	*/
1424887Schin #define PP_DONE			12	/* all processing done		*/
1434887Schin #define PP_DUMP			13	/* do checkpoint dump		*/
1444887Schin #define PP_FILEDEPS		14	/* output file dependencies	*/
1454887Schin #define PP_FILENAME		15	/* set input file name		*/
1464887Schin #define PP_HOSTDIR		16	/* hosted file dirs follow	*/
1474887Schin #define PP_ID			17	/* add to identifier set	*/
1484887Schin #define PP_IGNORE		18	/* ignore this include file	*/
1494887Schin #define PP_IGNORELIST		19	/* include ignore list file	*/
1504887Schin #define PP_INCLUDE		20	/* add dir to include search	*/
1514887Schin #define PP_INCREF		21	/* include file push/ret handler*/
1524887Schin #define PP_INIT			22	/* one time initialization	*/
1534887Schin #define PP_INPUT		23	/* set input source file	*/
1544887Schin #define PP_KEYARGS		24	/* name=value macro args	*/
1554887Schin #define PP_LINE			25	/* line sync handler		*/
1564887Schin #define PP_LINEBASE		26	/* base name in line sync	*/
1574887Schin #define PP_LINEFILE		27	/* line sync requires file arg	*/
1584887Schin #define PP_LINEID		28	/* PP_LINE directive id		*/
1594887Schin #define PP_LINETYPE		29	/* # extra line sync type args	*/
1604887Schin #define PP_LOCAL		30	/* previous PP_INCLUDE for ""	*/
1614887Schin #define PP_MACREF		31	/* macro def/ref handler	*/
1624887Schin #define PP_MULTIPLE		32	/* set all files multiple	*/
1634887Schin #define PP_NOHASH		33	/* don't hash PP_COMPILE T_ID's	*/
1644887Schin #define PP_NOISE		34	/* convert T_X_* to T_NOISE	*/
1654887Schin #define PP_OPTION		35	/* set pragma option		*/
1664887Schin #define PP_OPTARG		36	/* unknown option arg handler	*/
1674887Schin #define PP_OUTPUT		37	/* set output file sink		*/
1684887Schin #define PP_PASSTHROUGH		38	/* ppcpp() expands # lines only	*/
1694887Schin #define PP_PEDANTIC		39	/* pedantic non-hosted warnings	*/
1704887Schin #define PP_PLUSCOMMENT		40	/* enable C++ comments		*/
1714887Schin #define PP_PLUSPLUS		41	/* tokenize for C++		*/
1724887Schin #define PP_POOL			42	/* pool for multiple io passes	*/
1734887Schin #define PP_PRAGMA		43	/* passed pragma handler	*/
1744887Schin #define PP_PRAGMAFLAGS		44	/* global pragma flags		*/
1754887Schin #define PP_PROBE		45	/* ppdefault probe key		*/
1764887Schin #define PP_QUOTE		46	/* add to quote set		*/
1774887Schin #define PP_READ			47	/* include file without output	*/
1784887Schin #define PP_REGUARD		48	/* file pop emits guard define	*/
1794887Schin #define PP_RESERVED		49	/* COMPILE reserved keyword	*/
1804887Schin #define PP_RESET		50	/* reset to initiali predefs	*/
1814887Schin #define PP_SPACEOUT		51	/* pplex returns space,newline	*/
1824887Schin #define PP_STANDALONE		52	/* standalone preprocessor	*/
1834887Schin #define PP_STANDARD		53	/* standard include dir		*/
1844887Schin #define PP_STRICT		54	/* strict implementation	*/
1854887Schin #define PP_TEST			55	/* enable (undocumented) tests	*/
1864887Schin #define PP_TEXT			56	/* include file with output	*/
1874887Schin #define PP_TRANSITION		57	/* on COMPATIBILITY boundary	*/
1884887Schin #define PP_TRUNCATE		58	/* truncate macro names		*/
1894887Schin #define PP_UNDEF		59	/* undef symbol after ppdefault	*/
1904887Schin #define PP_VENDOR		60	/* vendor file dirs follow	*/
1914887Schin #define PP_WARN			61	/* enable annoying warnings	*/
1924887Schin 
1934887Schin #define PP_comment		(1<<0)	/* PP_COMMENT is set		*/
1944887Schin #define PP_compatibility	(1<<1)	/* PP_COMPATIBILITY is set	*/
1954887Schin #define PP_hosted		(1<<2)	/* current file is hosted	*/
1964887Schin #define PP_linebase		(1<<3)	/* base name in line sync	*/
1974887Schin #define PP_linefile		(1<<4)	/* line sync file arg required	*/
1984887Schin #define PP_linehosted		(1<<5)	/* line sync hosted arg required*/
1994887Schin #define PP_lineignore		(1<<6)	/* line sync for ignored file	*/
2004887Schin #define PP_linetype		(1<<7)	/* line sync type arg required	*/
2014887Schin #define PP_strict		(1<<8)	/* PP_STRICT is set		*/
2024887Schin #define PP_transition		(1<<9)	/* PP_TRANSITION is set		*/
2034887Schin 
2044887Schin #define PP_deps			(1<<0)	/* generate header deps		*/
2054887Schin #define PP_deps_file		(1<<1)	/* write deps to separate file	*/
2064887Schin #define PP_deps_generated	(1<<2)	/* missing deps are generated	*/
2074887Schin #define PP_deps_local		(1<<3)	/* only local header deps	*/
2084887Schin 
2094887Schin #define PP_sync			0	/* normal line sync		*/
2104887Schin #define PP_sync_push		'1'	/* [3] include file push	*/
2114887Schin #define PP_sync_pop		'2'	/* [3] include file pop		*/
2124887Schin #define PP_sync_ignore		'3'	/* [3] ignored include file	*/
2134887Schin #define PP_sync_hosted		'3'	/* [4] hosted include file	*/
2144887Schin 
2154887Schin #define PP_SYNC_PUSH		(1<<0)	/* pp.incref PP_sync_push type	*/
2164887Schin #define PP_SYNC_POP		(1<<1)	/* pp.incref PP_sync_pop type	*/
2174887Schin #define PP_SYNC_IGNORE		(1<<2)	/* pp.incref PP_sync_ignore type*/
2184887Schin #define PP_SYNC_HOSTED		(1<<3)	/* pp.incref PP_sync_hosted type*/
2194887Schin #define PP_SYNC_INSERT		(1<<4)	/* pinserted by other means	*/
2204887Schin 
2214887Schin /*
2224887Schin  * numeric modifiers
2234887Schin  *
2244887Schin  * NOTE: 0400 is claimed by error in yacc
2254887Schin  * 	 (N_PP+30) is the largest valid pp token
2264887Schin  *	 free tokens start at T_TOKEN
2274887Schin  */
2284887Schin 
2294887Schin #define N_PP			0401		/* pp tokens 0401..0437	*/
2304887Schin #define N_NUMBER		0440		/* numbers 0440..0477	*/
2314887Schin #define N_TEST			(N_NUMBER|07700)/* number test mask	*/
2324887Schin #define N_TOKEN			0500		/* free 0500..07777	*/
2334887Schin #define N_WIDE			1		/* wide quoted constant	*/
2344887Schin 
2354887Schin /*
2364887Schin  * NOTE: preserve the token ranges and encodings for is*(x)
2374887Schin  */
2384887Schin 
2394887Schin #define ppisnumber(x)		(((x)&N_TEST)==N_NUMBER)
2404887Schin #define ppisinteger(x)		(((x)&(N_TEST|N_REAL))==N_NUMBER)
2414887Schin #define ppisreal(x)		(((x)&(N_TEST|N_REAL))==(N_NUMBER|N_REAL))
2424887Schin #define ppisassignop(x)		(((x)>=T_MPYEQ)&&((x)<=T_OREQ))
2434887Schin #define ppisseparate(x)		(((x)>=N_PP)&&((x)<=T_WSTRING)||((x)>=N_NUMBER)||((x)=='+')||((x)=='-'))
2444887Schin 
2454887Schin #define N_LONG			0001
2464887Schin #define N_UNSIGNED		0002		/* if ppisinteger(x)	*/
2474887Schin #define N_FLOAT			0002		/* if ppisreal(x)		*/
2484887Schin 
2494887Schin #define N_REAL			0004
2504887Schin #define N_OCTAL			0010
2514887Schin #define N_HEXADECIMAL		0020
2524887Schin 
2534887Schin #define N_EXPONENT		010000		/* for lexing only	*/
2544887Schin #define N_SIGN			020000		/* for lexing only	*/
2554887Schin #define N_TRAILING		040000		/* for lexing only	*/
2564887Schin 
2574887Schin #if !defined(T_DOUBLE)
2584887Schin 
2594887Schin /*
2604887Schin  * numeric constants
2614887Schin  */
2624887Schin 
2634887Schin #define T_DOUBLE		(N_NUMBER|N_REAL)
2644887Schin #define T_DOUBLE_L		(N_NUMBER|N_REAL|N_LONG)
2654887Schin #define T_FLOAT			(N_NUMBER|N_REAL|N_FLOAT)
2664887Schin #define T_DECIMAL		(N_NUMBER)
2674887Schin #define T_DECIMAL_L		(N_NUMBER|N_LONG)
2684887Schin #define T_DECIMAL_U		(N_NUMBER|N_UNSIGNED)
2694887Schin #define T_DECIMAL_UL		(N_NUMBER|N_UNSIGNED|N_LONG)
2704887Schin #define T_OCTAL			(N_NUMBER|N_OCTAL)
2714887Schin #define T_OCTAL_L		(N_NUMBER|N_OCTAL|N_LONG)
2724887Schin #define T_OCTAL_U		(N_NUMBER|N_OCTAL|N_UNSIGNED)
2734887Schin #define T_OCTAL_UL		(N_NUMBER|N_OCTAL|N_UNSIGNED|N_LONG)
2744887Schin #define T_HEXADECIMAL		(N_NUMBER|N_HEXADECIMAL)
2754887Schin #define T_HEXADECIMAL_L		(N_NUMBER|N_HEXADECIMAL|N_LONG)
2764887Schin #define T_HEXADECIMAL_U		(N_NUMBER|N_HEXADECIMAL|N_UNSIGNED)
2774887Schin #define T_HEXADECIMAL_UL	(N_NUMBER|N_HEXADECIMAL|N_UNSIGNED|N_LONG)
2784887Schin #define T_HEXDOUBLE		(N_NUMBER|N_HEXADECIMAL|N_REAL)
2794887Schin #define T_HEXDOUBLE_L		(N_NUMBER|N_HEXADECIMAL|N_REAL|N_LONG)
2804887Schin 
2814887Schin /*
2824887Schin  * identifier and invalid token
2834887Schin  */
2844887Schin 
2854887Schin #define T_ID			(N_PP+0)
2864887Schin #define T_INVALID		(N_PP+1)
2874887Schin 
2884887Schin /*
2894887Schin  * quoted constants
2904887Schin  */
2914887Schin 
2924887Schin #define T_HEADER		(N_PP+2)		/*	<..>	*/
2934887Schin #define T_CHARCONST		(N_PP+3)		/*	'..'	*/
2944887Schin #define T_WCHARCONST		(T_CHARCONST|N_WIDE)	/*	L'..'	*/
2954887Schin #define T_STRING		(N_PP+5)		/*	".."	*/
2964887Schin #define T_WSTRING		(T_STRING|N_WIDE)	/*	L".."	*/
2974887Schin 
2984887Schin /*
2994887Schin  * multichar operators
3004887Schin  */
3014887Schin 
3024887Schin #define T_PTRMEM		(N_PP+7)	/*	->	*/
3034887Schin #define T_ADDADD		(N_PP+8)	/*	++	*/
3044887Schin #define T_SUBSUB		(N_PP+9)	/*	--	*/
3054887Schin #define T_LSHIFT		(N_PP+10)	/*	<<	*/
3064887Schin #define T_RSHIFT		(N_PP+11)	/*	>>	*/
3074887Schin #define T_LE			(N_PP+12)	/*	<=	*/
3084887Schin #define T_GE			(N_PP+13)	/*	>=	*/
3094887Schin #define T_EQ			(N_PP+14)	/*	==	*/
3104887Schin #define T_NE			(N_PP+15)	/*	!=	*/
3114887Schin #define T_ANDAND		(N_PP+16)	/*	&&	*/
3124887Schin #define T_OROR			(N_PP+17)	/*	||	*/
3134887Schin #define T_MPYEQ			(N_PP+18)	/*	*=	*/
3144887Schin #define T_DIVEQ			(N_PP+19)	/*	/=	*/
3154887Schin #define T_MODEQ			(N_PP+20)	/*	%=	*/
3164887Schin #define T_ADDEQ			(N_PP+21)	/*	+=	*/
3174887Schin #define T_SUBEQ			(N_PP+22)	/*	-=	*/
3184887Schin #define T_LSHIFTEQ		(N_PP+23)	/*	<<=	*/
3194887Schin #define T_RSHIFTEQ		(N_PP+24)	/*	>>=	*/
3204887Schin #define T_ANDEQ			(N_PP+25)	/*	&=	*/
3214887Schin #define T_XOREQ			(N_PP+26)	/*	^=	*/
3224887Schin #define T_OREQ			(N_PP+27)	/*	|=	*/
3234887Schin #define T_TOKCAT		(N_PP+28)	/*	##	*/
3244887Schin #define T_VARIADIC		(N_PP+29)	/*	...	*/
3254887Schin 
3264887Schin /*
3274887Schin  * C++ tokens
3284887Schin  */
3294887Schin 
3304887Schin #define T_DOTREF		(N_TOKEN+0)	/*	.*	*/
3314887Schin #define T_PTRMEMREF		(N_TOKEN+1)	/*	->*	*/
3324887Schin #define T_SCOPE			(N_TOKEN+2)	/*	::	*/
3334887Schin 
3344887Schin /*
3354887Schin  * compiler tokens
3364887Schin  */
3374887Schin 
3384887Schin #define T_UMINUS		(N_TOKEN+3)
3394887Schin 
3404887Schin #endif
3414887Schin 
3424887Schin /*
3434887Schin  * start of free tokens
3444887Schin  */
3454887Schin 
3464887Schin #define T_TOKEN			(N_TOKEN+4)
3474887Schin 
3484887Schin struct ppdirs				/* directory list		*/
3494887Schin {
3504887Schin 	char*		name;		/* directory name		*/
3514887Schin 	struct ppdirs*	next;		/* next in list			*/
3524887Schin 
3534887Schin #ifdef _PP_DIRS_PRIVATE_
3544887Schin 	_PP_DIRS_PRIVATE_
3554887Schin #endif
3564887Schin 
3574887Schin };
3584887Schin 
3594887Schin struct ppkeyword			/* pp keyword info		*/
3604887Schin {
3614887Schin 	char*		name;		/* keyword name			*/
3624887Schin 	int		value;		/* keyword token value		*/
3634887Schin };
3644887Schin 
3654887Schin struct ppmacro				/* pp macro info		*/
3664887Schin {
3674887Schin 	int		arity;		/* # formal arguments		*/
3684887Schin 	char*		value;		/* definition value		*/
3694887Schin 
3704887Schin #ifdef _PP_MACRO_PRIVATE_
3714887Schin 	_PP_MACRO_PRIVATE_
3724887Schin #endif
3734887Schin 
3744887Schin };
3754887Schin 
3764887Schin struct ppsymbol				/* pp symbol info		*/
3774887Schin {
3784887Schin 	HASH_HEADER;			/* hash stuff and symbol name	*/
3794887Schin 	unsigned long	flags;		/* SYM_* status			*/
3804887Schin 	struct ppmacro*	macro;		/* macro info			*/
3814887Schin 	void*		value;		/* value (for other passes)	*/
3824887Schin 
3834887Schin #ifdef _PP_SYMBOL_PRIVATE_
3844887Schin 	_PP_SYMBOL_PRIVATE_
3854887Schin #endif
3864887Schin 
3874887Schin };
3884887Schin 
3894887Schin #define _PP_CONTEXT_BASE_	((char*)&pp.lcldirs)
3904887Schin 
3914887Schin #define _PP_CONTEXT_PUBLIC_ \
3924887Schin 	struct ppdirs*	lcldirs;	/* the "..." dir list		*/ \
3934887Schin 	struct ppdirs*	stddirs;	/* next is the <...> dir list	*/ \
3944887Schin 	int		flags;		/* PP_[a-z]* flags		*/ \
3954887Schin 	Hash_table_t*	symtab;		/* macro and id hash table	*/
3964887Schin 
3974887Schin struct ppglobals			/* globals accessed by pp.*	*/
3984887Schin {
3994887Schin 	const char*	version;	/* version stamp		*/
4004887Schin 	char*		lineid;		/* line sync directive id	*/
4014887Schin 	char*		outfile;	/* output file name		*/
4024887Schin 	char*		pass;		/* pass name			*/
4034887Schin 	char*		token;		/* pplex() token name		*/
4044887Schin 	struct ppsymbol* symbol;	/* last symbol if PP_COMPILE	*/
4054887Schin 
4064887Schin 	/* exposed for the output macros */
4074887Schin 
4084887Schin 	char*		outb;		/* output buffer base		*/
4094887Schin 	char*		outbuf;		/* output buffer		*/
4104887Schin 	char*		outp;	    	/* outbuf pointer		*/
4114887Schin 	char*		oute;	    	/* outbuf end			*/
4124887Schin 	unsigned long	offset;		/* output offset		*/
4134887Schin 
4144887Schin #ifdef _PP_CONTEXT_PUBLIC_
4154887Schin 	_PP_CONTEXT_PUBLIC_		/* public context		*/
4164887Schin #endif
4174887Schin 
4184887Schin #ifdef _PP_CONTEXT_PRIVATE_
4194887Schin 	_PP_CONTEXT_PRIVATE_		/* library private context	*/
4204887Schin #endif
4214887Schin 
4224887Schin #ifdef _PP_GLOBALS_PRIVATE_
4234887Schin 	_PP_GLOBALS_PRIVATE_		/* library private additions	*/
4244887Schin #endif
4254887Schin 
4264887Schin };
4274887Schin 
4284887Schin /*
4294887Schin  * library interface globals
4304887Schin  */
4314887Schin 
4324887Schin #define ppctype		_pp_ctype
4334887Schin 
4344887Schin extern struct ppglobals	pp;
4354887Schin extern char		ppctype[];
4364887Schin 
4374887Schin extern int		ppargs(char**, int);
4384887Schin extern void		ppcpp(void);
4394887Schin extern void		ppcomment(char*, char*, char*, int);
4404887Schin extern void*		ppcontext(void*, int);
4414887Schin extern void		pperror(int, ...);
4424887Schin extern void		ppincref(char*, char*, int, int);
4434887Schin extern void		ppinput(char*, char*, int);
4444887Schin extern int		pplex(void);
4454887Schin extern void		ppline(int, char*);
4464887Schin extern void		ppmacref(struct ppsymbol*, char*, int, int, unsigned long);
4474887Schin extern void		ppop(int, ...);
4484887Schin extern void		pppragma(char*, char*, char*, char*, int);
4494887Schin extern int		ppprintf(char*, ...);
4504887Schin extern int		ppsync(void);
4514887Schin 
4524887Schin #endif
453