Start doing type evaluation for binops - integer promotion rules
[smatch.git] / test-lexing.c
blob1cd82c9fa241c73e707e14e51a58ad03f3396642
1 /*
2 * Example test program that just uses the tokenization and
3 * preprocessing phases, and prints out the results.
5 * Copyright (C) 2003 Linus Torvalds, all rights reserved.
6 */
7 #include <stdarg.h>
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <string.h>
11 #include <ctype.h>
12 #include <unistd.h>
13 #include <fcntl.h>
15 #include "token.h"
16 #include "symbol.h"
18 int main(int argc, char **argv)
20 int fd = open(argv[1], O_RDONLY);
21 struct token *token;
23 if (fd < 0)
24 die("No such file: %s", argv[1]);
26 init_symbols();
27 token = tokenize(argv[1], fd, NULL);
28 close(fd);
29 token = preprocess(token);
31 while (!eof_token(token)) {
32 struct token *next = token->next;
33 char * separator = "";
34 if (next->whitespace)
35 separator = " ";
36 if (next->newline)
37 separator = "\n";
38 printf("%s%s", show_token(token), separator);
39 token = next;
41 putchar('\n');
42 show_identifier_stats();
43 return 0;