]> git.decadent.org.uk Git - ion3.git/blob - libtu/tester.c
[svn-inject] Installing original source of ion3
[ion3.git] / libtu / tester.c
1 /*
2  * libtu/tester.c
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2002. 
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.
8  */
9
10 #include <stdio.h>
11
12 #include "misc.h"
13 #include "tokenizer.h"
14 #include "util.h"
15
16 int main(int argc, char *argv[])
17 {
18     Tokenizer*tokz;
19     Token tok=TOK_INIT;
20     
21     libtu_init(argv[0]);
22     
23     if(!(tokz=tokz_open_file(stdin, "stdin")))
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