2 * Example trivial client program that uses the sparse library
5 * Copyright (C) 2003 Transmeta Corp.
7 * Copyright 2003 Jeff Garzik
9 * Licensed under the Open Software License version 1.1
24 #include "expression.h"
27 static void clean_up_symbols(struct symbol_list
*list
)
31 FOR_EACH_PTR(list
, sym
) {
34 } END_FOR_EACH_PTR(sym
);
37 int main(int argc
, char **argv
)
40 char *basename
, *filename
= NULL
, **args
;
42 struct symbol_list
*list
;
44 // Initialize symbol stream first, so that we can add defines etc
47 create_builtin_stream();
55 args
= handle_switch(arg
+ 1, args
);
61 // Initialize type system
65 die("No file specified");
67 basename
= strrchr(filename
, '/');
70 else if ((basename
== filename
) && (basename
[1] == 0)) {
71 fprintf(stderr
, "um\n");
76 fprintf(stderr
, "um\n");
81 fd
= open(filename
, O_RDONLY
);
83 die("No such file: %s", filename
);
85 // Tokenize the input stream
86 token
= tokenize(filename
, fd
, NULL
, includepath
);
89 // Prepend the initial built-in stream
90 token
= tokenize_buffer(pre_buffer
, pre_buffer_size
, token
);
92 // Pre-process the stream
93 token
= preprocess(token
);
95 // Parse the resulting C code
96 list
= translation_unit(token
);
98 // Do type evaluation and simplification
99 emit_unit_begin(basename
);
100 clean_up_symbols(list
);
104 // And show the allocation statistics
108 show_expression_alloc();
109 show_statement_alloc();