1 #include "../gramgram.h"
2 #include "../d.h"
3 #include "../mkdparse.h"
4
5 int
make_tables(char * grammar_string,char * grammar_pathname)6 make_tables(char *grammar_string, char *grammar_pathname) {
7 Grammar *g;
8 g = new_D_Grammar(grammar_pathname);
9 g->set_op_priority_from_rule = 0;
10 g->right_recursive_BNF = 0;
11 g->states_for_whitespace = 1;
12 g->states_for_all_nterms = 1;
13 g->tokenizer = 0;
14 g->longest_match = 0;
15 strcpy(g->grammar_ident, "gram");
16 g->scanner_blocks = 4;
17 g->scanner_block_size = 0;
18 g->write_line_directives = 1;
19 g->write_header = -1;
20 g->token_type = 0;
21 strcpy(g->write_extension, "dat");
22 static char output_file [1024] = "";
23 strncpy(output_file, grammar_pathname, sizeof(output_file)-1);
24 strncat(output_file, ".d_parser.", sizeof(output_file)-strlen(output_file)-1);
25 strncat(output_file, g->write_extension, sizeof(output_file)-strlen(output_file)-1);
26 g->write_pathname = output_file;
27
28 mkdparse_from_string(g, grammar_string);
29
30 if (write_binary_tables(g) < 0)
31 d_fail("unable to write tables");
32
33 free_D_Grammar(g);
34 return 0;
35 }
36