1 /****************************************************************************
3 ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
4 ** Copyright 2005 Roberto Raggi <roberto@kdevelop.org>
6 ** This file is part of $PRODUCT$.
10 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 ****************************************************************************/
34 inline bool is_ulong () const { return kind
== Kind_ULong
; }
36 inline void set_ulong (unsigned long v
)
42 inline void set_long (long v
)
48 inline bool is_zero () const { return l
== 0; }
50 #define PP_DEFINE_BIN_OP(name, op) \
51 inline Value &name (const Value &other) \
53 if (is_ulong () || other.is_ulong ()) \
54 set_ulong (ul op other.ul); \
56 set_long (l op other.l); \
60 PP_DEFINE_BIN_OP(op_add
, +)
61 PP_DEFINE_BIN_OP(op_sub
, -)
62 PP_DEFINE_BIN_OP(op_mult
, *)
63 PP_DEFINE_BIN_OP(op_div
, /)
64 PP_DEFINE_BIN_OP(op_mod
, %)
65 PP_DEFINE_BIN_OP(op_lhs
, <<)
66 PP_DEFINE_BIN_OP(op_rhs
, >>)
67 PP_DEFINE_BIN_OP(op_lt
, <)
68 PP_DEFINE_BIN_OP(op_gt
, >)
69 PP_DEFINE_BIN_OP(op_le
, <=)
70 PP_DEFINE_BIN_OP(op_ge
, >=)
71 PP_DEFINE_BIN_OP(op_eq
, ==)
72 PP_DEFINE_BIN_OP(op_ne
, !=)
73 PP_DEFINE_BIN_OP(op_bit_and
, &)
74 PP_DEFINE_BIN_OP(op_bit_or
, |)
75 PP_DEFINE_BIN_OP(op_bit_xor
, ^)
76 PP_DEFINE_BIN_OP(op_and
, &&)
77 PP_DEFINE_BIN_OP(op_or
, ||)
79 #undef PP_DEFINE_BIN_OP
85 pp_macro_expander expand
;
86 pp_skip_identifier skip_identifier
;
87 pp_skip_comment_or_divop skip_comment_or_divop
;
88 pp_skip_blanks skip_blanks
;
89 pp_skip_number skip_number
;
90 std::vector
<std::string
> include_paths
;
91 std::string _M_current_text
;
93 enum { MAX_LEVEL
= 512 };
94 int _M_skipping
[MAX_LEVEL
];
95 int _M_true_test
[MAX_LEVEL
];
101 unsigned long token_uvalue
;
102 std::string
*token_text
;
127 enum PP_DIRECTIVE_TYPE
129 PP_UNKNOWN_DIRECTIVE
,
145 pp (pp_environment
&__env
);
147 inline std::back_insert_iterator
<std::vector
<std::string
> > include_paths_inserter ();
149 inline void push_include_path (std::string
const &__path
);
151 inline std::vector
<std::string
>::iterator
include_paths_begin ();
152 inline std::vector
<std::string
>::iterator
include_paths_end ();
154 inline std::vector
<std::string
>::const_iterator
include_paths_begin () const;
155 inline std::vector
<std::string
>::const_iterator
include_paths_end () const;
157 template <typename _InputIterator
>
158 inline _InputIterator
eval_expression (_InputIterator __first
, _InputIterator __last
, Value
*result
);
160 template <typename _OutputIterator
>
161 void file (std::string
const &filename
, _OutputIterator __result
);
163 template <typename _OutputIterator
>
164 void file (FILE *fp
, _OutputIterator __result
);
166 template <typename _InputIterator
, typename _OutputIterator
>
167 void operator () (_InputIterator __first
, _InputIterator __last
, _OutputIterator __result
);
170 inline bool file_isdir (std::string
const &__filename
) const;
171 inline bool file_exists (std::string
const &__filename
) const;
172 FILE *find_include_file (std::string
const &__filename
, std::string
*__filepath
,
173 INCLUDE_POLICY __include_policy
, bool __skip_current_path
= false) const;
175 inline int skipping() const;
176 bool test_if_level();
178 inline std::string
fix_file_path (std::string
const &filename
) const;
179 inline bool is_absolute (std::string
const &filename
) const;
181 PP_DIRECTIVE_TYPE
find_directive (char const *__directive
, std::size_t __size
) const;
183 template <typename _InputIterator
>
184 bool find_header_protection (_InputIterator __first
, _InputIterator __last
, std::string
*__prot
);
186 template <typename _InputIterator
>
187 _InputIterator
skip (_InputIterator __first
, _InputIterator __last
);
189 template <typename _InputIterator
>
190 _InputIterator
eval_primary(_InputIterator __first
, _InputIterator __last
, Value
*result
);
192 template <typename _InputIterator
>
193 _InputIterator
eval_multiplicative(_InputIterator __first
, _InputIterator __last
, Value
*result
);
195 template <typename _InputIterator
>
196 _InputIterator
eval_additive(_InputIterator __first
, _InputIterator __last
, Value
*result
);
198 template <typename _InputIterator
>
199 _InputIterator
eval_shift(_InputIterator __first
, _InputIterator __last
, Value
*result
);
201 template <typename _InputIterator
>
202 _InputIterator
eval_relational(_InputIterator __first
, _InputIterator __last
, Value
*result
);
204 template <typename _InputIterator
>
205 _InputIterator
eval_equality(_InputIterator __first
, _InputIterator __last
, Value
*result
);
207 template <typename _InputIterator
>
208 _InputIterator
eval_and(_InputIterator __first
, _InputIterator __last
, Value
*result
);
210 template <typename _InputIterator
>
211 _InputIterator
eval_xor(_InputIterator __first
, _InputIterator __last
, Value
*result
);
213 template <typename _InputIterator
>
214 _InputIterator
eval_or(_InputIterator __first
, _InputIterator __last
, Value
*result
);
216 template <typename _InputIterator
>
217 _InputIterator
eval_logical_and(_InputIterator __first
, _InputIterator __last
, Value
*result
);
219 template <typename _InputIterator
>
220 _InputIterator
eval_logical_or(_InputIterator __first
, _InputIterator __last
, Value
*result
);
222 template <typename _InputIterator
>
223 _InputIterator
eval_constant_expression(_InputIterator __first
, _InputIterator __last
, Value
*result
);
225 template <typename _InputIterator
, typename _OutputIterator
>
226 _InputIterator
handle_directive(char const *__directive
, std::size_t __size
,
227 _InputIterator __first
, _InputIterator __last
, _OutputIterator __result
);
229 template <typename _InputIterator
, typename _OutputIterator
>
230 _InputIterator
handle_include(bool skip_current_path
, _InputIterator __first
, _InputIterator __last
,
231 _OutputIterator __result
);
233 template <typename _InputIterator
>
234 _InputIterator
handle_define (_InputIterator __first
, _InputIterator __last
);
236 template <typename _InputIterator
>
237 _InputIterator
handle_if (_InputIterator __first
, _InputIterator __last
);
239 template <typename _InputIterator
>
240 _InputIterator
handle_else (_InputIterator __first
, _InputIterator __last
);
242 template <typename _InputIterator
>
243 _InputIterator
handle_elif (_InputIterator __first
, _InputIterator __last
);
245 template <typename _InputIterator
>
246 _InputIterator
handle_endif (_InputIterator __first
, _InputIterator __last
);
248 template <typename _InputIterator
>
249 _InputIterator
handle_ifdef (bool check_undefined
, _InputIterator __first
, _InputIterator __last
);
251 template <typename _InputIterator
>
252 _InputIterator
handle_undef(_InputIterator __first
, _InputIterator __last
);
254 template <typename _InputIterator
>
255 inline char peek_char (_InputIterator __first
, _InputIterator __last
);
257 template <typename _InputIterator
>
258 _InputIterator
next_token (_InputIterator __first
, _InputIterator __last
, int *kind
);
263 #endif // PP_ENGINE_H
265 // kate: space-indent on; indent-width 2; replace-tabs on;