Fix constant expression parsing (a constant expression can
[smatch.git] / test-parsing.c
blob4b9a93105d0f3eada85ec833cb77d1315753aceb
1 #include <stdarg.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <string.h>
5 #include <ctype.h>
6 #include <unistd.h>
7 #include <fcntl.h>
9 #include "lib.h"
10 #include "token.h"
11 #include "parse.h"
12 #include "symbol.h"
14 int main(int argc, char **argv)
16 int fd = open(argv[1], O_RDONLY);
17 struct token *token;
18 struct symbol_list *list = NULL;
20 if (fd < 0)
21 die("No such file: %s", argv[1]);
22 init_symbols();
24 // Tokenize the input stream
25 token = tokenize(argv[1], fd, NULL);
26 close(fd);
28 // Pre-process the stream
29 token = preprocess(token);
31 // Parse the resulting C code
32 translation_unit(token, &list);
34 // Show the end result.
35 show_symbol_list(list, "\n\n");
36 printf("\n\n");
38 // And show the allocation statistics
39 show_ident_alloc();
40 show_token_alloc();
41 show_symbol_alloc();
42 show_expression_alloc();
43 show_statement_alloc();
44 show_string_alloc();
45 show_bytes_alloc();
46 return 0;