Wed, 28 May 2003 23:48:16 +0200
trunk: changeset 57
License changed to Artistic/LGPL dual license.
0 | 1 | /* |
2 | * libtu/tester.c | |
3 | * | |
36 | 4 | * Copyright (c) Tuomo Valkonen 1999-2002. |
53 | 5 | * |
6 | * You may distribute and modify this library under the terms of either | |
7 | * the Clarified Artistic License or the GNU LGPL, version 2.1 or later. | |
0 | 8 | */ |
9 | ||
10 | #include <stdio.h> | |
5 | 11 | |
12 | #include <libtu/misc.h> | |
13 | #include <libtu/tokenizer.h> | |
12 | 14 | #include <libtu/util.h> |
0 | 15 | |
12 | 16 | int main(int argc, char *argv[]) |
0 | 17 | { |
18 | Tokenizer*tokz; | |
19 | Token tok=TOK_INIT; | |
20 | ||
12 | 21 | libtu_init(argv[0]); |
22 | ||
17 | 23 | if(!(tokz=tokz_open_file(stdin, "stdin"))) |
0 | 24 | return EXIT_FAILURE; |
25 | ||
26 | while(tokz_get_token(tokz, &tok)){ | |
27 | switch(tok.type){ | |
28 | case TOK_LONG: | |
29 | printf("long - %ld\n", TOK_LONG_VAL(&tok)); | |
30 | break; | |
31 | case TOK_DOUBLE: | |
32 | printf("double - %g\n", TOK_DOUBLE_VAL(&tok)); | |
33 | break; | |
34 | case TOK_CHAR: | |
35 | printf("char - '%c'\n", TOK_CHAR_VAL(&tok)); | |
36 | break; | |
37 | case TOK_STRING: | |
38 | printf("string - \"%s\"\n", TOK_STRING_VAL(&tok)); | |
39 | break; | |
40 | case TOK_IDENT: | |
41 | printf("ident - %s\n", TOK_IDENT_VAL(&tok)); | |
42 | break; | |
43 | case TOK_COMMENT: | |
44 | printf("comment - %s\n", TOK_COMMENT_VAL(&tok)); | |
45 | break; | |
46 | case TOK_OP: | |
47 | printf("operator - %03x\n", TOK_OP_VAL(&tok)); | |
48 | break; | |
49 | } | |
50 | } | |
51 | ||
52 | return EXIT_SUCCESS; | |
53 | } | |
54 |