Wed, 19 Apr 2000 22:10:28 +0200
trunk: changeset 8
Moved include/*.h to include/libtu/
0 | 1 | /* |
2 | * libtu/tester.c | |
3 | * | |
4 | * Copyright (c) Tuomo Valkonen 1999-2000. | |
5 | * | |
6 | * This file is distributed under the terms of the "Artistic License". | |
7 | * See the included file LICENSE for details. | |
8 | */ | |
9 | ||
10 | #include <stdio.h> | |
5 | 11 | |
12 | #include <libtu/misc.h> | |
13 | #include <libtu/tokenizer.h> | |
0 | 14 | |
15 | ||
16 | int main(void) | |
17 | { | |
18 | Tokenizer*tokz; | |
19 | Token tok=TOK_INIT; | |
20 | ||
21 | if(!(tokz=tokz_open_file(stdin))) | |
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 |