aboutsummaryrefslogtreecommitdiff
path: root/test/rembero.adb
blob: 301c85cb10fb757c545aa6836992ed1ae50edcfb (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


--  Programmed by Jedidiah Barber
--  Licensed under the Sunset License v1.0

--  See license.txt for further details


with

    Ada.Characters.Latin_1,
    Ada.Text_IO,
    Kompsos.Pretty_Print;


procedure Rembero is

    package Latin renames Ada.Characters.Latin_1;
    package TIO   renames Ada.Text_IO;


    package InKomp is new Kompsos (Integer);
    use InKomp;

    package Printer is new InKomp.Pretty_Print (Integer'Image);


    Relation : Goal := Empty_Goal;

    Item_Term : constant Term := Relation.Fresh;
    List_Term : constant Term := Relation.Fresh;
    Out_Term  : constant Term := Relation.Fresh;

begin

    TIO.Put_Line ("Test program to check if calculating an infinite number of results works.");
    TIO.New_Line;
    TIO.Put_Line ("It will call rembero with variables as all arguments.");
    TIO.Put_Line ("The first 5 results will be displayed.");

    TIO.New_Line;

    Relation.Remove (Item_Term & List_Term & Out_Term);

    declare
        First_Five : constant State_Array := Relation.Run (5);
    begin
        TIO.Put_Line ("Raw results:");
        TIO.Put_Line (Printer.Image (First_Five));

        TIO.New_Line;

        TIO.Put_Line ("Reified results:");
        for Index in First_Five'Range loop
            TIO.Put_Line ("#" & Printer.Image (Index) & ":");
            TIO.Put_Line (Latin.HT & "item: " &
                Printer.Image (Item_Term.Resolve (First_Five (Index))));
            TIO.Put_Line (Latin.HT & "list: " &
                Printer.Image (List_Term.Resolve (First_Five (Index))));
            TIO.Put_Line (Latin.HT & "out: " &
                Printer.Image (Out_Term.Resolve (First_Five (Index))));
        end loop;
    end;

end Rembero;