Commit | Line | Data |
---|---|---|
ae4735db C |
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. | |
978fd7e5 | 3 | * cf also init_defs_xxx below. |
34e49164 C |
4 | *) |
5 | ||
34e49164 | 6 | type program2 = toplevel2 list |
ca417fcf C |
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 *) | |
10 | and toplevel2 = | |
11 | Ast_c.toplevel * info_item | |
978fd7e5 C |
12 | (* the token list contains now also the comment-tokens *) |
13 | and info_item = (string * Parser_c.token list) | |
708f4980 C |
14 | |
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 | |
19 | ||
978fd7e5 C |
20 | val init_defs_macros : Common.filename -> unit |
21 | val init_defs_builtins : Common.filename -> unit | |
708f4980 C |
22 | |
23 | ||
34e49164 | 24 | (* This is the main function *) |
ae4735db | 25 | val parse_c_and_cpp : |
ca417fcf C |
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) | |
34e49164 | 32 | |
485bce71 C |
33 | (* use some .ast_raw memoized version, and take care if obsolete *) |
34 | val parse_cache: | |
ca417fcf | 35 | Common.filename (*cfile*) -> (extended_program2 * Parsing_stat.parsing_stat) |
978fd7e5 C |
36 | |
37 | ||
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 *) | |
ae4735db | 41 | val extract_macros : |
978fd7e5 C |
42 | Common.filename -> (string, Cpp_token_c.define_def) Common.assoc |
43 | ||
44 | ||
45 | ||
46 | ||
485bce71 | 47 | |
485bce71 C |
48 | (* ---------------------------------------------------------------------- *) |
49 | (* used also for the standard.h file *) | |
978fd7e5 | 50 | val tokens: ?profile:bool -> Common.filename -> Parser_c.token list |
485bce71 | 51 | val tokens_of_string: string -> Parser_c.token list |
34e49164 | 52 | |
978fd7e5 C |
53 | val parse: Common.filename -> Ast_c.program |
54 | val parse_print_error: Common.filename -> Ast_c.program | |
ae4735db | 55 | val parse_gen: |
34e49164 C |
56 | ((Lexing.lexbuf -> Parser_c.token) -> Lexing.lexbuf -> 'a) -> string -> 'a |
57 | ||
485bce71 C |
58 | (* ---------------------------------------------------------------------- *) |
59 | (* Easy way to build complex Ast elements from simple strings. | |
ae4735db | 60 | * Can also be useful when called from the ocaml toplevel to test. |
485bce71 | 61 | *) |
34e49164 C |
62 | val type_of_string : string -> Ast_c.fullType |
63 | val statement_of_string : string -> Ast_c.statement | |
91eba41f | 64 | |
485bce71 C |
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 | |
68 | ||
34e49164 | 69 | |
485bce71 C |
70 | (* ---------------------------------------------------------------------- *) |
71 | (* a few helpers *) | |
91eba41f C |
72 | val print_commentized : Parser_c.token list -> unit |
73 | ||
485bce71 C |
74 | val program_of_program2 : program2 -> Ast_c.program |
75 | val with_program2: (Ast_c.program -> Ast_c.program) -> program2 -> program2 |