Import libtu instead of using submodules
[notion.git] / libtu / tester.c
blob4f27fd6d1afd79457f74dd754eb4475c160f7dba
1 /*
2 * libtu/tester.c
4 * Copyright (c) Tuomo Valkonen 1999-2002.
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 */
10 #include <stdio.h>
12 #include "misc.h"
13 #include "tokenizer.h"
14 #include "util.h"
16 int main(int argc, char *argv[])
18 Tokenizer*tokz;
19 Token tok=TOK_INIT;
21 libtu_init(argv[0]);
23 if(!(tokz=tokz_open_file(stdin, "stdin")))
24 return EXIT_FAILURE;
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;
52 return EXIT_SUCCESS;