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