]> andersk Git - libyaml.git/blame - tests/run-scanner.c
Refactor internal and external API.
[libyaml.git] / tests / run-scanner.c
CommitLineData
625fcfe9
KS
1#include <yaml.h>
2
3#include <stdlib.h>
4#include <stdio.h>
5#include <assert.h>
6
7int
8main(int argc, char *argv[])
9{
10 FILE *file;
11 yaml_parser_t parser;
12 yaml_token_t token;
13 int done = 0;
14 int count = 0;
15
16 if (argc != 2) {
17 printf("Usage: %s file.yaml\n", argv[0]);
18 return 0;
19 }
20 file = fopen(argv[1], "rb");
21 assert(file);
22
23 assert(yaml_parser_initialize(&parser));
24
25 yaml_parser_set_input_file(&parser, file);
26
27 while (!done)
28 {
29 assert(yaml_parser_scan(&parser, &token));
30
31 done = (token.type == YAML_STREAM_END_TOKEN);
32
33 yaml_token_delete(&token);
34
35 count ++;
36 }
37
38 yaml_parser_delete(&parser);
39
40 fclose(file);
41
42 printf("Parsing the file '%s': %d tokens\n", argv[1], count);
43
44 return 0;
45}
46
This page took 0.205413 seconds and 5 git commands to generate.