Sat, 29 Apr 2000 15:35:45 +0200
trunk: changeset 12
Changed the copyright notice in headers
0 | 1 | /* |
2 | * libtu/tester.c | |
3 | * | |
9 | 4 | * Copyright (c) Tuomo Valkonen 1999-2000. |
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> | |
0 | 12 | |
13 | ||
14 | int main(void) | |
15 | { | |
16 | Tokenizer*tokz; | |
17 | Token tok=TOK_INIT; | |
18 | ||
19 | if(!(tokz=tokz_open_file(stdin))) | |
20 | return EXIT_FAILURE; | |
21 | ||
22 | while(tokz_get_token(tokz, &tok)){ | |
23 | switch(tok.type){ | |
24 | case TOK_LONG: | |
25 | printf("long - %ld\n", TOK_LONG_VAL(&tok)); | |
26 | break; | |
27 | case TOK_DOUBLE: | |
28 | printf("double - %g\n", TOK_DOUBLE_VAL(&tok)); | |
29 | break; | |
30 | case TOK_CHAR: | |
31 | printf("char - '%c'\n", TOK_CHAR_VAL(&tok)); | |
32 | break; | |
33 | case TOK_STRING: | |
34 | printf("string - \"%s\"\n", TOK_STRING_VAL(&tok)); | |
35 | break; | |
36 | case TOK_IDENT: | |
37 | printf("ident - %s\n", TOK_IDENT_VAL(&tok)); | |
38 | break; | |
39 | case TOK_COMMENT: | |
40 | printf("comment - %s\n", TOK_COMMENT_VAL(&tok)); | |
41 | break; | |
42 | case TOK_OP: | |
43 | printf("operator - %03x\n", TOK_OP_VAL(&tok)); | |
44 | break; | |
45 | } | |
46 | } | |
47 | ||
48 | return EXIT_SUCCESS; | |
49 | } | |
50 |