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 | |
485bce71 | 15 | (* ---------------------------------------------------------------------- *) |
34e49164 C |
16 | (* This is the main function *) |
17 | val parse_print_error_heuristic: | |
485bce71 C |
18 | filename (*cfile*) -> (program2 * Parsing_stat.parsing_stat) |
19 | (* alias of previous func *) | |
20 | val parse_c_and_cpp : | |
21 | filename (*cfile*) -> (program2 * Parsing_stat.parsing_stat) | |
34e49164 | 22 | |
485bce71 C |
23 | (* use some .ast_raw memoized version, and take care if obsolete *) |
24 | val parse_cache: | |
25 | filename (*cfile*) -> (program2 * Parsing_stat.parsing_stat) | |
26 | ||
27 | ||
28 | (* ---------------------------------------------------------------------- *) | |
34e49164 | 29 | val parse_cpp_define_file : |
485bce71 | 30 | filename -> (string, Parsing_hacks.define_def) assoc |
34e49164 C |
31 | |
32 | val init_defs : filename -> unit | |
33 | ||
34 | ||
35 | ||
36 | ||
37 | ||
485bce71 C |
38 | (* ---------------------------------------------------------------------- *) |
39 | (* used also for the standard.h file *) | |
40 | val tokens: ?profile:bool -> filename -> Parser_c.token list | |
41 | val tokens_of_string: string -> Parser_c.token list | |
34e49164 C |
42 | |
43 | val parse: filename -> Ast_c.program | |
44 | val parse_print_error: filename -> Ast_c.program | |
45 | val parse_gen: | |
46 | ((Lexing.lexbuf -> Parser_c.token) -> Lexing.lexbuf -> 'a) -> string -> 'a | |
47 | ||
485bce71 C |
48 | |
49 | ||
50 | (* ---------------------------------------------------------------------- *) | |
51 | (* Easy way to build complex Ast elements from simple strings. | |
52 | * Can also be useful when called from the ocaml toplevel to test. | |
53 | *) | |
34e49164 C |
54 | val type_of_string : string -> Ast_c.fullType |
55 | val statement_of_string : string -> Ast_c.statement | |
485bce71 C |
56 | (* similar but use parse_c_and_cpp and a /tmp/__cocci.c and extract the part *) |
57 | val cstatement_of_string : string -> Ast_c.statement | |
58 | val cexpression_of_string : string -> Ast_c.expression | |
59 | ||
34e49164 C |
60 | |
61 | ||
34e49164 | 62 | |
485bce71 C |
63 | (* ---------------------------------------------------------------------- *) |
64 | (* a few helpers *) | |
65 | val program_of_program2 : program2 -> Ast_c.program | |
66 | val with_program2: (Ast_c.program -> Ast_c.program) -> program2 -> program2 | |
34e49164 | 67 | |
34e49164 C |
68 | val print_commentized : Parser_c.token list -> unit |
69 | ||
70 |