]> mj.ucw.cz Git - moe.git/blob - judge/test-tok.c
Added real and case-insensitive modes to judge-tok.
[moe.git] / judge / test-tok.c
1 #include <stdio.h>
2
3 #include "judge.h"
4
5 int main(void)
6 {
7   struct stream *i = sopen_fd("stdin", 0);
8
9   struct tokenizer t;
10   tok_init(&t, i);
11   // t.maxtoken = 1000;
12   t.flags = TF_REPORT_LINES;
13   char *tok;
14   while (tok = get_token(&t))
15     {
16       printf("<%s>", tok);
17 #define T(f, type, fmt) { type x; if (to_##f(&t, &x)) printf(" = " #f " " fmt, x); }
18       T(int, int, "%d");
19       T(uint, unsigned int, "%u");
20       T(long, long int, "%ld");
21       T(ulong, unsigned long int, "%lu");
22       T(double, double, "%f");
23       T(long_double, long double, "%Lf");
24 #undef T
25       putchar('\n');
26     }
27   tok_cleanup(&t);
28
29   sclose(i);
30   return 0;
31 }