Natools

Check-in [34988e159c]
Login
Overview
Comment:s_expression: new version of Descriptor.Next without event output
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 34988e159c62a27ebd55f796095c060362ecf64f
User & Date: nat on 2014-03-17 20:00:34
Other Links: manifest | tags
Context
2014-03-18
19:34
s_expressions-printers-pretty-config: new package for serialization and deserialization of pretty printer parameters check-in: 25b0a7d25f user: nat tags: trunk
2014-03-17
20:00
s_expression: new version of Descriptor.Next without event output check-in: 34988e159c user: nat tags: trunk
2014-03-16
13:03
s_expressions-interpreter_tests: add a test for new inspection functions check-in: 24ac878eae user: nat tags: trunk
Changes

Modified src/natools-s_expressions.adb from [2735e7af56] to [b7bd510b03].

1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
-- Copyright (c) 2013, Natacha Porté                                        --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --

|







1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
-- Copyright (c) 2013-2014, Natacha Porté                                   --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
31
32
33
34
35
36
37








38
      return Result : Atom (0 .. Data'Length - 1) do
         for I in Result'Range loop
            Result (I) := Character'Pos (Data (Data'First + Integer (I)));
         end loop;
      end return;
   end To_Atom;









end Natools.S_Expressions;







>
>
>
>
>
>
>
>

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
      return Result : Atom (0 .. Data'Length - 1) do
         for I in Result'Range loop
            Result (I) := Character'Pos (Data (Data'First + Integer (I)));
         end loop;
      end return;
   end To_Atom;


   procedure Next (Object : in out Descriptor'Class) is
      Discarded : Events.Event;
      pragma Unreferenced (Discarded);
   begin
      Next (Object, Discarded);
   end Next;

end Natools.S_Expressions;

Modified src/natools-s_expressions.ads from [e84fc42042] to [f476ab6e67].

1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
-- Copyright (c) 2013, Natacha Porté                                        --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --

|







1
2
3
4
5
6
7
8
9
------------------------------------------------------------------------------
-- Copyright (c) 2013-2014, Natacha Porté                                   --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
102
103
104
105
106
107
108



109
110
111
112
113
114
115
116
117
      --  Copy the current atom in Object to Data.
      --  Must only be called when current event in Object is Add_Event.

   procedure Next
     (Object : in out Descriptor;
      Event : out Events.Event) is abstract;
      --  Update Object to reflect the next event in the S-expression




private

   use type Ada.Streams.Stream_Element;
   use type Ada.Streams.Stream_Element_Offset;
   use type Ada.Streams.Stream_Element_Array;
   use type Events.Event;

end Natools.S_Expressions;







>
>
>









102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
      --  Copy the current atom in Object to Data.
      --  Must only be called when current event in Object is Add_Event.

   procedure Next
     (Object : in out Descriptor;
      Event : out Events.Event) is abstract;
      --  Update Object to reflect the next event in the S-expression

   procedure Next (Object : in out Descriptor'Class);
      --  Call Next discarding current event

private

   use type Ada.Streams.Stream_Element;
   use type Ada.Streams.Stream_Element_Offset;
   use type Ada.Streams.Stream_Element_Array;
   use type Events.Event;

end Natools.S_Expressions;

Modified tests/natools-s_expressions-parsers-tests.adb from [e5f07b4bc7] to [b525d01f34].

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
   procedure Blackbox_Test (Report : in out NT.Reporter'Class) is
   begin
      declare
         Input, Output : aliased Test_Tools.Memory_Stream;
         Printer : Printers.Canonical (Output'Access);
         Parser : aliased Parsers.Parser;
         Sub : Subparser (Parser'Access, Input'Access);
         Event : Events.Event;  --  !
      begin
         Output.Set_Expected (Expected);
         Input.Set_Data (Source);
--       Parser.Next_Event (Input'Access);
         Sub.Next (Event);  --  !

         Printers.Transfer (Sub, Printer);

         Check_Parsing (Report, Name, Parser, Input, Output);
      end;
   exception
      when Error : others => Report.Report_Exception (Name, Error);







<



<
|







88
89
90
91
92
93
94

95
96
97

98
99
100
101
102
103
104
105
   procedure Blackbox_Test (Report : in out NT.Reporter'Class) is
   begin
      declare
         Input, Output : aliased Test_Tools.Memory_Stream;
         Printer : Printers.Canonical (Output'Access);
         Parser : aliased Parsers.Parser;
         Sub : Subparser (Parser'Access, Input'Access);

      begin
         Output.Set_Expected (Expected);
         Input.Set_Data (Source);

         Sub.Next;

         Printers.Transfer (Sub, Printer);

         Check_Parsing (Report, Name, Parser, Input, Output);
      end;
   exception
      when Error : others => Report.Report_Exception (Name, Error);

Modified tests/natools-s_expressions-printers-pretty-tests.adb from [2c8c19248a] to [4985db0008].

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
      Expected : in Atom) is
   begin
      declare
         Input, Output : aliased Test_Tools.Memory_Stream;
         Parser : aliased Parsers.Parser;
         Subparser : Parsers.Subparser (Parser'Access, Input'Access);
         Pretty_Printer : Printer (Output'Access);
         Event : Events.Event;
      begin
         Input.Set_Data (Expected);
         Output.Set_Expected (Expected);
         Pretty_Printer.Set_Parameters (Param);
         Subparser.Next (Event);
         Transfer (Subparser, Pretty_Printer);
         Output.Check_Stream (Test);
      end;
   exception
      when Error : others =>
         Test.Report_Exception (Error);
   end Parse_Print_Test;







<




|







43
44
45
46
47
48
49

50
51
52
53
54
55
56
57
58
59
60
61
      Expected : in Atom) is
   begin
      declare
         Input, Output : aliased Test_Tools.Memory_Stream;
         Parser : aliased Parsers.Parser;
         Subparser : Parsers.Subparser (Parser'Access, Input'Access);
         Pretty_Printer : Printer (Output'Access);

      begin
         Input.Set_Data (Expected);
         Output.Set_Expected (Expected);
         Pretty_Printer.Set_Parameters (Param);
         Subparser.Next;
         Transfer (Subparser, Pretty_Printer);
         Output.Check_Stream (Test);
      end;
   exception
      when Error : others =>
         Test.Report_Exception (Error);
   end Parse_Print_Test;