Mon, 17 Feb 2003 23:24:47 +0100
trunk: changeset 46
UNLINK_ITEM fixed to reset next/previous pointers to NULL
0 | 1 | /* |
2 | * libtu/tester.c | |
3 | * | |
36 | 4 | * Copyright (c) Tuomo Valkonen 1999-2002. |
0 | 5 | * See the included file LICENSE for details. |
6 | */ | |
7 | ||
8 | #include <stdio.h> | |
5 | 9 | |
10 | #include <libtu/misc.h> | |
11 | #include <libtu/tokenizer.h> | |
12 | 12 | #include <libtu/util.h> |
0 | 13 | |
12 | 14 | int main(int argc, char *argv[]) |
0 | 15 | { |
16 | Tokenizer*tokz; | |
17 | Token tok=TOK_INIT; | |
18 | ||
12 | 19 | libtu_init(argv[0]); |
20 | ||
17 | 21 | if(!(tokz=tokz_open_file(stdin, "stdin"))) |
0 | 22 | return EXIT_FAILURE; |
23 | ||
24 | while(tokz_get_token(tokz, &tok)){ | |
25 | switch(tok.type){ | |
26 | case TOK_LONG: | |
27 | printf("long - %ld\n", TOK_LONG_VAL(&tok)); | |
28 | break; | |
29 | case TOK_DOUBLE: | |
30 | printf("double - %g\n", TOK_DOUBLE_VAL(&tok)); | |
31 | break; | |
32 | case TOK_CHAR: | |
33 | printf("char - '%c'\n", TOK_CHAR_VAL(&tok)); | |
34 | break; | |
35 | case TOK_STRING: | |
36 | printf("string - \"%s\"\n", TOK_STRING_VAL(&tok)); | |
37 | break; | |
38 | case TOK_IDENT: | |
39 | printf("ident - %s\n", TOK_IDENT_VAL(&tok)); | |
40 | break; | |
41 | case TOK_COMMENT: | |
42 | printf("comment - %s\n", TOK_COMMENT_VAL(&tok)); | |
43 | break; | |
44 | case TOK_OP: | |
45 | printf("operator - %03x\n", TOK_OP_VAL(&tok)); | |
46 | break; | |
47 | } | |
48 | } | |
49 | ||
50 | return EXIT_SUCCESS; | |
51 | } | |
52 |