3 (* This module tries to detect some cpp idioms so that we can parse as-is
4 * files by adjusting or commenting some tokens. Parsing hack style.
5 * Sometime we use some indentation information,
6 * sometimes we do some kind of lalr(k) by finding patterns. Often try to
7 * work on better token representation, like ifdef-paren-ized, brace-ized,
8 * paren-ized, so can do easier pattern matching to more easily match
9 * complex cpp idiom pattern (cf token_views_c.ml).
10 * We also try to get more contextual information such as whether the
11 * token is in a initializer as some common patterns have different
12 * use depending on context.
15 * Example of cpp idioms:
16 * - if 0 for commenting stuff (not always code, sometimes just real comments)
19 * - ifdef statements, ifdef expression, ifdef-mid
20 * - macro toplevel (with or without ptvirg)
22 * - macro higher order
26 * - macro string, and macro function string taking param and ##
29 * Cf the TMacroXxx in parser_c.mly and MacroXxx in ast_c.ml
31 * Also try to infer typedef.
33 * Also do other stuff involving cpp like expanding some macros,
34 * or try parse well define body by finding the end of define virtual
35 * end-of-line token. But now most of the code is actually in cpp_token_c.ml
36 * It is related to what is in the yacfe configuration file (e.g. standard.h)
39 val regexp_macro
: Str.regexp
40 val regexp_annot
: Str.regexp
41 val regexp_declare
: Str.regexp
42 val regexp_foreach
: Str.regexp
43 val regexp_typedef
: Str.regexp
45 (* can reset this global *)
46 val ifdef_paren_cnt
: int ref
48 val filter_cpp_stuff
:
49 Token_views_c.token_extended list
-> Token_views_c.token_extended list
50 val insert_virtual_positions
:
51 Parser_c.token list
-> Parser_c.token list
54 macro_defs
:(string, Cpp_token_c.define_def
) Hashtbl.t
->
55 Parser_c.token list
-> Parser_c.token list
57 (* next stream tokens -> passed stream tokens -> final next token *)
60 Parser_c.token list
-> Parser_c.token list
-> Parser_c.token