tester.c

changeset 62
aae5facf9fc5
parent 53
f8f9366b359c
child 70
e866dc825481
equal deleted inserted replaced
61:fc585645ad05 62:aae5facf9fc5
13 #include <libtu/tokenizer.h> 13 #include <libtu/tokenizer.h>
14 #include <libtu/util.h> 14 #include <libtu/util.h>
15 15
16 int main(int argc, char *argv[]) 16 int main(int argc, char *argv[])
17 { 17 {
18 Tokenizer*tokz; 18 Tokenizer*tokz;
19 Token tok=TOK_INIT; 19 Token tok=TOK_INIT;
20 20
21 libtu_init(argv[0]); 21 libtu_init(argv[0]);
22 22
23 if(!(tokz=tokz_open_file(stdin, "stdin"))) 23 if(!(tokz=tokz_open_file(stdin, "stdin")))
24 return EXIT_FAILURE; 24 return EXIT_FAILURE;
25 25
26 while(tokz_get_token(tokz, &tok)){ 26 while(tokz_get_token(tokz, &tok)){
27 switch(tok.type){ 27 switch(tok.type){
28 case TOK_LONG: 28 case TOK_LONG:
29 printf("long - %ld\n", TOK_LONG_VAL(&tok)); 29 printf("long - %ld\n", TOK_LONG_VAL(&tok));
30 break; 30 break;
31 case TOK_DOUBLE: 31 case TOK_DOUBLE:
32 printf("double - %g\n", TOK_DOUBLE_VAL(&tok)); 32 printf("double - %g\n", TOK_DOUBLE_VAL(&tok));
33 break; 33 break;
34 case TOK_CHAR: 34 case TOK_CHAR:
35 printf("char - '%c'\n", TOK_CHAR_VAL(&tok)); 35 printf("char - '%c'\n", TOK_CHAR_VAL(&tok));
36 break; 36 break;
37 case TOK_STRING: 37 case TOK_STRING:
38 printf("string - \"%s\"\n", TOK_STRING_VAL(&tok)); 38 printf("string - \"%s\"\n", TOK_STRING_VAL(&tok));
39 break; 39 break;
40 case TOK_IDENT: 40 case TOK_IDENT:
41 printf("ident - %s\n", TOK_IDENT_VAL(&tok)); 41 printf("ident - %s\n", TOK_IDENT_VAL(&tok));
42 break; 42 break;
43 case TOK_COMMENT: 43 case TOK_COMMENT:
44 printf("comment - %s\n", TOK_COMMENT_VAL(&tok)); 44 printf("comment - %s\n", TOK_COMMENT_VAL(&tok));
45 break; 45 break;
46 case TOK_OP: 46 case TOK_OP:
47 printf("operator - %03x\n", TOK_OP_VAL(&tok)); 47 printf("operator - %03x\n", TOK_OP_VAL(&tok));
48 break; 48 break;
49 } 49 }
50 } 50 }
51 51
52 return EXIT_SUCCESS; 52 return EXIT_SUCCESS;
53 } 53 }
54 54

mercurial