2 * Copyright 1998 Bertho A. Stultiens (BS)
6 #ifndef __WRC_PREPROC_H
7 #define __WRC_PREPROC_H
9 struct pp_entry
; /* forward */
12 * A stack of files which are already included and
13 * are protected in the #ifndef/#endif way.
15 typedef struct includelogicentry
{
16 struct includelogicentry
*next
;
17 struct includelogicentry
*prev
;
18 struct pp_entry
*ppp
; /* The define which protects the file */
19 char *filename
; /* The filename of the include */
20 } includelogicentry_t
;
23 * The arguments of a macrodefinition
31 def_arg_t type
; /* Normal or ... argument */
32 char *arg
; /* The textual argument */
33 int nnl
; /* Number of newlines in the text to subst */
37 * The expansiontext of a macro
40 exp_text
, /* Simple text substitution */
41 exp_concat
, /* Concat (##) operator requested */
42 exp_stringize
, /* Stringize (#) operator requested */
43 exp_subst
/* Substitute argument */
46 typedef struct mtext
{
52 int argidx
; /* For exp_subst and exp_stringize reference */
57 * The define descriptor
60 def_none
, /* Not-a-define; used as return value */
61 def_define
, /* Simple defines */
62 def_macro
, /* Macro defines */
63 def_special
/* Special expansions like __LINE__ and __FILE__ */
66 typedef struct pp_entry
{
67 struct pp_entry
*next
;
68 struct pp_entry
*prev
;
69 def_type_t type
; /* Define or macro */
70 char *ident
; /* The key */
71 marg_t
**margs
; /* Macro arguments array or NULL if none */
74 mtext_t
*mtext
; /* The substitution sequence or NULL if none */
77 int expanding
; /* Set when feeding substitution into the input */
78 char *filename
; /* Filename where it was defined */
79 int linenumber
; /* Linenumber where it was defined */
80 includelogicentry_t
*iep
; /* Points to the include it protects */
87 #define MAXIFSTACK 64 /* If this isn't enough you should alter the source... */
99 * I assume that 'long long' exists in the compiler when it has a size
100 * of 8 or bigger. If not, then we revert to a simple 'long' for now.
101 * This should prevent most unexpected things with other compilers than
102 * gcc and egcs for now.
103 * In the future it should be possible to use another way, like a
104 * structure, so that we can emulate the MS compiler.
106 #if defined(SIZEOF_LONGLONG) && SIZEOF_LONGLONG >= 8
107 typedef long long wrc_sll_t
;
108 typedef unsigned long long wrc_ull_t
;
110 typedef long wrc_sll_t
;
111 typedef unsigned long wrc_ull_t
;
118 #define SIZE_LONGLONG 5
119 #define SIZE_MASK 0x00ff
120 #define FLAG_SIGNED 0x0100
124 cv_schar
= SIZE_CHAR
+ FLAG_SIGNED
,
125 cv_uchar
= SIZE_CHAR
,
126 cv_sshort
= SIZE_SHORT
+ FLAG_SIGNED
,
127 cv_ushort
= SIZE_SHORT
,
129 cv_sint
= SIZE_INT
+ FLAG_SIGNED
,
131 cv_slong
= SIZE_LONG
+ FLAG_SIGNED
,
132 cv_ulong
= SIZE_LONG
,
133 cv_sll
= SIZE_LONGLONG
+ FLAG_SIGNED
,
134 cv_ull
= SIZE_LONGLONG
137 typedef struct cval
{
141 signed char sc
; /* Explicitely signed because compilers are stupid */
157 pp_entry_t
*pplookup(char *ident
);
158 pp_entry_t
*add_define(char *def
, char *text
);
159 pp_entry_t
*add_cmdline_define(char *set
);
160 pp_entry_t
*add_special_define(char *id
);
161 pp_entry_t
*add_macro(char *ident
, marg_t
*args
[], int nargs
, mtext_t
*exp
);
162 void del_define(char *name
);
163 FILE *open_include(const char *name
, int search
, char **newpath
);
164 void add_include_path(char *path
);
165 void push_if(if_state_t s
);
166 void next_if_state(int);
167 if_state_t
pop_if(void);
168 if_state_t
if_state(void);
169 int get_if_depth(void);
177 extern int pp_flex_debug
;
180 void do_include(char *fname
, int type
);
181 void push_ignore_state(void);
182 void pop_ignore_state(void);
184 extern int include_state
;
185 extern char *include_ppp
;
186 extern char *include_filename
;
187 extern int include_ifdepth
;
188 extern int seen_junk
;
189 extern includelogicentry_t
*includelogiclist
;