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.
6 type program2
= toplevel2 list
7 and extended_program2
= toplevel2 list
*
8 (string, Lexer_parser.identkind
) Common.scoped_h_env
(* type defs *) *
9 (string, Cpp_token_c.define_def
) Hashtbl.t
(* macro defs *)
11 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 (* usually correspond to what is inside your macros.h *)
16 val _defs
: (string, Cpp_token_c.define_def
) Hashtbl.t
ref
17 (* usually correspond to what is inside your standard.h *)
18 val _defs_builtins
: (string, Cpp_token_c.define_def
) Hashtbl.t
ref
20 val init_defs_macros
: Common.filename
-> unit
21 val init_defs_builtins
: Common.filename
-> unit
24 (* This is the main function *)
26 Common.filename
(*cfile*) -> (program2
* Parsing_stat.parsing_stat
)
27 val parse_c_and_cpp_keep_typedefs
:
28 (string, Lexer_parser.identkind
) Common.scoped_h_env
option (*typedefs*) ->
29 (string, Cpp_token_c.define_def
) Hashtbl.t
option (* macro defs *) ->
30 Common.filename
(*cfile*) ->
31 (extended_program2
* Parsing_stat.parsing_stat
)
33 (* use some .ast_raw memoized version, and take care if obsolete *)
35 Common.filename
(*cfile*) -> (extended_program2
* Parsing_stat.parsing_stat
)
38 (* ---------------------------------------------------------------------- *)
39 (* used to extract macros from standard.h, but also now from regular C files
40 * in -extract_macros to later feed an automatically build standard.h *)
42 Common.filename
-> (string, Cpp_token_c.define_def
) Common.assoc
48 (* ---------------------------------------------------------------------- *)
49 (* used also for the standard.h file *)
50 val tokens
: ?profile
:bool -> Common.filename
-> Parser_c.token list
51 val tokens_of_string
: string -> Parser_c.token list
53 val parse
: Common.filename
-> Ast_c.program
54 val parse_print_error
: Common.filename
-> Ast_c.program
56 ((Lexing.lexbuf
-> Parser_c.token
) -> Lexing.lexbuf
-> 'a
) -> string -> 'a
58 (* ---------------------------------------------------------------------- *)
59 (* Easy way to build complex Ast elements from simple strings.
60 * Can also be useful when called from the ocaml toplevel to test.
62 val type_of_string
: string -> Ast_c.fullType
63 val statement_of_string
: string -> Ast_c.statement
65 (* similar but use parse_c_and_cpp and a /tmp/__cocci.c and extract the part *)
66 val cstatement_of_string
: string -> Ast_c.statement
67 val cexpression_of_string
: string -> Ast_c.expression
70 (* ---------------------------------------------------------------------- *)
72 val print_commentized
: Parser_c.token list
-> unit
74 val program_of_program2
: program2
-> Ast_c.program
75 val with_program2
: (Ast_c.program
-> Ast_c.program
) -> program2
-> program2