]> mj.ucw.cz Git - moe.git/blob - judge/test-tok.c
Basic functions for building of judges.
[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.flags = TF_REPORT_LINES;
12   char *tok;
13   while (tok = get_token(&t))
14     {
15       printf("<%s>", tok);
16 #define T(f, type, fmt) { type x; if (to_##f(&t, &x)) printf(" = " #f " " fmt, x); }
17       T(int, int, "%d");
18       T(uint, unsigned int, "%u");
19       T(long, long int, "%ld");
20       T(ulong, unsigned long int, "%lu");
21       T(double, double, "%f");
22       T(long_double, long double, "%Lf");
23 #undef T
24       putchar('\n');
25     }
26   tok_cleanup(&t);
27
28   sclose(i);
29   return 0;
30 }