summaryrefslogtreecommitdiff
path: root/test/rat_tests-parse_graphs.adb
blob: e445f1b5622ea99a3849ea8f3b538c611e0694a3 (plain)
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


with Packrat.Parse_Graphs;


package body Rat_Tests.Parse_Graphs is


    type My_Labels is
       (Noun, Determiner, Noun_Phrase, Preposition,
        Prepositional_Phrase, Verb, Verb_Phrase, Sentence);

    package String_Tokens is new Packrat.Tokens (My_Labels, Character, String);
    package Graphs is new Packrat.Parse_Graphs (My_Labels, Character, String, "<", String_Tokens);


    --  These tokens are defined here purely to reduce verbosity when
    --  manually constructing the various test graphs in the package initialisation.

    Noun_1  : String_Tokens.Token := String_Tokens.Create (Noun, 1, "i");
    Noun_4  : String_Tokens.Token := String_Tokens.Create (Noun, 4, "man");
    Noun_7  : String_Tokens.Token := String_Tokens.Create (Noun, 7, "park");
    Noun_10 : String_Tokens.Token := String_Tokens.Create (Noun, 10, "bat");

    Det_3 : String_Tokens.Token := String_Tokens.Create (Determiner, 3, "a");
    Det_6 : String_Tokens.Token := String_Tokens.Create (Determiner, 6, "the");
    Det_9 : String_Tokens.Token := String_Tokens.Create (Determiner, 9, "a");

    NP_1 : String_Tokens.Token := String_Tokens.Create (Noun_Phrase, 1, "");
    NP_3 : String_Tokens.Token := String_Tokens.Create (Noun_Phrase, 3, "");
    NP_6 : String_Tokens.Token := String_Tokens.Create (Noun_Phrase, 6, "");
    NP_9 : String_Tokens.Token := String_Tokens.Create (Noun_Phrase, 9, "");

    Prep_5 : String_Tokens.Token := String_Tokens.Create (Preposition, 5, "in");
    Prep_8 : String_Tokens.Token := String_Tokens.Create (Preposition, 8, "with");

    PP_5 : String_Tokens.Token := String_Tokens.Create (Prepositional_Phrase, 5, "");
    PP_8 : String_Tokens.Token := String_Tokens.Create (Prepositional_Phrase, 8, "");

    Verb_2 : String_Tokens.Token := String_Tokens.Create (Verb, 2, "saw");

    VP_2 : String_Tokens.Token := String_Tokens.Create (Verb_Phrase, 2, "");

    Sen_1 : String_Tokens.Token := String_Tokens.Create (Sentence, 1, "");


    --  This should be set up to be identical to the example parse in the paper
    --  on pages 168-169.

    Paper_Graph : Graphs.Parse_Graph;




    function Debug_String_Check
        return String is
    begin
        return Paper_Graph.Debug_String;
    end Debug_String_Check;




    function Assign_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Assign_Check;


    function Copy_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Copy_Check;


    function Move_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Move_Check;





    function Is_Empty_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Is_Empty_Check;


    function Clear_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Clear_Check;





    function Contains_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Contains_Check;


    function Reachable_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Reachable_Check;


    function All_Reachable_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end All_Reachable_Check;


    function Valid_Starts_Finishes_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Valid_Starts_Finishes_Check;


    function No_Loops_Introduced_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end No_Loops_Introduced_Check;


    function Is_Sorted_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Is_Sorted_Check;


    function No_Duplicates_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end No_Duplicates_Check;





    function Include_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Include_Check;


    function Connect_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Connect_Check;


    function Prune_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Prune_Check;


    function Delete_Unreachable_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Delete_Unreachable_Check;





    function Has_Root_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Has_Root_Check;


    function Set_Root_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Set_Root_Check;


    function Clear_Root_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Clear_Root_Check;


    function Root_Token_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Root_Token_Check;


    function Root_Finish_List_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Root_Finish_List_Check;


    function Root_Element_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Root_Element_Check;





    function Finish_List_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Finish_List_Check;


    function Is_Leaf_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Is_Leaf_Check;


    function Is_Branch_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Is_Branch_Check;





    function Subgroups_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Subgroups_Check;


    function First_Index_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end First_Index_Check;


    function Last_Index_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Last_Index_Check;


    function Length_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Length_Check;


    function Element_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Element_Check;


    function Elements_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Elements_Check;


    function Parent_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Parent_Check;


    function Finish_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Finish_Check;





    function Is_Root_Ambiguous_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Is_Root_Ambiguous_Check;


    function Is_Ambiguous_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Is_Ambiguous_Check;


    function Ambiguities_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Ambiguities_Check;





    function Isomorphic_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Isomorphic_Check;


    function Isomorphic_Subgraph_Check
        return Test_Result
    is
    begin
        --  to-do
        return Fail;
    end Isomorphic_Subgraph_Check;


begin


    --  Constructing the various test graphs

    Paper_Graph.Connect ((NP_1, 2),
       (1 => Graphs.Finished_Token'(Noun_1, 2)));
    Paper_Graph.Connect ((NP_3, 5),
       ((Det_3, 4), (Noun_4, 5)));
    Paper_Graph.Connect ((NP_3, 8),
       ((NP_3, 5), (PP_5, 8)));
    Paper_Graph.Connect ((NP_3, 11),
       ((NP_3, 5), (PP_5, 11)));
    Paper_Graph.Connect ((NP_3, 11),
       ((NP_3, 8), (PP_8, 11)));
    Paper_Graph.Connect ((NP_6, 8),
       ((Det_6, 7), (Noun_7, 8)));
    Paper_Graph.Connect ((NP_6, 11),
       ((NP_6, 8), (PP_8, 11)));
    Paper_Graph.Connect ((NP_9, 11),
       ((Det_9, 10), (Noun_10, 11)));

    Paper_Graph.Connect ((PP_5, 8),
       ((Prep_5, 6), (NP_6, 8)));
    Paper_Graph.Connect ((PP_5, 11),
       ((Prep_5, 6), (NP_6, 11)));
    Paper_Graph.Connect ((PP_8, 11),
       ((Prep_8, 9), (NP_9, 11)));

    Paper_Graph.Connect ((VP_2, 5),
       ((Verb_2, 3), (NP_3, 5)));
    Paper_Graph.Connect ((VP_2, 8),
       ((Verb_2, 3), (NP_3, 8)));
    Paper_Graph.Connect ((VP_2, 11),
       ((Verb_2, 3), (NP_3, 11)));

    Paper_Graph.Connect ((Sen_1, 5),
       ((NP_1, 2), (VP_2, 5)));
    Paper_Graph.Connect ((Sen_1, 8),
       ((NP_1, 2), (VP_2, 8)));
    Paper_Graph.Connect ((Sen_1, 8),
       ((Sen_1, 5), (PP_5, 8)));
    Paper_Graph.Connect ((Sen_1, 11),
       ((NP_1, 2), (VP_2, 11)));
    Paper_Graph.Connect ((Sen_1, 11),
       ((Sen_1, 5), (PP_5, 11)));
    Paper_Graph.Connect ((Sen_1, 11),
       ((Sen_1, 8), (PP_8, 11)));

    Paper_Graph.Set_Root (Sen_1, (5, 8, 11));


end Rat_Tests.Parse_Graphs;