summaryrefslogtreecommitdiff
path: root/src/test/check_reader.c
blob: 3184e4128b6123c11aa62eccf44c759e9cdf1835 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdlib.h>
#include <stdio.h>

#include "../util.h"
#include "../list.h"
#include "../grammar.h"
#include "../reader.h"

int
main(U_ATTR int argc, U_ATTR char **argv)
{
  /* return 77; */

  char *file_name = "test.txt";
  char *buffer = MYALLOC(char, 512);
  NUM buffer_size = 0;

  if (read_entire_file(file_name, &buffer, &buffer_size)) {
    fleprintf("Cannot read file %s", file_name);
    free(buffer);
    return 1;
  }

  utf8 *s = new_utf8(buffer, buffer_size);

  Grammar *g = read_grammar_from_bnf((str *) s);

  if (g) {
    print_grammar(g);
    destroy_grammar(g, 2);
    destroy_str((str *)s, 1);

    return 0;
  }

  return 1;
}