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.
8 (* ---------------------------------------------------------------------- *)
9 type program2
= toplevel2 list
10 and toplevel2
= Ast_c.toplevel
* info_item
12 (* the token list contains now also the comment-tokens *)
13 and info_item
= (string * Parser_c.token list
)
15 (* ---------------------------------------------------------------------- *)
17 val parse_cpp_define_file
:
18 filename
-> (string, Cpp_token_c.define_def
) assoc
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
25 val init_defs_macros
: filename
-> unit
26 val init_defs_builtins
: filename
-> unit
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 *)
35 filename
(*cfile*) -> (program2
* Parsing_stat.parsing_stat
)
37 (* use some .ast_raw memoized version, and take care if obsolete *)
39 filename
(*cfile*) -> (program2
* Parsing_stat.parsing_stat
)
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
46 val parse
: filename
-> Ast_c.program
47 val parse_print_error
: filename
-> Ast_c.program
49 ((Lexing.lexbuf
-> Parser_c.token
) -> Lexing.lexbuf
-> 'a
) -> string -> 'a
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.
57 val type_of_string
: string -> Ast_c.fullType
58 val statement_of_string
: string -> Ast_c.statement
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
67 (* ---------------------------------------------------------------------- *)
69 val print_commentized
: Parser_c.token list
-> unit
71 val program_of_program2
: program2
-> Ast_c.program
72 val with_program2
: (Ast_c.program
-> Ast_c.program
) -> program2
-> program2