2 * Example trivial client program that uses the sparse library
3 * to tokenize, pre-process and parse a C file, and prints out
6 * Copyright (C) 2003 Linus Torvalds, all rights reserved.
21 char *includepath
[] = {
22 "/usr/lib/gcc-lib/i386-redhat-linux/3.2.1/include/",
24 "/home/torvalds/v2.5/linux/include/",
27 "/usr/local/include/",
33 static void handle_switch(char *arg
)
37 int main(int argc
, char **argv
)
40 char *filename
= NULL
;
42 struct symbol_list
*list
= NULL
;
44 // Initialize symbol stream first, so that we can add defines etc
47 for (i
= 1; i
< argc
; i
++) {
57 fd
= open(filename
, O_RDONLY
);
59 die("No such file: %s", argv
[1]);
61 // Tokenize the input stream
62 token
= tokenize(filename
, fd
, NULL
);
65 // Pre-process the stream
66 token
= preprocess(token
);
68 // Parse the resulting C code
69 translation_unit(token
, &list
);
71 // Show the end result.
72 show_symbol_list(list
, "\n\n");
75 // And show the allocation statistics
79 show_expression_alloc();
80 show_statement_alloc();