Bump for 3.6-28
[LibreOffice.git] / soltools / cpp / cpp.h
blobb85d28e0584e62c3988efdc1d0f74d6ba943e30c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* $Id: cpp.h,v 1.4 2006-06-20 05:07:28 hr Exp $ */
4 #define INS 32768 /* input buffer */
5 #define OBS 8092 /* outbut buffer */
6 #define NARG 32 /* Max number arguments to a macro */
7 #define NINCLUDE 48 /* Max number of include directories (-I) */
8 #define NIF 64 /* depth of nesting of #if */
9 #define NINC 32 /* depth of nesting of #include */
11 #ifndef EOF
12 #define EOF (-1)
13 #endif
15 #ifndef NULL
16 #define NULL 0
17 #endif
19 typedef unsigned char uchar;
21 enum toktype
23 END, UNCLASS, NAME, NUMBER, STRING, CCON, NL, WS, DSHARP,
24 EQ, NEQ, LEQ, GEQ, LSH, RSH, LAND, LOR, PPLUS, MMINUS,
25 ARROW, SBRA, SKET, LP, RP, DOT, AND, STAR, PLUS, MINUS,
26 TILDE, NOT, SLASH, PCT, LT, GT, CIRC, OR, QUEST,
27 COLON, ASGN, COMMA, SHARP, SEMIC, CBRA, CKET,
28 ASPLUS, ASMINUS, ASSTAR, ASSLASH, ASPCT, ASCIRC, ASLSH,
29 ASRSH, ASOR, ASAND, ELLIPS,
30 DSHARP1, NAME1, NAME2, DEFINED, UMINUS, ARCHITECTURE, IDENT,
31 COMMENT
34 enum kwtype
36 KIF, KIFDEF, KIFNDEF, KELIF, KELSE, KENDIF, KINCLUDE, KINCLUDENEXT,
37 KIMPORT, KDEFINE, KUNDEF, KLINE, KERROR, KPRAGMA, KIDENT, KDEFINED,
38 KMACHINE, KLINENO, KFILE, KDATE, KTIME, KSTDC, KEVAL
41 #define ISDEFINED 0x01 /* has #defined value */
42 #define ISKW 0x02 /* is PP keyword */
43 #define ISUNCHANGE 0x04 /* can't be #defined in PP */
44 #define ISMAC 0x08 /* builtin macro, e.g. __LINE__ */
45 #define ISARCHITECTURE 0x10 /* architecture */
46 #define ISACTIVE 0x80 /* is macro currently expanded */
48 #define EOB 0xFE /* sentinel for end of input buffer */
49 #define EOFC 0xFD /* sentinel for end of input file */
50 #define XPWS 1 /* token flag: white space to assure token sep. */
51 #define XTWS 2
53 typedef struct token
55 unsigned char type;
56 unsigned char flag;
57 size_t wslen;
58 size_t len;
59 uchar *t;
60 unsigned int identifier; /* used from macro processor to identify where a macro becomes valid again. */
61 } Token;
63 typedef struct tokenrow
65 Token *tp; /* current one to scan */
66 Token *bp; /* base (allocated value) */
67 Token *lp; /* last+1 token used */
68 size_t max; /* number allocated */
69 } Tokenrow;
71 typedef struct source
73 char *filename; /* name of file of the source */
74 int line; /* current line number */
75 int lineinc; /* adjustment for \\n lines */
76 uchar *inb; /* input buffer */
77 uchar *inp; /* input pointer */
78 uchar *inl; /* end of input */
79 int fd; /* input source */
80 int ifdepth; /* conditional nesting in include */
81 int pathdepth;
82 int wrap;
83 struct source *next; /* stack for #include */
84 } Source;
86 typedef struct nlist
88 struct nlist *next;
89 uchar *name;
90 size_t len;
91 Tokenrow *vp; /* value as macro */
92 Tokenrow *ap; /* list of argument names, if any */
93 char val; /* value as preprocessor name */
94 char flag; /* is defined, is pp name */
95 uchar *loc; /* location of definition */
96 } Nlist;
98 typedef struct includelist
100 char deleted;
101 char always;
102 char *file;
103 } Includelist;
105 typedef struct wraplist
107 char *file;
108 } Wraplist;
110 #define new(t) (t *)domalloc(sizeof(t))
111 #define quicklook(a,b) (namebit[(a)&077] & (1<<((b)&037)))
112 #define quickset(a,b) namebit[(a)&077] |= (1<<((b)&037))
113 extern unsigned long namebit[077 + 1];
115 enum errtype
117 INFO, WARNING, ERROR, FATAL
121 typedef struct macroValidator
123 Nlist * pMacro;
124 unsigned int nTokenWhereMacroBecomesValid;
125 struct macroValidator *
126 pNext;
127 } MacroValidator;
128 typedef struct mvl
130 MacroValidator * pFirst;
131 unsigned int nextFreeIdentifier;
132 } MacroValidatorList;
134 void mvl_init(
135 MacroValidatorList *
136 out_pValidators);
137 void mvl_destruct(
138 MacroValidatorList *
139 out_pValidators);
140 /* Adds MacroValidator to the list.
142 void mvl_add(
143 MacroValidatorList *
144 inout_pValidators,
145 Nlist * in_pMacro,
146 Token * in_pTokenWhereMacroBecomesValid);
148 /* Checks if one of the validators within the list points to
149 the token in_pTokenToCheck. If so, the macro is set valid and
150 the validator is removed.
152 void mvl_check(
153 MacroValidatorList *
154 inout_pValidators,
155 Token * inout_pTokenToCheck);
157 void tokenrow_zeroTokenIdentifiers(Tokenrow* trp);
159 void expandlex(void);
160 void fixlex(void);
161 void setup(int, char **);
162 int gettokens(Tokenrow *, int);
163 int comparetokens(Tokenrow *, Tokenrow *);
164 Source *setsource(char *, int, int, char *, int);
165 void unsetsource(void);
166 void puttokens(Tokenrow *);
167 void process(Tokenrow *);
168 void *domalloc(size_t);
169 void dofree(void *);
170 void error(enum errtype, char *,...);
171 void flushout(void);
172 int fillbuf(Source *);
173 int trigraph(Source *);
174 int foldline(Source *);
175 Nlist *lookup(Token *, int);
176 void control(Tokenrow *);
177 void dodefine(Tokenrow *);
178 void doadefine(Tokenrow *, int);
179 void doinclude(Tokenrow *, int, int);
180 void doif(Tokenrow *, enum kwtype);
181 void expand(Tokenrow *, Nlist *, MacroValidatorList *);
182 void builtin(Tokenrow *, int);
183 int gatherargs(Tokenrow *, Tokenrow **, int *);
184 void substargs(Nlist *, Tokenrow *, Tokenrow **);
185 void expandrow(Tokenrow *, char *);
186 void maketokenrow(int, Tokenrow *);
187 Tokenrow *copytokenrow(Tokenrow *, Tokenrow *);
188 Token *growtokenrow(Tokenrow *);
189 Tokenrow *normtokenrow(Tokenrow *);
190 void adjustrow(Tokenrow *, int);
191 void movetokenrow(Tokenrow *, Tokenrow *);
192 void insertrow(Tokenrow *, int, Tokenrow *);
193 void peektokens(Tokenrow *, char *);
194 void doconcat(Tokenrow *);
195 Tokenrow *stringify(Tokenrow *);
196 int lookuparg(Nlist *, Token *);
197 long eval(Tokenrow *, int);
198 void genline(void);
199 void genimport(char *, int, char *, int);
200 void genwrap(int);
201 void setempty(Tokenrow *);
202 void makespace(Tokenrow *, Token *);
203 char *outnum(char *, int);
204 int digit(int);
205 uchar *newstring(uchar *, size_t, size_t);
207 #define rowlen(tokrow) ((tokrow)->lp - (tokrow)->bp)
209 extern char *outptr;
210 extern Token nltoken;
211 extern Source *cursource;
212 extern char *curtime;
213 extern int incdepth;
214 extern int ifdepth;
215 extern int ifsatisfied[NIF];
216 extern int Mflag;
217 extern int Iflag;
218 extern int Pflag;
219 extern int Aflag;
220 extern int Lflag;
221 extern int Xflag;
222 extern int Vflag;
223 extern int Cflag;
224 extern int Dflag;
225 extern int Cplusplus;
226 extern int skipping;
227 extern Nlist *kwdefined;
228 extern Includelist includelist[NINCLUDE];
229 extern Wraplist wraplist[NINCLUDE];
230 extern char wd[];
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */