Natools

Check-in [02db3410f5]
Login
Overview
Comment:s_expressions-printers: add an option for Transfer to stay in the current nesting level
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 02db3410f5589a1864ba9a96a00820bde1b54c8a
User & Date: nat on 2014-09-10 19:08:14
Other Links: manifest | tags
Context
2014-09-11
19:19
s_expressions-generic_caches: add Move functions to build a cache directly from a descriptor check-in: 86680251f9 user: nat tags: trunk
2014-09-10
19:08
s_expressions-printers: add an option for Transfer to stay in the current nesting level check-in: 02db3410f5 user: nat tags: trunk
2014-09-09
18:36
s_expressions-cache_tests: add a test for the new replayable interface check-in: dd07424307 user: nat tags: trunk
Changes

Modified src/natools-s_expressions-printers.adb from [a821173aae] to [52aa58b1a0].

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
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







-
+
+









+








+
+










   begin
      Output.Stream.Write ((0 => Encodings.List_End));
   end Close_List;


   procedure Transfer
     (Source : in out Descriptor'Class;
      Target : in out Printer'Class)
      Target : in out Printer'Class;
      Check_Level : in Boolean := False)
   is
      procedure Print_Atom (Data : in Atom);

      procedure Print_Atom (Data : in Atom) is
      begin
         Target.Append_Atom (Data);
      end Print_Atom;

      Event : Events.Event := Source.Current_Event;
      Starting_Level : constant Natural := Source.Current_Level;
   begin
      loop
         case Event is
            when Events.Error | Events.End_Of_Input =>
               exit;
            when Events.Open_List =>
               Target.Open_List;
            when Events.Close_List =>
               exit when Check_Level
                 and then Source.Current_Level < Starting_Level;
               Target.Close_List;
            when Events.Add_Atom =>
               Source.Query_Atom (Print_Atom'Access);
         end case;

         Source.Next (Event);
      end loop;
   end Transfer;

end Natools.S_Expressions.Printers;

Modified src/natools-s_expressions-printers.ads from [fea555b603] to [d999b2268e].

37
38
39
40
41
42
43
44


45
46
47
48
49
50
51
52
53
54
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53
54
55







-
+
+











   procedure Open_List (Output : in out Printer) is abstract;
   procedure Append_Atom (Output : in out Printer; Data : in Atom) is abstract;
   procedure Close_List (Output : in out Printer) is abstract;

   procedure Transfer
     (Source : in out Descriptor'Class;
      Target : in out Printer'Class);
      Target : in out Printer'Class;
      Check_Level : in Boolean := False);

   type Canonical (Stream : access Ada.Streams.Root_Stream_Type'Class) is
     new Printer with null record;

   overriding procedure Open_List (Output : in out Canonical);
   overriding procedure Append_Atom (Output : in out Canonical;
                                     Data : in Atom);
   overriding procedure Close_List (Output : in out Canonical);

end Natools.S_Expressions.Printers;