2 * Copyright 1998 Bertho A. Stultiens (BS)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef __WRC_PREPROC_H
20 #define __WRC_PREPROC_H
22 struct pp_entry
; /* forward */
25 * A stack of files which are already included and
26 * are protected in the #ifndef/#endif way.
28 typedef struct includelogicentry
{
29 struct includelogicentry
*next
;
30 struct includelogicentry
*prev
;
31 struct pp_entry
*ppp
; /* The define which protects the file */
32 char *filename
; /* The filename of the include */
33 } includelogicentry_t
;
36 * The arguments of a macrodefinition
44 def_arg_t type
; /* Normal or ... argument */
45 char *arg
; /* The textual argument */
46 int nnl
; /* Number of newlines in the text to subst */
50 * The expansiontext of a macro
53 exp_text
, /* Simple text substitution */
54 exp_concat
, /* Concat (##) operator requested */
55 exp_stringize
, /* Stringize (#) operator requested */
56 exp_subst
/* Substitute argument */
59 typedef struct mtext
{
65 int argidx
; /* For exp_subst and exp_stringize reference */
70 * The define descriptor
73 def_none
, /* Not-a-define; used as return value */
74 def_define
, /* Simple defines */
75 def_macro
, /* Macro defines */
76 def_special
/* Special expansions like __LINE__ and __FILE__ */
79 typedef struct pp_entry
{
80 struct pp_entry
*next
;
81 struct pp_entry
*prev
;
82 def_type_t type
; /* Define or macro */
83 char *ident
; /* The key */
84 marg_t
**margs
; /* Macro arguments array or NULL if none */
87 mtext_t
*mtext
; /* The substitution sequence or NULL if none */
90 int expanding
; /* Set when feeding substitution into the input */
91 char *filename
; /* Filename where it was defined */
92 int linenumber
; /* Linenumber where it was defined */
93 includelogicentry_t
*iep
; /* Points to the include it protects */
100 #define MAXIFSTACK 64 /* If this isn't enough you should alter the source... */
112 * I assume that 'long long' exists in the compiler when it has a size
113 * of 8 or bigger. If not, then we revert to a simple 'long' for now.
114 * This should prevent most unexpected things with other compilers than
115 * gcc and egcs for now.
116 * In the future it should be possible to use another way, like a
117 * structure, so that we can emulate the MS compiler.
119 #if defined(SIZEOF_LONGLONG) && SIZEOF_LONGLONG >= 8
120 typedef long long wrc_sll_t
;
121 typedef unsigned long long wrc_ull_t
;
123 typedef long wrc_sll_t
;
124 typedef unsigned long wrc_ull_t
;
131 #define SIZE_LONGLONG 5
132 #define SIZE_MASK 0x00ff
133 #define FLAG_SIGNED 0x0100
137 cv_schar
= SIZE_CHAR
+ FLAG_SIGNED
,
138 cv_uchar
= SIZE_CHAR
,
139 cv_sshort
= SIZE_SHORT
+ FLAG_SIGNED
,
140 cv_ushort
= SIZE_SHORT
,
142 cv_sint
= SIZE_INT
+ FLAG_SIGNED
,
144 cv_slong
= SIZE_LONG
+ FLAG_SIGNED
,
145 cv_ulong
= SIZE_LONG
,
146 cv_sll
= SIZE_LONGLONG
+ FLAG_SIGNED
,
147 cv_ull
= SIZE_LONGLONG
150 typedef struct cval
{
154 signed char sc
; /* Explicitely signed because compilers are stupid */
170 pp_entry_t
*pplookup(char *ident
);
171 pp_entry_t
*add_define(char *def
, char *text
);
172 pp_entry_t
*add_cmdline_define(char *set
);
173 pp_entry_t
*add_special_define(char *id
);
174 pp_entry_t
*add_macro(char *ident
, marg_t
*args
[], int nargs
, mtext_t
*exp
);
175 void del_define(char *name
);
176 FILE *open_include(const char *name
, int search
, char **newpath
);
177 void add_include_path(char *path
);
178 void push_if(if_state_t s
);
179 void next_if_state(int);
180 if_state_t
pop_if(void);
181 if_state_t
if_state(void);
182 int get_if_depth(void);
190 extern int pp_flex_debug
;
193 void do_include(char *fname
, int type
);
194 void push_ignore_state(void);
195 void pop_ignore_state(void);
197 extern int include_state
;
198 extern char *include_ppp
;
199 extern char *include_filename
;
200 extern int include_ifdepth
;
201 extern int seen_junk
;
202 extern includelogicentry_t
*includelogiclist
;