Release coccinelle-0.1.8
[bpt/coccinelle.git] / parsing_c / parse_c.mli
CommitLineData
34e49164
C
1open 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
485bce71 8(* ---------------------------------------------------------------------- *)
34e49164 9type program2 = toplevel2 list
485bce71 10 and toplevel2 = Ast_c.toplevel * info_item
34e49164 11
485bce71
C
12 (* the token list contains now also the comment-tokens *)
13 and info_item = (string * Parser_c.token list)
34e49164 14
708f4980
C
15(* ---------------------------------------------------------------------- *)
16(* a few globals *)
17val parse_cpp_define_file :
18 filename -> (string, Cpp_token_c.define_def) assoc
19
20(* usually correspond to what is inside your macros.h *)
21val _defs : (string, Cpp_token_c.define_def) Hashtbl.t ref
22(* usually correspond to what is inside your standard.h *)
23val _defs_builtins : (string, Cpp_token_c.define_def) Hashtbl.t ref
24
25val init_defs_macros : filename -> unit
26val init_defs_builtins : filename -> unit
27
28
485bce71 29(* ---------------------------------------------------------------------- *)
34e49164
C
30(* This is the main function *)
31val parse_print_error_heuristic:
485bce71
C
32 filename (*cfile*) -> (program2 * Parsing_stat.parsing_stat)
33(* alias of previous func *)
34val parse_c_and_cpp :
35 filename (*cfile*) -> (program2 * Parsing_stat.parsing_stat)
34e49164 36
485bce71
C
37(* use some .ast_raw memoized version, and take care if obsolete *)
38val parse_cache:
39 filename (*cfile*) -> (program2 * Parsing_stat.parsing_stat)
40
485bce71
C
41(* ---------------------------------------------------------------------- *)
42(* used also for the standard.h file *)
43val tokens: ?profile:bool -> filename -> Parser_c.token list
44val tokens_of_string: string -> Parser_c.token list
34e49164
C
45
46val parse: filename -> Ast_c.program
47val parse_print_error: filename -> Ast_c.program
48val parse_gen:
49 ((Lexing.lexbuf -> Parser_c.token) -> Lexing.lexbuf -> 'a) -> string -> 'a
50
485bce71
C
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 *)
34e49164
C
57val type_of_string : string -> Ast_c.fullType
58val statement_of_string : string -> Ast_c.statement
91eba41f 59
485bce71
C
60(* similar but use parse_c_and_cpp and a /tmp/__cocci.c and extract the part *)
61val cstatement_of_string : string -> Ast_c.statement
62val cexpression_of_string : string -> Ast_c.expression
63
34e49164
C
64
65
34e49164 66
485bce71
C
67(* ---------------------------------------------------------------------- *)
68(* a few helpers *)
91eba41f
C
69val print_commentized : Parser_c.token list -> unit
70
485bce71
C
71val program_of_program2 : program2 -> Ast_c.program
72val with_program2: (Ast_c.program -> Ast_c.program) -> program2 -> program2
34e49164 73
34e49164
C
74
75