Natools

Check-in [6f257a4f4d]
Login

Check-in [6f257a4f4d]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Move atom comparison function from Natools.S_Expressions.Interpreters to Natools.S_Expressions
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6f257a4f4dd23cc39cc0b8796b8e7e5175518515
User & Date: nat 2014-05-08 18:36:49.121
Context
2014-05-10
20:43
s_expressions-atom_refs: new package for atom references, taken out from Atom_Buffers check-in: 4627abed57 user: nat tags: trunk
2014-05-08
18:36
Move atom comparison function from Natools.S_Expressions.Interpreters to Natools.S_Expressions check-in: 6f257a4f4d user: nat tags: trunk
2014-04-15
20:16
s_expressions-interpreters: add a null command constant that does nothing check-in: c3bac18f66 user: nat tags: trunk
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/natools-s_expressions-interpreters.adb.
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
11
12
13
14
15
16
17












18
19
20
21
22
23
24







-
-
-
-
-
-
-
-
-
-
-
-







-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES   --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN    --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF  --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.           --
------------------------------------------------------------------------------

package body Natools.S_Expressions.Interpreters is

   ---------------------
   -- Atom Comparison --
   ---------------------

   function Less_Than (Left, Right : Atom) return Boolean is
   begin
      return Left'Length < Right'Length
        or else (Left'Length = Right'Length and then Left < Right);
   end Less_Than;



   -----------------
   -- Interpreter --
   -----------------

   procedure Add_Command
     (Self : in out Interpreter;
Changes to src/natools-s_expressions-interpreters.ads.
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
111
112
113
114
115
116
117


118
119
120
121
122
123
124







-
-







      --  Execute a single command with arguments


private

   type Exception_Command is new Command with null record;

   function Less_Than (Left, Right : Atom) return Boolean;

   package Command_Maps is new Ada.Containers.Indefinite_Ordered_Maps
     (Atom, Command'Class, Less_Than);

   type Interpreter is new Command with record
      Commands : Command_Maps.Map;
      Max_Length : Count := 0;
      Fallback_Name : Atom_Buffers.Atom_Refs.Reference;
Changes to src/natools-s_expressions.adb.
31
32
33
34
35
36
37







38
39
40
41
42
43
44
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51







+
+
+
+
+
+
+







      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;


   function Less_Than (Left, Right : Atom) return Boolean is
   begin
      return Left'Length < Right'Length
        or else (Left'Length = Right'Length and then Left < Right);
   end Less_Than;


   procedure Next (Object : in out Descriptor'Class) is
      Discarded : Events.Event;
      pragma Unreferenced (Discarded);
   begin
      Next (Object, Discarded);
   end Next;
Changes to src/natools-s_expressions.ads.
52
53
54
55
56
57
58


59
60
61
62
63
64
65
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67







+
+







   subtype Count is Ada.Streams.Stream_Element_Count;
   subtype Atom is Ada.Streams.Stream_Element_Array;

   Null_Atom : constant Atom (1 .. 0) := (others => <>);

   function To_String (Data : in Atom) return String;
   function To_Atom (Data : in String) return Atom;

   function Less_Than (Left, Right : Atom) return Boolean;



   -----------------------------
   -- S-expression Descriptor --
   -----------------------------