Commit | Line | Data |
---|---|---|
34e49164 C |
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 | ||
485bce71 | 8 | (* ---------------------------------------------------------------------- *) |
34e49164 | 9 | type 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 *) | |
17 | val parse_cpp_define_file : | |
18 | filename -> (string, Cpp_token_c.define_def) assoc | |
19 | ||
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 | |
24 | ||
25 | val init_defs_macros : filename -> unit | |
26 | val init_defs_builtins : filename -> unit | |
27 | ||
28 | ||
485bce71 | 29 | (* ---------------------------------------------------------------------- *) |
34e49164 C |
30 | (* This is the main function *) |
31 | val parse_print_error_heuristic: | |
485bce71 C |
32 | filename (*cfile*) -> (program2 * Parsing_stat.parsing_stat) |
33 | (* alias of previous func *) | |
34 | val 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 *) |
38 | val parse_cache: | |
39 | filename (*cfile*) -> (program2 * Parsing_stat.parsing_stat) | |
40 | ||
485bce71 C |
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 | |
34e49164 C |
45 | |
46 | val parse: filename -> Ast_c.program | |
47 | val parse_print_error: filename -> Ast_c.program | |
48 | val 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 |
57 | val type_of_string : string -> Ast_c.fullType |
58 | val 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 *) |
61 | val cstatement_of_string : string -> Ast_c.statement | |
62 | val cexpression_of_string : string -> Ast_c.expression | |
63 | ||
34e49164 C |
64 | |
65 | ||
34e49164 | 66 | |
485bce71 C |
67 | (* ---------------------------------------------------------------------- *) |
68 | (* a few helpers *) | |
91eba41f C |
69 | val print_commentized : Parser_c.token list -> unit |
70 | ||
485bce71 C |
71 | val program_of_program2 : program2 -> Ast_c.program |
72 | val with_program2: (Ast_c.program -> Ast_c.program) -> program2 -> program2 | |
34e49164 | 73 | |
34e49164 C |
74 | |
75 |