8a6cc919ac342d62fdce6e33206c74a628b73b6b
[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 (* This is the main function *)
17 val parse_print_error_heuristic:
18 filename (*cfile*) -> (program2 * Parsing_stat.parsing_stat)
19 (* alias of previous func *)
20 val parse_c_and_cpp :
21 filename (*cfile*) -> (program2 * Parsing_stat.parsing_stat)
22
23 (* use some .ast_raw memoized version, and take care if obsolete *)
24 val parse_cache:
25 filename (*cfile*) -> (program2 * Parsing_stat.parsing_stat)
26
27
28 (* ---------------------------------------------------------------------- *)
29 val parse_cpp_define_file :
30 filename -> (string, Parsing_hacks.define_def) assoc
31
32 val init_defs : filename -> unit
33
34
35
36
37
38 (* ---------------------------------------------------------------------- *)
39 (* used also for the standard.h file *)
40 val tokens: ?profile:bool -> filename -> Parser_c.token list
41 val tokens_of_string: string -> Parser_c.token list
42
43 val parse: filename -> Ast_c.program
44 val parse_print_error: filename -> Ast_c.program
45 val parse_gen:
46 ((Lexing.lexbuf -> Parser_c.token) -> Lexing.lexbuf -> 'a) -> string -> 'a
47
48
49
50 (* ---------------------------------------------------------------------- *)
51 (* Easy way to build complex Ast elements from simple strings.
52 * Can also be useful when called from the ocaml toplevel to test.
53 *)
54 val type_of_string : string -> Ast_c.fullType
55 val statement_of_string : string -> Ast_c.statement
56
57 (* similar but use parse_c_and_cpp and a /tmp/__cocci.c and extract the part *)
58 val cstatement_of_string : string -> Ast_c.statement
59 val cexpression_of_string : string -> Ast_c.expression
60
61
62
63
64 (* ---------------------------------------------------------------------- *)
65 (* a few helpers *)
66 val print_commentized : Parser_c.token list -> unit
67
68 val program_of_program2 : program2 -> Ast_c.program
69 val with_program2: (Ast_c.program -> Ast_c.program) -> program2 -> program2
70
71
72