2 * Copyright (c) 2003 Nara Institute of Science and Technology
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name Nara Institute of Science and Technology may not be used to
15 * endorse or promote products derived from this software without
16 * specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY Nara Institute of Science and Technology
19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE Nara Institute
22 * of Science and Technology BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * $Id: katuyou.c,v 1.1.1.1 2007/03/13 07:40:10 masayu-a Exp $
36 ktype_t Cha_type[TYPE_NUM];
37 kform_t Cha_form[TYPE_NUM][FORM_NUM];
38 char *Cha_base_form_str = NULL;
44 read_type_form(FILE * fp)
46 chasen_cell_t *cell1, *cell2;
50 for (i = 1; !cha_s_feof(fp); i++) {
51 cell1 = cha_s_read(fp);
52 Cha_type[i].name = cha_strdup(cha_s_atom(cha_car(cell1)));
53 Cha_type[i].basic = 0;
54 cell1 = cha_car(cha_cdr(cell1));
56 /* base form string */
57 if (cha_litmatch(Cha_type[i].name, 2,
58 STR_BASE_FORM_STR1, STR_BASE_FORM_STR2)) {
59 Cha_base_form_str = cha_strdup(cha_s_atom(cell1));
64 for (j = 1; !nullp(cell2 = cha_car(cell1));
65 cell1 = cha_cdr(cell1), j++) {
69 Cha_form[i][j].name = cha_strdup(cha_s_atom(cha_car(cell2)));
70 if (!Cha_type[i].basic &&
72 ? !strcmp(Cha_form[i][j].name, Cha_base_form_str)
73 : cha_litmatch(Cha_form[i][j].name, 2,
74 STR_BASE_FORM1, STR_BASE_FORM2)))
75 Cha_type[i].basic = j;
81 cha_s_atom(cha_car(cell2 = cha_cdr(cell2))), "*") == 0)
82 Cha_form[i][j].gobi = "";
84 Cha_form[i][j].gobi = cha_strdup(s);
85 Cha_form[i][j].gobi_len = strlen(s);
90 if (nullp(cha_car(cell2 = cha_cdr(cell2))))
91 Cha_form[i][j].ygobi = Cha_form[i][j].gobi;
92 else if (strcmp(s = cha_s_atom(cha_car(cell2)), "*") == 0)
93 Cha_form[i][j].ygobi = "";
95 Cha_form[i][j].ygobi = cha_strdup(s);
100 if (nullp(cha_car(cell2 = cha_cdr(cell2))))
101 Cha_form[i][j].pgobi = Cha_form[i][j].ygobi;
102 else if (strcmp(s = cha_s_atom(cha_car(cell2)), "*") == 0)
103 Cha_form[i][j].pgobi = "";
105 Cha_form[i][j].pgobi = cha_strdup(s);
108 if (!Cha_type[i].basic)
109 cha_exit_file(1, "no basic form");
114 * cha_read_katuyou - read CFORM_FILE and set Cha_form[][]
117 * dir - 0: read from current directory
118 * 1: read from grammar directory
119 * 2: read from current directory or grammar directory
122 cha_read_katuyou(FILE * fp_out, int dir)
127 fp = cha_fopen_grammar(CFORM_FILE, "r", 1, dir, &filepath);
129 fprintf(fp_out, "parsing %s\n", filepath);