@@ -47,22 +47,35 @@ requires the information.
This means that a user of the library will literally just need to do
- struct string_list *filelist = NULL;
- char *file;
+ struct token *token;
+ int fd = open(filename, O_RDONLY);
+ struct symbol_list *list = NULL;
- action(sparse_initialize(argc, argv, filelist));
+ if (fd < 0)
+ exit_with_complaint();
- FOR_EACH_PTR_NOTAG(filelist, file) {
- action(sparse(file));
- } END_FOR_EACH_PTR_NOTAG(file);
+ // Initialize parse symbols
+ init_symbols();
+
+ // Tokenize the input stream
+ token = tokenize(filename, fd, NULL);
+
+ // Pre-process the stream
+ token = preprocess(token);
+
+ // Parse the resulting C code
+ translation_unit(token, &list);
+
+ // Evaluate the types now if we want to
+ // Or leave it until later.
+ symbol_iterate(list, evaluate_symbol, NULL);
and he is now done - having a full C parse of the file he opened. The
library doesn't need any more setup, and once done does not impose any
more requirements. The user is free to do whatever he wants with the
parse tree that got built up, and needs not worry about the library ever
again. There is no extra state, there are no parser callbacks, there is
-only the parse tree that is described by the header files. The action
-function takes a pointer to a symbol_list and does whatever it likes with it.
+only the parse tree that is described by the header files.
The library also contains (as an example user) a few clients that do the
preprocessing, parsing and type evaluation and just print out the