-
Notifications
You must be signed in to change notification settings - Fork 7
/
terms.c
1719 lines (1439 loc) · 43.5 KB
/
terms.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
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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***************************************
$Header$
Processing to work out which x-place of a particular selbri any term
in the text occupies.
***************************************/
/* COPYRIGHT */
/*{{{ #Includes */
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "functions.h"
#include "rpc_tab.h"
#include "nodes.h"
#include "cmavotab.h"
/*}}}*/
#define MAX_TERMS_IN_VECTOR 20
/* Maximum argument position. Even the most horrific abstraction or
lujvo would be pushed to get this many args!!! */
#define MAX_POS 20
/*+ Value used to denote 'fai' as a place. So fa,fe,fi,fo,fu are
1..5, f[aeiou] xi xa is 6, ... f[aeiou] xi soso is 99, fai or fai xi
pa is 101 etc +*/
#define FAI_OFFSET 101
/* Type definitions *//*{{{*/
typedef enum {
TRM_POS, /* positional, i.e. just bare sumti */
TRM_FA, /* a term with a FA in front */
TRM_FAhI,/* a term with a fa'i in front */
TRM_TAG /* a term with a modal tag in front */
} TermType;
typedef struct TermVectorEntry{
TermType type;
int pos; /* For the FA case, which position the sumti has */
TreeNode *node; /* The treenode corresponding to this term */
} TermVectorEntry;
typedef struct TermVector{
int n_nodes;
TermVectorEntry nodes[MAX_TERMS_IN_VECTOR];
} TermVector;
/*+ Enumeration tags for the LinkConvEntry type. +*/
typedef enum {
LC_LINKS, /* TermVector of sumti links */
LC_SE, /* SE conversion */
LC_JAI, /* JAI conversion */
LC_TAG /* JAI tag conversion */
} LCType;
typedef struct {
int conv;
TreeNode *senode;
} SeInfo;
typedef struct {
LCType type;
union {
TermVector *links;
SeInfo se;
struct {
TreeNode *tag; /* The tag */
TreeNode *inner_tu2; /* The modified tanru_unit_2 */
} jai_tag;
} data;
} LinkConvEntry;
/*+ Structure containing an array of linked sumti blocks and
conversions. This is accumulated whilst drilling down into 'KE
selbri3 KE'E BE links' constructions, which could recurse a lot. +*/
typedef struct {
int n;
LinkConvEntry e[MAX_TERMS_IN_VECTOR];
} LinkConv;
/*}}}*/
/* Forward prototypes *//*{{{*/
static void process_bridi_tail(TreeNode *bt, TermVector *pre, TermVector *post);
static void process_selbri_args(TreeNode *s, TermVector *pre, TermVector *post, LinkConv *lc);
static void process_selbri_3_args(TreeNode *s3, TermVector *pre, TermVector *post, LinkConv *lc);
/*}}}*/
static void tv_init(TermVector *tv)/*{{{*/
{
tv->n_nodes = 0;
}
/*}}}*/
static void tv_catenate(TermVector *s1, TermVector *s2, TermVector *r)/*{{{*/
{
int tn;
int i, n1, n2;
tn = s1->n_nodes + s2->n_nodes;
/* If this is exceeded, we'll need to reassess the design. Really
ought to make the arrays dynamic but that incurs hassle of
releasing them. */
assert(tn <= MAX_TERMS_IN_VECTOR);
n1 = s1->n_nodes;
n2 = s2->n_nodes;
r->n_nodes = tn;
for (i=0; i<n1; i++) {
r->nodes[i] = s1->nodes[i];
}
for (i=0; i<n2; i++) {
r->nodes[n1+i] = s2->nodes[i];
}
}
/*}}}*/
static void tv_reverse(TermVector *dest, TermVector *src)/*{{{*/
{
/* Reverse the order of a Termector. */
int n, i;
assert(dest != src); /* Not designed to cope with this case */
n = dest->n_nodes = src->n_nodes;
for (i=0; i<n; i++) {
dest->nodes[i] = src->nodes[n-1-i];
}
}/*}}}*/
static void lc_init(LinkConv *lc)/*{{{*/
{
/* Initialise a linkconv list to empty */
lc->n = 0;
}
/*}}}*/
static void lc_append_se(LinkConv *lc, int conv, TreeNode *senode)/*{{{*/
{
/* Append a SE conversion to a linkconv chain */
assert(lc->n < MAX_TERMS_IN_VECTOR);
lc->e[lc->n].data.se.conv = conv;
lc->e[lc->n].data.se.senode = senode;
lc->e[lc->n].type = LC_SE;
++(lc->n);
}
/*}}}*/
static void lc_append_jai_tag(LinkConv *lc, TreeNode *tag, TreeNode *inner_tu2)/*{{{*/
{
assert(lc->n < MAX_TERMS_IN_VECTOR);
lc->e[lc->n].data.jai_tag.tag = tag;
lc->e[lc->n].data.jai_tag.inner_tu2 = inner_tu2;
lc->e[lc->n].type = LC_TAG;
++(lc->n);
}
/*}}}*/
static void lc_append_jai(LinkConv *lc)/*{{{*/
{
assert(lc->n < MAX_TERMS_IN_VECTOR);
lc->e[lc->n].type = LC_JAI;
++(lc->n);
}
/*}}}*/
static void lc_append_links(LinkConv *lc, TermVector *v)/*{{{*/
{
/* Append a set of linked sumti to a linkconv chain. Note, a dynamic COPY is
made of 'v'. */
assert(lc->n < MAX_TERMS_IN_VECTOR);
lc->e[lc->n].data.links = new(TermVector);
/* Deep structure copy */
*(lc->e[lc->n].data.links) = *v;
lc->e[lc->n].type = LC_LINKS;
++(lc->n);
}
/*}}}*/
static void lc_copy(const LinkConv *src, LinkConv *dest)/*{{{*/
{
/* Copy a link/conv vector. A semi-deep structure copy is made, i.e. the
pointers to the vectors of linked sumti get aliased. The intention is to
produce a local copy onto which extra terms can be appended, rather than to
make a completely general copy. */
*dest = *src;
}
/*}}}*/
static int recover_se_conv(TreeNode *x)/*{{{*/
{
/* Turn se, te etc into 2..5 */
int se_code;
char *se_str;
TreeNode *se;
se = strip_attitudinal(x);
assert (se->data.cmavo.selmao == SE);
se_code = se->data.cmavo.code;
se_str = cmavo_table[se_code].cmavo;
/* Unfortunately, faxixa, faxize etc to access the 6th places
onwards are just too much to handle for now!! */
if (!strcmp(se_str, "se")) {
return 2;
} else if (!strcmp(se_str, "te")) {
return 3;
} else if (!strcmp(se_str, "ve")) {
return 4;
} else if (!strcmp(se_str, "xe")) {
return 5;
} else {
abort();
}
}
/*}}}*/
static int recover_fa_conv(TreeNode *x)/*{{{*/
{
/* Turn fa, fe... into 1 .. 5
EXTEND TO COPE WITH SUBSCRIPTED VALUES!!!
static int recover_fa_conv Return the value in the range 1 .. 5
corresponding to the FA cmavo.
TreeNode *x The parse node, must be a cmavo of selma'o FA. */
int fa_code;
char *fa_str;
x = strip_attitudinal(x);
assert (x->data.cmavo.selmao == FA);
fa_code = x->data.cmavo.code;
fa_str = cmavo_table[fa_code].cmavo;
/* Unfortunately, faxixa, faxize etc to access the 6th places
onwards are just too much to handle for now!! */
if (!strcmp(fa_str, "fi'a")) {
return 0;
} else if (!strcmp(fa_str, "fa")) {
return 1;
} else if (!strcmp(fa_str, "fe")) {
return 2;
} else if (!strcmp(fa_str, "fi")) {
return 3;
} else if (!strcmp(fa_str, "fo")) {
return 4;
} else if (!strcmp(fa_str, "fu")) {
return 5;
} else if (!strcmp(fa_str, "fai")) {
return FAI_OFFSET;
} else {
abort();
}
}
/*}}}*/
static void tv_build(TermVector *r, TreeNode *x)/*{{{*/
{
/* Build a TermVector from a terms node in the parse tree. Any terms_1
or terms_2 with CEhE or PEhE inside is ignored - to defer the problem of what
to do about afterthought termsets to somewhere else. */
TermVector vv;
TreeNode *xx, *t1, *t2, *t, *tc, *tcc;
struct nonterm *ntx, *ntt;
int nc, ntc;
type_check(x, TERMS);
/* The main hassle is that the <terms> rule is left recursive, so we
build the vector backwards and reverse it at the end. */
tv_init(&vv);
xx = x;
do {
ntx = &xx->data.nonterm;
nc = ntx->nchildren;
if (nc == 1) { /* last term in the series */
t1 = ntx->children[0];
} else if (nc == 2) {
t1 = ntx->children[1];
xx = ntx->children[0]; /* next term in the series */
} else {
abort();
}
type_check(t1, TERMS_1);
/* No point assertion checking whether the children are
nonterminals, they must be from the grammar */
ntt = &t1->data.nonterm;
ntc = ntt->nchildren;
if (ntc > 1) {
/* aaaargh!! termset land */
fprintf(stderr, "No place tagging for termset at line %d\n", t1->start_line);
continue;
}
t2 = ntt->children[0];
type_check(t2, TERMS_2);
ntt = &t2->data.nonterm;
ntc = ntt->nchildren;
if (ntc > 1) {
/* aaaargh!! termset land */
fprintf(stderr, "No place tagging for termset at line %d\n", t2->start_line);
continue;
}
t = ntt->children[0];
assert(t->data.nonterm.type == TERM);
/* Now, what sort of term is it? Have to drill down one layer further */
tc = t->data.nonterm.children[0];
switch (tc->data.nonterm.type) {
case TERM_PLAIN_SUMTI:
vv.nodes[vv.n_nodes].type = TRM_POS;
vv.nodes[vv.n_nodes].node = t;
vv.n_nodes++;
break;
case TERM_PLACED_SUMTI:
{
int pos;
tcc = child_ref(tc, 0);
pos = recover_fa_conv(tcc);
if (pos == 0) {
vv.nodes[vv.n_nodes].type = TRM_FAhI;
vv.nodes[vv.n_nodes].node = t;
vv.nodes[vv.n_nodes].pos = 0;
} else {
vv.nodes[vv.n_nodes].type = TRM_FA;
vv.nodes[vv.n_nodes].node = t;
vv.nodes[vv.n_nodes].pos = pos;
}
vv.n_nodes++;
}
break;
case TERM_TAGGED_SUMTI:
case TAGGED_TERMSET:
vv.nodes[vv.n_nodes].type = TRM_TAG;
vv.nodes[vv.n_nodes].node = t;
vv.n_nodes++;
break;
case TERMSET:
fprintf(stderr, "No place tagging for termset at line %d\n", t->start_line);
break;
case TERM_FLOATING_TENSE:
case TERM_FLOATING_NEGATE:
case TERM_OTHER:
default:
/* None of these are interesting for place tagging */
break;
}
} while (nc == 2); /* Keep looping whilst were in the left recursive <terms> rule */
/* Reverse the order to put the terms in natural order */
tv_reverse(r, &vv);
}
/*}}}*/
static void process_subsentence(TreeNode *ss, TermVector *pre, TermVector *post)/*{{{*/
{
struct nonterm *nt, *ntc;
int nc;
TreeNode *sss;
TreeNode *c;
TermVector head_terms, new_pre;
TreeNode *terms, *btail;
sss = ss;
do {
type_check(ss, SUBSENTENCE);
nt = &sss->data.nonterm;
nc = nt->nchildren;
if (nc == 2) {
/* Pick the 'subsentence' following the 'prenex' out of the 2 child version */
sss = child_ref(sss, 1);
} else {
/* Pick 'sentence' out of the 1 child version */
sss = child_ref(sss, 0);
}
} while (nc == 2);
type_check(sss, SENTENCE);
nt = &sss->data.nonterm;
if (nt->nchildren == 1) {
c = nt->children[0];
if (c->type == N_NONTERM) {
ntc = & c->data.nonterm;
if ((ntc->type == NO_CU_SENTENCE) || (ntc->type == OBSERVATIVE_SENTENCE)) {
sss = c;
nt = ntc;
}
}
}
/* Now looking at the '[terms [CU #]] bridi_tail' node. */
terms = find_nth_child(sss, 1, TERMS);
btail = find_nth_child(sss, 1, BRIDI_TAIL);
assert(btail); /* Every sentence has one of these! */
if (terms) {
tv_build(&head_terms, terms);
tv_catenate(pre, &head_terms, &new_pre);
process_bridi_tail(btail, &new_pre, post);
} else {
process_bridi_tail(btail, pre, post);
}
}
/*}}}*/
/* Type definitions (tags, places etc) *//*{{{*/
typedef enum {
PT_ORD, /* one of the x1 .. x5 of the BRIVLA etc */
PT_TAG, /* e.g. the x1 of 'jai bau cusku' */
PT_JAI /* e.g. the x1 of 'jai rinka' */
} PlaceType;
typedef struct {
TreeNode *tag;
TreeNode *inner_tu2;
} TagPlace;
typedef struct {
int pad;
} JaiPlace;
typedef struct {
PlaceType type;
int valid;
int taken;
int pos;
TagPlace tag;
JaiPlace jai;
} Place;
/*}}}*/
static void fixup_term_place(TreeNode *x, Place *pl, XTermTag *tt)/*{{{*/
{
/* Given a term treenode and a single place descriptor, chain the place
information to the node's property list for later display. */
XTermTags *ts, *nts;
type_check(x, TERM);
ts = prop_term_tags(x, NO);
if (ts) {
while(ts->next) ts = ts->next; /* Get to end of list */
nts = new(XTermTags);
ts->next = nts;
nts->next = NULL;
ts = nts;
} else {
ts = prop_term_tags(x, YES); /* Create it */
ts->next = NULL;
}
ts->tag = *tt; /* deep copy, tt is in automatic storage */
ts->tag.pos = pl->pos;
switch (pl->type) {
case PT_ORD:
break;
case PT_TAG:
ts->tag.jaitag.tag = pl->tag.tag;
ts->tag.jaitag.inner_tu2 = pl->tag.inner_tu2;
ts->tag.type = TTT_JAITAG;
break;
case PT_JAI:
ts->tag.type = TTT_JAI;
break;
}
}/*}}}*/
static void assign_terms_to_places(TermVector *t, Place *place, Place *fai, int abase, XTermTag *tt)/*{{{*/
{
int i, n;
int base;
int pos;
base = abase;
/* Assign FA places */
n = t->n_nodes;
for (i=0; i<n; i++) {
if (t->nodes[i].type == TRM_FA) {
pos = t->nodes[i].pos;
if (pos < FAI_OFFSET) {
if (place[pos].valid) {
fixup_term_place(t->nodes[i].node, &place[pos], tt);
place[pos].taken = 1;
} else {
fprintf(stderr, "Invalid place\n");
}
} else {
pos -= FAI_OFFSET;
pos++;
if (fai[pos].valid) {
fixup_term_place(t->nodes[i].node, &fai[pos], tt);
fai[pos].taken = 1;
} else {
fprintf(stderr, "Invalid place\n");
}
}
}
}
/* Now fix up unmarked places */
for (i=0; i<n; i++) {
switch (t->nodes[i].type) {
case TRM_POS :
/* Look for first unassigned place */
while (place[base].taken) ++base;
if (base > MAX_POS) {
fprintf(stderr, "Too many places assigned\n");
} else {
fixup_term_place(t->nodes[i].node, &place[base], tt);
place[base].taken = 1;
++base;
}
break;
case TRM_FA :
pos = t->nodes[i].pos;
if (pos < FAI_OFFSET) {
base = pos + 1;
}
break;
default:
break;
}
}
}
/*}}}*/
static void assign_conversion(LinkConv *lc, TreeNode *convertible)/*{{{*/
{
Place place[MAX_POS];
XConversion *ext;
int i, n;
/* Init the place and vectors */
for (i=0; i<MAX_POS; i++) {
place[i].valid = 1;
place[i].taken = 0;
place[i].type = PT_ORD;
place[i].pos = i;
}
/* Work back through the linked sumti */
n = lc->n;
for (i=n-1; i>=0; i--) {
switch (lc->e[i].type) {
case LC_SE:
/* Just swap 2 positions in the place[] array */
{
Place temp;
SeInfo *j;
XDontGloss *dg;
j = &lc->e[i].data.se;
temp = place[1];
place[1] = place[j->conv];
place[j->conv] = temp;
dg = prop_dont_gloss(j->senode, YES); /* prevent the node being glossed */
}
break;
case LC_LINKS:
/* Binding of linked sumti does not affect the glossing of the
brivla or whatever, just drop through to next loop
iteration */
break;
case LC_TAG:
/* Break out at this point */
goto loop_done;
break;
case LC_JAI:
fprintf(stderr, "Don't know what to do with <jai> for gloss conversion\n");
break;
}
}
loop_done:
ext = prop_conversion(convertible, YES);
ext->conv = place[1].pos;
}
/*}}}*/
static void assign_places(TermVector *pre, TermVector *post, LinkConv *lc, XTermTag *tt)/*{{{*/
{
/* Work out which terms have which places in the bridi, and tag them
accordingly */
/* Variable declarations */
/*+ Array for the ordinary places in the bridi. e.g. if you get a
term with 'fe' in front of it, look in place[2] to find what to do
with it. +*/
Place place[MAX_POS];
/*+ Array for the 'fai' places. e.g. if a term has 'fai xi re' in
front, look in fai[2] to find what to do. +*/
Place fai[MAX_POS];
int i, n;
/* Init the place and fai vectors */
for (i=0; i<MAX_POS; i++) {
place[i].valid = 1;
place[i].taken = 0;
place[i].type = PT_ORD;
place[i].pos = i;
fai[i].valid = 0;
fai[i].taken = 0;
}
/* Work back through the linked sumti */
n = lc->n;
for (i=n-1; i>=0; i--) {
switch (lc->e[i].type) {
case LC_SE:
/* Just swap 2 positions in the place[] array */
{
Place temp;
SeInfo *j;
j = &lc->e[i].data.se;
temp = place[1];
place[1] = place[j->conv];
place[j->conv] = temp;
}
break;
case LC_TAG:
{
int j;
/* Shift fai place array up (i.e. need subscripts if more
than one fai place is in scope). */
for (j=1; ; j++) {
if (!fai[j].valid) break;
}
for (; j>1; j--) {
fai[j] = fai[j-1];
}
fai[1] = place[1];
place[1].type = PT_TAG;
place[1].valid = 1;
place[1].tag.tag = lc->e[i].data.jai_tag.tag;
place[1].tag.inner_tu2 = lc->e[i].data.jai_tag.inner_tu2;
}
break;
case LC_JAI:
{
int j;
/* Shift fai place array up (i.e. need subscripts if more
than one fai place is in scope). */
for (j=1; ; j++) {
if (!fai[j].valid) break;
}
for (; j>1; j--) {
fai[j] = fai[j-1];
}
fai[1] = place[1];
place[1].type = PT_ORD;
place[1].valid = 1;
}
break;
case LC_LINKS:
assign_terms_to_places(lc->e[i].data.links, place, fai, 2, tt);
break;
}
}
/* Do the pre and post terms */
assign_terms_to_places(pre, place, fai, 1, tt);
assign_terms_to_places(post, place, fai, 2, tt);
}
/*}}}*/
static void process_tanru_unit_2_args(TreeNode *tu2, TermVector *pre, TermVector *post, LinkConv *lc)/*{{{*/
{
/* Handle argument processing at the level of a tanru_unit_2. This is
where the clever tag assignment stuff is done! */
TreeNode *c1;
type_check(tu2, TANRU_UNIT_2);
c1 = maybe_strip_attitudinal(child_ref(tu2, 0));
if (c1->type == N_CMAVO) {/*{{{*/
switch (c1->data.cmavo.selmao) {
case GOhA:/*{{{*/
{
XTermTag tt;
tt.type = TTT_GOhA;
tt.goha.goha = c1;
assign_places(pre, post, lc, &tt);
assign_conversion(lc, c1);
}
break;/*}}}*/
case ME:/*{{{*/
{
XTermTag tt;
XRequireBrac *xrb;
TreeNode *me_node;
tt.type = TTT_ME;
tt.me.sumti = find_nth_child(tu2, 1, SUMTI);
me_node = find_nth_cmavo_child(tu2, 1, ME);
assert(tt.me.sumti);
xrb = prop_require_brac (tt.me.sumti, YES);
assign_places(pre, post, lc, &tt);
/* Conversion can't occur on ME, there is only an x1 place */
}
break;/*}}}*/
case NUhA:/*{{{*/
{
XTermTag tt;
XRequireBrac *xrb;
tt.type = TTT_NUhA;
tt.nuha.mex_operator = find_nth_child(tu2, 1, MEX_OPERATOR);
assign_places(pre, post, lc, &tt);
assign_conversion(lc, c1);
xrb = prop_require_brac (tt.nuha.mex_operator, YES);
}
break;/*}}}*/
}
/*}}}*/
} else if (c1->type == N_BRIVLA) {/*{{{*/
XTermTag tt;
tt.type = TTT_BRIVLA;
tt.brivla.x = c1;
assign_places(pre, post, lc, &tt);
assign_conversion(lc, c1);/*}}}*/
} else if (c1->type == N_NONTERM) {
switch (c1->data.nonterm.type) {
case NUMBER_MOI_TU2:/*{{{*/
{
TreeNode *norl, *moi;
XRequireBrac *xrb;
XTermTag tt;
/* Remember : The NUMBER_MOI marker that's in the bison file is NOT
built into the parse tree!! */
norl = child_ref(c1, 0);
moi = find_nth_cmavo_child(c1, 1, MOI);
tt.type = TTT_NUMBERMOI;
tt.numbermoi.number_or_lerfu = norl;
tt.numbermoi.moi = moi;
assign_places(pre, post, lc, &tt);
if ((pre->n_nodes > 0) ||
(post->n_nodes > 0)) {
xrb = prop_require_brac (norl, YES);
}
}
break;
/*}}}*/
case KE_SELBRI3_TU2:/*{{{*/
{
TreeNode *cs3;
cs3 = find_nth_child(c1, 1, SELBRI_3);
assert(cs3);
process_selbri_3_args(cs3, pre, post, lc);
}
break;/*}}}*/
case SE_TU2:/*{{{*/
{
LinkConv newlc;
int conv;
TreeNode *se_child, *tu2_child;
lc_copy(lc, &newlc);
se_child = child_ref(c1, 0);
tu2_child = find_nth_child(c1, 1, TANRU_UNIT_2);
assert(tu2_child);
conv = recover_se_conv(se_child);
lc_append_se(&newlc, conv, se_child);
process_tanru_unit_2_args(tu2_child, pre, post, &newlc);
}
break;/*}}}*/
case JAI_TAG_TU2:/*{{{*/
{
LinkConv newlc;
TreeNode *ctag, *tu2_child;
XRequireBrac *xrb;
lc_copy(lc, &newlc);
ctag = find_nth_child(c1, 1, TAG);
tu2_child = find_nth_child(c1, 1, TANRU_UNIT_2);
assert(ctag);
assert(tu2_child);
lc_append_jai_tag(&newlc, ctag, tu2_child);
xrb = prop_require_brac(tu2_child, YES);
process_tanru_unit_2_args(tu2_child, pre, post, &newlc);
}
break;
/*}}}*/
case JAI_TU2:/*{{{*/
{
LinkConv newlc;
TreeNode *tu2_child;
lc_copy(lc, &newlc);
tu2_child = find_nth_child(c1, 1, TANRU_UNIT_2);
assert(tu2_child);
lc_append_jai(&newlc);
process_tanru_unit_2_args(tu2_child, pre, post, &newlc);
}
break;
/*}}}*/
case NAHE_TU2:/*{{{*/
{
TreeNode *tu2_child;
tu2_child = find_nth_child(c1, 1, TANRU_UNIT_2);
assert(tu2_child);
process_tanru_unit_2_args(tu2_child, pre, post, lc);
}
break;
/*}}}*/
case ABSTRACTION:/*{{{*/
{
TreeNode *nns, *c2, *nu, *nai;
XTermTag tt;
nns = child_ref(c1, 0);
type_check(nns, NU_NAI_SEQ);
c2 = maybe_strip_attitudinal(child_ref(nns, 0));
if ((c2->type == N_CMAVO) &&
(c2->data.cmavo.selmao == NU)) {
/* A simple NU <subsentence> thing */
nu = c2;
/* Maybe null - not sure what to do with it as I haven't
seen any examples */
nai = find_nth_child(nns, 1, NAI);
if (nai) {
fprintf(stderr, "Don't know how to handle negated abstractor yet at line %d column %d - ignoring negation\n",
c1->start_line, c1->start_column);
}
tt.type = TTT_ABSTRACTION;
tt.abstraction.nu = nu;
assign_places(pre, post, lc, &tt);
assign_conversion(lc, nu);
} else {
fprintf(stderr, "Can't handle connected abstractors wrt places yet at line %d column %d\n",
c1->start_line, c1->start_column);
}
}
break;
/*}}}*/
default:
break;
}
} else if (c1->type == N_ZEI) {/*{{{*/
XTermTag tt;
tt.type = TTT_ZEI;
tt.zei.zei = c1;
assign_places(pre, post, lc, &tt);
assign_conversion(lc, c1);
/*}}}*/
} else {
abort();
}
}
/*}}}*/
static void process_tanru_unit_1_args(TreeNode *tu1, TermVector *pre, TermVector *post, LinkConv *lc)/*{{{*/
{
/* Handle argument processing at the level of a tanru_unit_1. */
XTermVector *xtv; /* The linked sumti vector of the tu1 if any */
XDoneTU1 *xdtu1; /* Property whose existence on the TU1 tree node
shows we have processed its linked sumti */
TreeNode *tu2;
xtv = prop_term_vector(tu1, NO);
tu2 = child_ref(tu1, 0);
if (xtv) {
LinkConv newlc;
lc_copy(lc, &newlc);
lc_append_links(&newlc, xtv->vec);
process_tanru_unit_2_args(tu2, pre, post, &newlc);
} else {
process_tanru_unit_2_args(tu2, pre, post, lc);
}
/* Put marker on the TU1 node so that we know its linked sumti have
now been processed. Later on we scan the entire parse tree for
TU1 nodes that don't have this property already set - these are
ones that are not part of tertau */
xdtu1 = prop_done_tu1(tu1, YES);
}
/*}}}*/
static void process_selbri_6_args(TreeNode *s6, TermVector *pre, TermVector *post, LinkConv *lc)/*{{{*/
{
/* Drill down into a selbri_6 etc */
TreeNode *tu, *tu1, *cs6, *cs;
/* For the cases with BO, I think it's only the very final term
that's relevant. For the guhek cases, I think these are like
connectives, in selbri_4/5, it's like gek_sentence?? */
type_check(s6, SELBRI_6);
if (nch(s6) == 1) {
tu = child_ref(s6, 0); /* Always first child */
if (nch(tu) > 1) {
fprintf(stderr, "tanru_unit at line %d column %d contains CEI, can't handle this yet\n",
tu->start_line, tu->start_column);
} else {
tu1 = child_ref(tu, 0);
process_tanru_unit_1_args(tu1, pre, post, lc);
}
} else {
tu = find_nth_child(s6, 1, TANRU_UNIT);
if (tu) {
/* BO form */
cs6 = find_nth_child(s6, 1, SELBRI_6);
process_selbri_6_args(cs6, pre, post, lc);
} else {
cs = find_nth_child(s6, 1, SELBRI);
cs6 = find_nth_child(s6, 1, SELBRI_6);
process_selbri_args(cs, pre, post, lc);
process_selbri_6_args(cs6, pre, post, lc);
}
}
}
/*}}}*/
static void process_selbri_5_args(TreeNode *s5, TermVector *pre, TermVector *post, LinkConv *lc)/*{{{*/
{
/* Drill down into a selbri_5 etc */
TreeNode *s6, *cs5;
cs5 = s5;
do {
s6 = find_nth_child(cs5, 1, SELBRI_6);
process_selbri_6_args(s6, pre, post, lc);
cs5 = find_nth_child(cs5, 1, SELBRI_5);
} while (cs5);
}
/*}}}*/
static void process_selbri_3_args(TreeNode *s3, TermVector *pre, TermVector *post, LinkConv *lc)/*{{{*/
{
/* Drill down into a selbri_3 to try to recover a single tanru_unit_2 which is
the tertau. Apply the supplied args to that - i.e. work out the place