-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtenses.c
201 lines (161 loc) · 4.04 KB
/
tenses.c
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/***************************************
$Header$
Processing to do with tense tokens, e.g. working out how to gloss
them depending on the context where they arise.
***************************************/
/* COPYRIGHT */
/*
Processing to do clever things with how tenses are glossed
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "rpc2x_act.tab.h"
#include "nonterm.h"
#include "functions.h"
/*++++++++++++++++++++++++++++++++++++++
TreeNode *x
++++++++++++++++++++++++++++++++++++++*/
static void
check_tense_context(TreeNode *x)
{
TreeNode *parent;
struct nonterm *nt;
XTenseCtx *tc;
parent = x->parent;
for (;;) {
/* Already know parent is non-terminal!! */
nt = & parent->data.nonterm;
/* In all cases, we will need to traverse upwards until we come
out of <tag> or <stag>, since they don't tell us anything
useful. */
switch (nt->type) {
case TERM_TAGGED_SUMTI:
case TAGGED_TERMSET:
tc = prop_tense_ctx(x, YES);
tc->ctx = TSC_TERM;
goto done;
break;
case TEXT_1C:
case I_JJ_STAG_BO:
case GIHEK_STAG_KE:
case GIHEK_STAG_BO:
case JOIK_EK_KE:
case JOIK_EK_STAG_BO:
case JOIK_STAG_KE:
case JOIK_JEK_STAG_BO:
tc = prop_tense_ctx(x, YES);
tc->ctx = TSC_LINK;
goto done;
break;
case SUMTI_5B:
case SUMTI_TAIL_1:
tc = prop_tense_ctx(x, YES);
tc->ctx = TSC_NOUN;
goto done;
break;
case STATEMENT_3:
case TERM_FLOATING_TENSE:
case GEK_SENTENCE:
case MAIN_SELBRI:
case METALINGUISTIC_MAIN_SELBRI:
/* It's no use just looking for <selbri>, because that happens
in a sumti context as well. */
tc = prop_tense_ctx(x, YES);
tc->ctx = TSC_SELBRI;
goto done;
break;
case JAI_TAG_TU2:
tc = prop_tense_ctx(x, YES);
tc->ctx = TSC_JAITAG;
goto done;
break;
case MEX_OPERATOR:
/* Via NAhU selbri */
goto done;
break;
case OPERAND_3:
/* Via NIhE selbri */
goto done;
break;
case COMPLEX_TENSE_MODAL:
/* Via FIhO selbri */
goto done;
break;
case FREE:
goto done;
break;
case GEK:
/* This is the case where we have something like 'ca gi X gi Y' which
can be treated like 'X icabo Y'. */
tc = prop_tense_ctx(x, YES);
tc->ctx = TSC_CONNECT;
goto done;
break;
case CHUNKS:
fprintf(stderr, "Selma'o PU token at line %d column %d lies in unhandled context\n",
x->start_line, x->start_column);
abort(); /* oops, we've got all the way out to the top of the parse tree. */
goto done;
break;
default:
break;
}
parent = parent->parent;
}
done:
return;
}
/*++++++++++++++++++++++++++++++++++++++
Scan for each node in selma'o PU. Backtrack up the tree to find out
the context where it occurs.
TreeNode *x
++++++++++++++++++++++++++++++++++++++*/
static void
scan_tenses(TreeNode *x)
{
struct nonterm *nt;
int nc, i;
TreeNode *c;
if (x->type == N_NONTERM) {
nt = & x->data.nonterm;
switch (nt->type) {
case TIME_OFFSET:
case SPACE_INT_PROP:
case INTERVAL_PROPERTY:
check_tense_context(x);
break;
default:
break;
}
nc = nt->nchildren;
for (i=0; i<nc; i++) {
c = nt->children[i];
scan_tenses(c);
}
} else {
if (x->type == N_CMAVO) {
switch (x->data.cmavo.selmao) {
case ZAhO:
case VA:
case FAhA:
case BAI:
case PU:
check_tense_context(x);
break;
default:
break;
}
}
}
}
/*++++++++++++++++++++++++++++++++++++++
Top level of tense handling, exported to rest of software
TreeNode *top
++++++++++++++++++++++++++++++++++++++*/
void
tense_processing(TreeNode *top)
{
scan_tenses(top);
}