#pragma prototyped
#ifndef _PP_H
#define _PP_H
#ifdef ppsymbol
#undef ppsymbol
#undef __LINE__
#define __LINE__ 0
#undef __FILE__
#define __FILE__ "libpp"
#undef __DATE__
#define __DATE__ "MMM DD YYYY"
#undef __TIME__
#define __TIME__ "HH:MM:SS"
#endif
#if PROTOMAIN
#define HASH_HEADER int hash_header
#define Hash_table_t char
#define Sfio_t char
#define CC_bel (('A'==0301)?0057:0007)
#define CC_esc (('A'==0301)?0047:0033)
#define CC_vt 0013
#else
#include <limits.h>
#include <hash.h>
#include <error.h>
#include <ccode.h>
#endif
#define PPDEFAULT "pp_default.h"
#define PPPROBE "cc"
#define PPSTANDARD "/usr/include"
#define PPBLKSIZ 1024
#define PPBAKSIZ (1*PPBLKSIZ)
#define PPBUFSIZ (32*PPBLKSIZ)
#define PPTOKSIZ ((PPBUFSIZ/2)-1)
#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)
#define pplastout() ((pp.outp>pp.outbuf)?*(pp.outp-1):pp.lastout)
#define ppoffset() (pp.offset+pppendout())
#define pppendout() (pp.outp-pp.outbuf)
#define ppputchar(c) (*pp.outp++=(c))
#define ppflushout() do{if(pp.outp>pp.outbuf){PPWRITE(pp.outp-pp.outbuf);pp.outp=pp.outbuf;}}while(0)
#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)
#define ppsymget(t,n) (struct ppsymbol*)hashlook(t,n,HASH_LOOKUP,NiL)
#define ppsymref(t,n) (struct ppsymbol*)hashlook(t,n,pp.truncate?HASH_LOOKUP:HASH_LOOKUP|HASH_INTERNAL,NiL)
#define ppsymset(t,n) (struct ppsymbol*)hashlook(t,n,HASH_CREATE|HASH_SIZE(sizeof(struct ppsymbol)),NiL)
#if CHAR_MIN < 0
#define pptype (ppctype-(CHAR_MIN))
#else
#define pptype (ppctype)
#endif
#define C_ID (1<<0)
#define C_DIG (1<<1)
#define C_SPLICE (1<<2)
#define ppisdig(c) ((pptype)[c]&C_DIG)
#define ppisid(c) ((pptype)[c]&C_ID)
#define ppisidig(c) ((pptype)[c]&(C_ID|C_DIG))
#define ppismac(c) ((pptype)[c]&(C_ID|C_DIG|C_SPLICE))
#define ppissplice(c) ((pptype)[c]&C_SPLICE)
#define setid(c) ((pptype)[c]|=C_ID)
#define clrid(c) ((pptype)[c]&=~C_ID)
#define setdig(c) ((pptype)[c]|=C_DIG)
#define setsplice(c) ((pptype)[c]|=C_SPLICE)
#define REF_CREATE (REF_NORMAL+1)
#define REF_DELETE (REF_NORMAL+2)
#define REF_NORMAL 0
#define REF_IF (-1)
#define REF_UNDEF (-2)
#define SYM_ACTIVE (1L<<0)
#define SYM_BUILTIN (1L<<1)
#define SYM_DISABLED (1L<<2)
#define SYM_EMPTY (1L<<3)
#define SYM_FINAL (1L<<4)
#define SYM_FUNCTION (1L<<5)
#define SYM_INIT (1L<<6)
#define SYM_INITIAL (1L<<7)
#define SYM_KEYWORD (1L<<8)
#define SYM_LEX (1L<<9)
#define SYM_MULTILINE (1L<<10)
#define SYM_NOEXPAND (1L<<11)
#define SYM_NOTICED (1L<<12)
#define SYM_PREDEFINED (1L<<13)
#define SYM_PREDICATE (1L<<14)
#define SYM_READONLY (1L<<15)
#define SYM_REDEFINE (1L<<16)
#define SYM_VARIADIC (1L<<17)
#define SYM_UNUSED 24
#define PP_ASSERT 1
#define PP_BUILTIN 2
#define PP_CDIR 3
#define PP_CHOP 4
#define PP_COMMENT 5
#define PP_COMPATIBILITY 6
#define PP_COMPILE 7
#define PP_DEBUG 8
#define PP_DEFINE 9
#define PP_DEFAULT 10
#define PP_DIRECTIVE 11
#define PP_DONE 12
#define PP_DUMP 13
#define PP_FILEDEPS 14
#define PP_FILENAME 15
#define PP_HOSTDIR 16
#define PP_ID 17
#define PP_IGNORE 18
#define PP_IGNORELIST 19
#define PP_INCLUDE 20
#define PP_INCREF 21
#define PP_INIT 22
#define PP_INPUT 23
#define PP_KEYARGS 24
#define PP_LINE 25
#define PP_LINEBASE 26
#define PP_LINEFILE 27
#define PP_LINEID 28
#define PP_LINETYPE 29
#define PP_LOCAL 30
#define PP_MACREF 31
#define PP_MULTIPLE 32
#define PP_NOHASH 33
#define PP_NOISE 34
#define PP_OPTION 35
#define PP_OPTARG 36
#define PP_OUTPUT 37
#define PP_PASSTHROUGH 38
#define PP_PEDANTIC 39
#define PP_PLUSCOMMENT 40
#define PP_PLUSPLUS 41
#define PP_POOL 42
#define PP_PRAGMA 43
#define PP_PRAGMAFLAGS 44
#define PP_PROBE 45
#define PP_QUOTE 46
#define PP_READ 47
#define PP_REGUARD 48
#define PP_RESERVED 49
#define PP_RESET 50
#define PP_SPACEOUT 51
#define PP_STANDALONE 52
#define PP_STANDARD 53
#define PP_STRICT 54
#define PP_TEST 55
#define PP_TEXT 56
#define PP_TRANSITION 57
#define PP_TRUNCATE 58
#define PP_UNDEF 59
#define PP_VENDOR 60
#define PP_WARN 61
#define PP_comment (1<<0)
#define PP_compatibility (1<<1)
#define PP_hosted (1<<2)
#define PP_linebase (1<<3)
#define PP_linefile (1<<4)
#define PP_linehosted (1<<5)
#define PP_lineignore (1<<6)
#define PP_linetype (1<<7)
#define PP_strict (1<<8)
#define PP_transition (1<<9)
#define PP_deps (1<<0)
#define PP_deps_file (1<<1)
#define PP_deps_generated (1<<2)
#define PP_deps_local (1<<3)
#define PP_sync 0
#define PP_sync_push '1'
#define PP_sync_pop '2'
#define PP_sync_ignore '3'
#define PP_sync_hosted '3'
#define PP_SYNC_PUSH (1<<0)
#define PP_SYNC_POP (1<<1)
#define PP_SYNC_IGNORE (1<<2)
#define PP_SYNC_HOSTED (1<<3)
#define PP_SYNC_INSERT (1<<4)
#define N_PP 0401
#define N_NUMBER 0440
#define N_TEST (N_NUMBER|07700)
#define N_TOKEN 0500
#define N_WIDE 1
#define ppisnumber(x) (((x)&N_TEST)==N_NUMBER)
#define ppisinteger(x) (((x)&(N_TEST|N_REAL))==N_NUMBER)
#define ppisreal(x) (((x)&(N_TEST|N_REAL))==(N_NUMBER|N_REAL))
#define ppisassignop(x) (((x)>=T_MPYEQ)&&((x)<=T_OREQ))
#define ppisseparate(x) (((x)>=N_PP)&&((x)<=T_WSTRING)||((x)>=N_NUMBER)||((x)=='+')||((x)=='-'))
#define N_LONG 0001
#define N_UNSIGNED 0002
#define N_FLOAT 0002
#define N_REAL 0004
#define N_OCTAL 0010
#define N_HEXADECIMAL 0020
#define N_EXPONENT 010000
#define N_SIGN 020000
#define N_TRAILING 040000
#if !defined(T_DOUBLE)
#define T_DOUBLE (N_NUMBER|N_REAL)
#define T_DOUBLE_L (N_NUMBER|N_REAL|N_LONG)
#define T_FLOAT (N_NUMBER|N_REAL|N_FLOAT)
#define T_DECIMAL (N_NUMBER)
#define T_DECIMAL_L (N_NUMBER|N_LONG)
#define T_DECIMAL_U (N_NUMBER|N_UNSIGNED)
#define T_DECIMAL_UL (N_NUMBER|N_UNSIGNED|N_LONG)
#define T_OCTAL (N_NUMBER|N_OCTAL)
#define T_OCTAL_L (N_NUMBER|N_OCTAL|N_LONG)
#define T_OCTAL_U (N_NUMBER|N_OCTAL|N_UNSIGNED)
#define T_OCTAL_UL (N_NUMBER|N_OCTAL|N_UNSIGNED|N_LONG)
#define T_HEXADECIMAL (N_NUMBER|N_HEXADECIMAL)
#define T_HEXADECIMAL_L (N_NUMBER|N_HEXADECIMAL|N_LONG)
#define T_HEXADECIMAL_U (N_NUMBER|N_HEXADECIMAL|N_UNSIGNED)
#define T_HEXADECIMAL_UL (N_NUMBER|N_HEXADECIMAL|N_UNSIGNED|N_LONG)
#define T_HEXDOUBLE (N_NUMBER|N_HEXADECIMAL|N_REAL)
#define T_HEXDOUBLE_L (N_NUMBER|N_HEXADECIMAL|N_REAL|N_LONG)
#define T_ID (N_PP+0)
#define T_INVALID (N_PP+1)
#define T_HEADER (N_PP+2)
#define T_CHARCONST (N_PP+3)
#define T_WCHARCONST (T_CHARCONST|N_WIDE)
#define T_STRING (N_PP+5)
#define T_WSTRING (T_STRING|N_WIDE)
#define T_PTRMEM (N_PP+7)
#define T_ADDADD (N_PP+8)
#define T_SUBSUB (N_PP+9)
#define T_LSHIFT (N_PP+10)
#define T_RSHIFT (N_PP+11)
#define T_LE (N_PP+12)
#define T_GE (N_PP+13)
#define T_EQ (N_PP+14)
#define T_NE (N_PP+15)
#define T_ANDAND (N_PP+16)
#define T_OROR (N_PP+17)
#define T_MPYEQ (N_PP+18)
#define T_DIVEQ (N_PP+19)
#define T_MODEQ (N_PP+20)
#define T_ADDEQ (N_PP+21)
#define T_SUBEQ (N_PP+22)
#define T_LSHIFTEQ (N_PP+23)
#define T_RSHIFTEQ (N_PP+24)
#define T_ANDEQ (N_PP+25)
#define T_XOREQ (N_PP+26)
#define T_OREQ (N_PP+27)
#define T_TOKCAT (N_PP+28)
#define T_VARIADIC (N_PP+29)
#define T_DOTREF (N_TOKEN+0)
#define T_PTRMEMREF (N_TOKEN+1)
#define T_SCOPE (N_TOKEN+2)
#define T_UMINUS (N_TOKEN+3)
#endif
#define T_TOKEN (N_TOKEN+4)
struct ppdirs
{
char* name;
struct ppdirs* next;
#ifdef _PP_DIRS_PRIVATE_
_PP_DIRS_PRIVATE_
#endif
};
struct ppkeyword
{
char* name;
int value;
};
struct ppmacro
{
int arity;
char* value;
#ifdef _PP_MACRO_PRIVATE_
_PP_MACRO_PRIVATE_
#endif
};
struct ppsymbol
{
HASH_HEADER;
unsigned long flags;
struct ppmacro* macro;
void* value;
#ifdef _PP_SYMBOL_PRIVATE_
_PP_SYMBOL_PRIVATE_
#endif
};
#define _PP_CONTEXT_BASE_ ((char*)&pp.lcldirs)
#define _PP_CONTEXT_PUBLIC_ \
struct ppdirs* lcldirs; \
struct ppdirs* stddirs; \
int flags; \
Hash_table_t* symtab;
struct ppglobals
{
const char* version;
char* lineid;
char* outfile;
char* pass;
char* token;
struct ppsymbol* symbol;
char* outb;
char* outbuf;
char* outp;
char* oute;
unsigned long offset;
#ifdef _PP_CONTEXT_PUBLIC_
_PP_CONTEXT_PUBLIC_
#endif
#ifdef _PP_CONTEXT_PRIVATE_
_PP_CONTEXT_PRIVATE_
#endif
#ifdef _PP_GLOBALS_PRIVATE_
_PP_GLOBALS_PRIVATE_
#endif
};
#define ppctype _pp_ctype
extern struct ppglobals pp;
extern char ppctype[];
extern int ppargs(char**, int);
extern void ppcpp(void);
extern void ppcomment(char*, char*, char*, int);
extern void* ppcontext(void*, int);
extern void pperror(int, ...);
extern void ppincref(char*, char*, int, int);
extern void ppinput(char*, char*, int);
extern int pplex(void);
extern void ppline(int, char*);
extern void ppmacref(struct ppsymbol*, char*, int, int, unsigned long);
extern void ppop(int, ...);
extern void pppragma(char*, char*, char*, char*, int);
extern int ppprintf(char*, ...);
extern int ppsync(void);
#endif