blob: 900b723545d175d6a1065a514b9fe5cd8a4ad3cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include "util/err.c"
#include "util/files.c"
#include "identifiers.c"
#include "tokenizer.c"
int main(int argc, char **argv) {
if (argc < 2) {
fprintf(stderr, "Please specify an input file.\n");
return EXIT_FAILURE;
}
FILE *in = fopen(argv[1], "r");
if (!in) {
fprintf(stderr, "Could not open file: %s.\n", argv[1]);
return EXIT_FAILURE;
}
Tokenizer t = tokenize_file(in);
for (size_t i = 0; i < t.ntokens; i++) {
if (i)
printf(" ");
token_fprint(stdout, &t.tokens[i]);
}
printf("\n");
tokenizer_free(&t);
fclose(in);
idents_free();
}
|