Index: src/natools-s_expressions-printers.adb ================================================================== --- src/natools-s_expressions-printers.adb +++ src/natools-s_expressions-printers.adb @@ -41,6 +41,36 @@ overriding procedure Close_List (Output : in out Canonical) is begin Output.Stream.Write ((0 => Encodings.List_End)); end Close_List; + + procedure Transfer + (Source : in out Descriptor'Class; + Target : in out Printer'Class) + 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; + begin + loop + case Event is + when Events.Error | Events.End_Of_Input => + exit; + when Events.Open_List => + Target.Open_List; + when Events.Close_List => + 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; Index: src/natools-s_expressions-printers.ads ================================================================== --- src/natools-s_expressions-printers.ads +++ src/natools-s_expressions-printers.ads @@ -37,14 +37,18 @@ 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); + 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;