Wed, 19 Apr 2000 22:03:38 +0200
trunk: changeset 6
- Simpler optparser
- New Makefile system
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> | |
11 | #include "include/misc.h" | |
12 | #include "include/tokenizer.h" | |
13 | ||
14 | ||
15 | int main(void) | |
16 | { | |
17 | Tokenizer*tokz; | |
18 | Token tok=TOK_INIT; | |
19 | ||
20 | if(!(tokz=tokz_open_file(stdin))) | |
21 | return EXIT_FAILURE; | |
22 | ||
23 | while(tokz_get_token(tokz, &tok)){ | |
24 | switch(tok.type){ | |
25 | case TOK_LONG: | |
26 | printf("long - %ld\n", TOK_LONG_VAL(&tok)); | |
27 | break; | |
28 | case TOK_DOUBLE: | |
29 | printf("double - %g\n", TOK_DOUBLE_VAL(&tok)); | |
30 | break; | |
31 | case TOK_CHAR: | |
32 | printf("char - '%c'\n", TOK_CHAR_VAL(&tok)); | |
33 | break; | |
34 | case TOK_STRING: | |
35 | printf("string - \"%s\"\n", TOK_STRING_VAL(&tok)); | |
36 | break; | |
37 | case TOK_IDENT: | |
38 | printf("ident - %s\n", TOK_IDENT_VAL(&tok)); | |
39 | break; | |
40 | case TOK_COMMENT: | |
41 | printf("comment - %s\n", TOK_COMMENT_VAL(&tok)); | |
42 | break; | |
43 | case TOK_OP: | |
44 | printf("operator - %03x\n", TOK_OP_VAL(&tok)); | |
45 | break; | |
46 | } | |
47 | } | |
48 | ||
49 | return EXIT_SUCCESS; | |
50 | } | |
51 |