-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_token.c
More file actions
36 lines (32 loc) · 775 Bytes
/
test_token.c
File metadata and controls
36 lines (32 loc) · 775 Bytes
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
#include <stdio.h> // FILE{}, stdin, stderr, fgets(), printf()
#include "token.h"
FILE *Debug;
int
main()
{
char buffer[ 256 ];
token_t tok;
int ret;
Debug = stderr;
token_init();
while (fgets(buffer, 256, stdin) != NULL) {
if (*buffer == 0 || *buffer == '\n')
break;
printf("===== %s", buffer);
token_source(buffer);
while (1) {
ret = token_read(&tok);
if (ret != TOKEN_SUCCESS) {
fprintf(Debug, "*** Token error: %s\n", token_result(ret));
break;
}
#ifdef DEBUG
token_dump(&tok);
#endif
if (tok.type == TOKEN_TYPE_EOL)
break;
}
fprintf(Debug, "\n");
}
return 0;
}