Release coccinelle-0.2.3rc2
[bpt/coccinelle.git] / parsing_c / parse_c.mli
1 (* The main function is parse_c_and_cpp. It uses globals in Lexer_Parser and
2 * and also _defs below which often comes from a standard.h macro file.
3 * cf also init_defs_xxx below.
4 *)
5
6 type program2 = toplevel2 list
7 and toplevel2 = Ast_c.toplevel * info_item
8 (* the token list contains now also the comment-tokens *)
9 and info_item = (string * Parser_c.token list)
10
11 (* usually correspond to what is inside your macros.h *)
12 val _defs : (string, Cpp_token_c.define_def) Hashtbl.t ref
13 (* usually correspond to what is inside your standard.h *)
14 val _defs_builtins : (string, Cpp_token_c.define_def) Hashtbl.t ref
15
16 val init_defs_macros : Common.filename -> unit
17 val init_defs_builtins : Common.filename -> unit
18
19
20 (* This is the main function *)
21 val parse_c_and_cpp :
22 Common.filename (*cfile*) -> (program2 * Parsing_stat.parsing_stat)
23
24 (* use some .ast_raw memoized version, and take care if obsolete *)
25 val parse_cache:
26 Common.filename (*cfile*) -> (program2 * Parsing_stat.parsing_stat)
27
28
29 (* ---------------------------------------------------------------------- *)
30 (* used to extract macros from standard.h, but also now from regular C files
31 * in -extract_macros to later feed an automatically build standard.h *)
32 val extract_macros :
33 Common.filename -> (string, Cpp_token_c.define_def) Common.assoc
34
35
36
37
38
39 (* ---------------------------------------------------------------------- *)
40 (* used also for the standard.h file *)
41 val tokens: ?profile:bool -> Common.filename -> Parser_c.token list
42 val tokens_of_string: string -> Parser_c.token list
43
44 val parse: Common.filename -> Ast_c.program
45 val parse_print_error: Common.filename -> Ast_c.program
46 val parse_gen:
47 ((Lexing.lexbuf -> Parser_c.token) -> Lexing.lexbuf -> 'a) -> string -> 'a
48
49 (* ---------------------------------------------------------------------- *)
50 (* Easy way to build complex Ast elements from simple strings.
51 * Can also be useful when called from the ocaml toplevel to test.
52 *)
53 val type_of_string : string -> Ast_c.fullType
54 val statement_of_string : string -> Ast_c.statement
55
56 (* similar but use parse_c_and_cpp and a /tmp/__cocci.c and extract the part *)
57 val cstatement_of_string : string -> Ast_c.statement
58 val cexpression_of_string : string -> Ast_c.expression
59
60
61 (* ---------------------------------------------------------------------- *)
62 (* a few helpers *)
63 val print_commentized : Parser_c.token list -> unit
64
65 val program_of_program2 : program2 -> Ast_c.program
66 val with_program2: (Ast_c.program -> Ast_c.program) -> program2 -> program2