tester.c

Tue, 16 Mar 2004 21:35:13 +0100

author
tuomov
date
Tue, 16 Mar 2004 21:35:13 +0100
changeset 70
e866dc825481
parent 62
aae5facf9fc5
permissions
-rw-r--r--

trunk: changeset 1408
Changed include directives to reflect change in locations of headers.

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

mercurial