-
Notifications
You must be signed in to change notification settings - Fork 7
/
nodes.h
405 lines (336 loc) · 8.18 KB
/
nodes.h
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
/***************************************
$Header$
Node type definitions for use in the bison parser and its interface
with the lexer / preprocessor.
***************************************/
/* COPYRIGHT */
#ifndef NODES_H
#define NODES_H /*+ To stop multiple inclusions. +*/
#include "nonterm.h"
struct treenode;
typedef enum {
N_MARKER,
N_GARBAGE,
N_CMAVO,
N_ZOI,
N_ZO,
N_LOhU,
N_ZEI,
N_BU,
N_BRIVLA,
N_CMENE,
N_NONTERM,
N_BROKEN_ERASURE /* ZOI, ZO or LOhU with insufficient SI after => parse error */
} NodeTypes;
typedef enum {
BR_NONE,
BR_ROUND,
BR_SQUARE,
BR_BRACE,
BR_ANGLE,
BR_CEIL,
BR_FLOOR,
BR_TRIANGLE
} BracketType;
struct marker {
int tok; /* To lie at same offset as selmao in struct cmavo, to
facilitate error lookahead, given that all values are
disjoint. */
char *text;
};
struct garbage {
char *word;
};
struct cmavo {
int selmao; /* which can be modified to do token groupings,
e.g. SE_BAI etc as required to work around the
grammar not being LR(1) */
int code; /* Reference into cmavo table */
/* Set in categ.c if the first token of a 'free' follows */
unsigned char followed_by_free;
};
struct zoi {
char *form; /* zoi or la'o */
char *term; /* delimiter */
char *text; /* body text */
};
struct zo {
char *text;
};
struct lohu {
char *text;
};
/* For X zei Y, nchildren==2. For X zei Y zei Z, nchildren==3 etc. */
struct zei {
int nchildren;
struct treenode **children;
char *sep_with_plus; /* Form for dictionary lookup of whole thing, e.g. o'o+cinmo */
char *sep_with_zei; /* Form with zei separating terms, kept for printing out if needed */
int number; /* Sequence number (can print out to help user match start and end of constructs) */
BracketType brackets; /* bracketing to apply to this construction */
};
enum BrivlaType {
BVT_GISMU,
BVT_LUJVO,
BVT_FUIVLA3,
BVT_FUIVLA4
};
struct brivla {
char *word;
enum BrivlaType type;
};
struct cmene {
char *word;
};
struct bu {
char *word;
};
/* When zoi, zo, lo'u..le'u has been erased with too few si cmavo,
how many matches are still required to clear it. */
struct erasure {
int defects;
};
struct nonterm {
int nchildren;
int number; /* Sequence number (can print out to help user match start and end of constructs) */
BracketType brackets; /* bracketing to apply to this construction */
NonTerm type;
struct treenode **children;
};
struct treenode;
/* ================================================== */
/* Extension field types */
typedef enum extension_type {
EX_CONV,
EX_BAICONV,
EX_DONTGLOSS,
EX_TERMVECTORS,
EX_TERMVECTOR,
EX_TERMTAGS,
EX_GLOSSTYPE,
EX_DONETU1,
EX_DONES3,
EX_TENSECTX,
EX_NEGINDICATOR,
EX_CAIINDICATOR,
EX_CONNECTIVE,
EX_ANTECEDENT,
EX_REQUIREBRAC,
EX_RELCLAUSELINK,
EX_CONTAINSKEHA,
EX_ELIDABLE
} ExtensionType;
typedef struct x_conversion {
int conv; /* Which place of the word goes into the x1 place of the
construction. */
} XConversion;
typedef struct x_baiconversion {
int conv;
} XBaiConversion;
typedef struct x_dontgloss {
int pad;
} XDontGloss;
struct TermVector;
typedef struct x_termvectors {
struct TermVector *pre;
struct TermVector *post;
} XTermVectors;
typedef struct x_termvector {
struct TermVector *vec;
} XTermVector;
typedef struct x_glosstype {
int in_selbri; /* 1 in main selbri, 0 in a sumti */
int is_tertau; /* 1 if it's the tertau */
} XGlosstype;
/* ================================================== */
typedef enum {
TTT_BRIVLA,
TTT_JAITAG,
TTT_JAI,
TTT_ABSTRACTION,
TTT_ME,
TTT_GOhA,
TTT_NUhA,
TTT_NUMBERMOI,
TTT_ZEI
} XTermTagType;
typedef struct {
struct treenode *x;
} XTT_Brivla;
typedef struct {
/* The tag (BAI, tense etc that does the modifying) */
struct treenode *tag;
/* The tanru_unit_2 that is modified. */
struct treenode *inner_tu2;
} XTT_JaiTag;
typedef struct {
int pad;
} XTT_Jai;
typedef struct {
struct treenode *nu;
} XTT_Abstraction;
typedef struct {
struct treenode *sumti;
} XTT_Me;
typedef struct {
struct treenode *goha;
} XTT_Goha;
typedef struct {
struct treenode *mex_operator;
} XTT_Nuha;
typedef struct {
struct treenode *number_or_lerfu;
struct treenode *moi;
} XTT_NumberMoi;
typedef struct {
struct treenode *zei;
} XTT_Zei;
typedef struct x_termtag {
XTermTagType type;
int pos; /* Needs extending to do JAI etc */
/* Not union, because the jai variants need to access the brivla one
too. Look at cleaning this up sometime */
XTT_Brivla brivla;
XTT_JaiTag jaitag;
XTT_Jai jai;
XTT_Abstraction abstraction;
XTT_Me me;
XTT_Goha goha;
XTT_Nuha nuha;
XTT_NumberMoi numbermoi;
XTT_Zei zei;
} XTermTag;
typedef struct x_termtags {
struct x_termtags *next;
struct x_termtag tag;
} XTermTags;
typedef struct x_donetu1 {
int pad;
} XDoneTU1;
typedef struct x_dones3 {
int pad;
} XDoneS3;
typedef struct x_tensectx {
enum tense_contexts {
TSC_OTHER,
TSC_SELBRI,
TSC_TERM,
TSC_NOUN,
TSC_LINK,
TSC_CONNECT,
TSC_JAITAG
} ctx;
} XTenseCtx;
typedef struct x_negindicator {
int pad;
} XNegIndicator;
typedef struct x_caiindicator {
enum cai_codes {
CC_CAI,
CC_SAI,
CC_RUhE,
CC_CUhI,
CC_RUhENAI,
CC_SAINAI,
CC_CAINAI,
CC_PEI,
CC_PEINAI
} code;
} XCaiIndicator;
typedef struct x_connective {
enum connective_position {
CNP_GE, /* ge part of forethought connective */
CNP_GI, /* gi part of forethought connective */
CNP_GE_JOIK, /* joik_gi in a gek */
CNP_GI_JOIK, /* gi matched with a joik_gi */
CNP_GE_STAG, /* stag_gik in a gek */
CNP_GI_STAG, /* gi matched with a stag_gik */
CNP_AFTER /* after-thought connective */
} pos;
/* This is used for the logical connectives */
char *pattern; /* TTFF etc */
/* This is used for the non-logical and tag connectives */
struct treenode *js; /* joik or stag */
int neg1; /* true if first half has NAI applied */
int neg2; /* true if second half has NAI applied */
} XConnective;
typedef struct {
struct treenode *node;
} XAntecedent;
typedef struct {
int pad;
} XRequireBrac;
typedef struct {
struct treenode *rel;
} XRelClauseLink;
typedef struct {
int pad;
} XContainsKeha;
typedef struct {
int pad;
} XElidable;
typedef union {
XConversion conversion;
XBaiConversion bai_conversion;
XDontGloss dont_gloss;
XTermVectors term_vectors;
XTermVector term_vector;
XTermTags term_tags;
XGlosstype glosstype;
XDoneTU1 done_tu1;
XDoneS3 done_s3;
XTenseCtx tense_ctx;
XNegIndicator neg_indicator;
XCaiIndicator cai_indicator;
XConnective connective;
XAntecedent antecedent;
XRequireBrac require_brac;
XRelClauseLink rel_clause_link;
XContainsKeha contains_keha;
XElidable elidable;
} ExtensionData;
typedef struct extension {
struct extension *next;
enum extension_type type;
ExtensionData data;
} Extension;
/* ================================================== */
/* The main tree node type */
typedef struct treenode {
struct treenode *next;
struct treenode *prev;
struct treenode *parent; /* Back link to the parent
nonterminal, to allow parse tree
traversal later */
struct treenode *bahe; /* Points singly to any bahe node
preceding the current one */
struct treenode *ui_next; /* Indicators linked list */
struct treenode *ui_prev;
/* Extension data if any, NULL if not (bahe/ui might be stuffed on
here when it's shaken down a bit) */
struct extension *ext;
int eols; /* Number of line feeds following token in input */
int start_line, start_column; /* Where does token start in input */
NodeTypes type;
union {
struct marker marker;
struct garbage garbage;
struct cmavo cmavo;
struct zoi zoi;
struct zo zo;
struct zei zei;
struct lohu lohu;
struct bu bu;
struct brivla brivla;
struct cmene cmene;
struct nonterm nonterm;
struct erasure erasure;
} data;
} TreeNode;
struct tk_cmavo {
int selmao;
};
struct tk_marker {
int tok;
};
#endif /* NODES_H */