3897a4794e16ee6bb44cf362c76ded3aa9a8ee20
3 (* Try detect some cpp idioms so can parse as is files by adjusting or
4 * commenting some tokens. Parsing hack style. Sometime use indentation info,
5 * Sometimes do some kind of lalr(k) by finding patterns. Often try to
6 * work on better token representation, like ifdef-paren-ized, brace-ized,
7 * paren-ized, so can do easier pattern matching to more easily match
8 * complex cpp idiom pattern. Also try to get context info such as
9 * whether the token is in a initializer as some common patterns have different
10 * use depending on context.
13 * Example of cpp idioms:
14 * - if 0 for commenting stuff (not always code, sometimes just real comments)
17 * - ifdef statements, ifdef expression, ifdef-mid
18 * - macro toplevel (with or without ptvirg)
20 * - macro higher order
24 * - macro string, and macro function string taking param and ##
26 * Cf the TMacroXxx in parser_c.mly and MacroXxx in ast_c.ml
28 * Also try infer typedef.
30 * Also do other stuff involving cpp like expanding some macros,
31 * or try parse well define body by finding the end of define virtual
35 (* the either is to differentialte macro-variables from macro-functions *)
36 type define_body
= (unit,string list
) either
* Parser_c.token list
38 val _defs
: (string, define_body
) Hashtbl.t
ref
41 val fix_tokens_define
: Parser_c.token list
-> Parser_c.token list
42 val extract_cpp_define
: Parser_c.token list
-> (string, define_body
) assoc
45 val fix_tokens_cpp
: Parser_c.token list
-> Parser_c.token list
47 (* next stream tokens -> passed stream tokens -> final next token *)
48 val lookahead
: Parser_c.token list
-> Parser_c.token list
-> Parser_c.token