Natools

Check-in [1cc98d90f5]
Login
Overview
Comment:static_hash_maps-s_expressions: add commands for definite or indefinite elements
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1cc98d90f557c1913a9c2345e12ded1b55857e70
User & Date: nat on 2014-11-09 20:48:10
Other Links: manifest | tags
Context
2014-11-26
20:13
references: add Implicit_Dereference aspects check-in: 3a18c0edc9 user: nat tags: trunk
2014-11-09
20:48
static_hash_maps-s_expressions: add commands for definite or indefinite elements check-in: 1cc98d90f5 user: nat tags: trunk
2014-11-08
21:24
static_hash_maps: allow elements to be indefinite by looking them up in a function rather than an array check-in: ba447ff2ea user: nat tags: trunk
Changes

Modified generated/natools-static_hash_maps-s_expressions-command_map.adb from [e6140e570c] to [1306be82db].

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
with Interfaces; use Interfaces;

package body Natools.Static_Hash_Maps.S_Expressions.Command_Map is

   P : constant array (0 .. 0) of Natural :=
     (0 .. 0 => 3);

   T1 : constant array (0 .. 0) of Unsigned_8 :=
     (0 .. 0 => 8);

   T2 : constant array (0 .. 0) of Unsigned_8 :=
     (0 .. 0 => 5);

   G : constant array (0 .. 8) of Unsigned_8 :=
     (0, 0, 0, 0, 3, 1, 0, 2, 0);

   function Hash (S : String) return Natural is
      F : constant Natural := S'First - 1;
      L : constant Natural := S'Length;
      F1, F2 : Natural := 0;
      J : Natural;
   begin
      for K in P'Range loop
         exit when L < P (K);
         J  := Character'Pos (S (P (K) + F));
         F1 := (F1 + Natural (T1 (K)) * J) mod 9;
         F2 := (F2 + Natural (T2 (K)) * J) mod 9;
      end loop;
      return (Natural (G (F1)) + Natural (G (F2))) mod 4;
   end Hash;

end Natools.Static_Hash_Maps.S_Expressions.Command_Map;




|
|

|
|

|
|

|
|










|
|

|



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
with Interfaces; use Interfaces;

package body Natools.Static_Hash_Maps.S_Expressions.Command_Map is

   P : constant array (0 .. 2) of Natural :=
     (1, 9, 11);

   T1 : constant array (0 .. 2) of Unsigned_8 :=
     (0, 16, 5);

   T2 : constant array (0 .. 2) of Unsigned_8 :=
     (10, 9, 15);

   G : constant array (0 .. 17) of Unsigned_8 :=
     (0, 1, 5, 0, 0, 0, 5, 0, 0, 0, 0, 0, 6, 7, 0, 3, 2, 0);

   function Hash (S : String) return Natural is
      F : constant Natural := S'First - 1;
      L : constant Natural := S'Length;
      F1, F2 : Natural := 0;
      J : Natural;
   begin
      for K in P'Range loop
         exit when L < P (K);
         J  := Character'Pos (S (P (K) + F));
         F1 := (F1 + Natural (T1 (K)) * J) mod 18;
         F2 := (F2 + Natural (T2 (K)) * J) mod 18;
      end loop;
      return (Natural (G (F1)) + Natural (G (F2))) mod 8;
   end Hash;

end Natools.Static_Hash_Maps.S_Expressions.Command_Map;

Modified generated/natools-static_hash_maps-s_expressions-command_maps-test.adb from [4ca212829b] to [c3cc0c6571].

1
2
3
4
5
6
7
8
9
--  Generated at 2014-05-31 15:03:28 +0000 by Natools.Static_Hash_Maps
--  from natools-static_hash_maps-s_expressions-hash_maps.sx

with Natools.Static_Hash_Maps.S_Expressions.Command_Pkg;
with Natools.Static_Hash_Maps.S_Expressions.Command_Map;
function Natools.Static_Hash_Maps.S_Expressions.Command_Maps.Test
  return Boolean is
begin
   for I in Map_1_Keys'Range loop
|
|







1
2
3
4
5
6
7
8
9
--  Generated at 2014-11-09 20:46:38 +0000 by Natools.Static_Hash_Maps
--  from src/natools-static_hash_maps-s_expressions-hash_maps.sx

with Natools.Static_Hash_Maps.S_Expressions.Command_Pkg;
with Natools.Static_Hash_Maps.S_Expressions.Command_Map;
function Natools.Static_Hash_Maps.S_Expressions.Command_Maps.Test
  return Boolean is
begin
   for I in Map_1_Keys'Range loop

Modified generated/natools-static_hash_maps-s_expressions-command_maps-test.ads from [4053b539ac] to [510e543dc6].

1
2
3
4
5
--  Generated at 2014-05-31 15:03:28 +0000 by Natools.Static_Hash_Maps
--  from natools-static_hash_maps-s_expressions-hash_maps.sx

function Natools.Static_Hash_Maps.S_Expressions.Command_Maps.Test
  return Boolean;
|
|



1
2
3
4
5
--  Generated at 2014-11-09 20:46:38 +0000 by Natools.Static_Hash_Maps
--  from src/natools-static_hash_maps-s_expressions-hash_maps.sx

function Natools.Static_Hash_Maps.S_Expressions.Command_Maps.Test
  return Boolean;

Modified generated/natools-static_hash_maps-s_expressions-command_maps.adb from [b6be33832f] to [8596a10278].

1
2
3
4
5
6
7
8
9
--  Generated at 2014-05-31 15:03:28 +0000 by Natools.Static_Hash_Maps
--  from natools-static_hash_maps-s_expressions-hash_maps.sx

with Natools.Static_Hash_Maps.S_Expressions.Command_Pkg;
with Natools.Static_Hash_Maps.S_Expressions.Command_Map;

package body Natools.Static_Hash_Maps.S_Expressions.Command_Maps is

   function To_Package_Command (Key : String) return Package_Command is
|
|







1
2
3
4
5
6
7
8
9
--  Generated at 2014-11-09 20:46:38 +0000 by Natools.Static_Hash_Maps
--  from src/natools-static_hash_maps-s_expressions-hash_maps.sx

with Natools.Static_Hash_Maps.S_Expressions.Command_Pkg;
with Natools.Static_Hash_Maps.S_Expressions.Command_Map;

package body Natools.Static_Hash_Maps.S_Expressions.Command_Maps is

   function To_Package_Command (Key : String) return Package_Command is

Modified generated/natools-static_hash_maps-s_expressions-command_maps.ads from [0eaa976a29] to [a84758ce2d].

1
2
3
4
5
6
7
8
9
--  Generated at 2014-05-31 15:03:28 +0000 by Natools.Static_Hash_Maps
--  from natools-static_hash_maps-s_expressions-hash_maps.sx

private package Natools.Static_Hash_Maps.S_Expressions.Command_Maps is

   function To_Package_Command (Key : String) return Package_Command;
   function To_Map_Command (Key : String) return Map_Command;

private
|
|







1
2
3
4
5
6
7
8
9
--  Generated at 2014-11-09 20:46:38 +0000 by Natools.Static_Hash_Maps
--  from src/natools-static_hash_maps-s_expressions-hash_maps.sx

private package Natools.Static_Hash_Maps.S_Expressions.Command_Maps is

   function To_Package_Command (Key : String) return Package_Command;
   function To_Map_Command (Key : String) return Map_Command;

private
28
29
30
31
32
33
34
35
36
37
38




39
40
41
42
43




44




45
46
47
48
49
50
         Extra_Declarations,
         Private_Child,
         Public_Child,
         Pure_Package,
         Preelaborate_Package,
         Test_Function);

   Map_2_Key_0 : aliased constant String := "hash-package";
   Map_2_Key_1 : aliased constant String := "nodes";
   Map_2_Key_2 : aliased constant String := "function";
   Map_2_Key_3 : aliased constant String := "not-found";




   Map_2_Keys : constant array (0 .. 3) of access constant String
     := (Map_2_Key_0'Access,
         Map_2_Key_1'Access,
         Map_2_Key_2'Access,
         Map_2_Key_3'Access);




   Map_2_Elements : constant array (0 .. 3) of Map_Command




     := (Hash_Package,
         Nodes,
         Function_Name,
         Not_Found);

end Natools.Static_Hash_Maps.S_Expressions.Command_Maps;







|
|
|
|
>
>
>
>
|



|
>
>
>
>
|
>
>
>
>
|





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
         Extra_Declarations,
         Private_Child,
         Public_Child,
         Pure_Package,
         Preelaborate_Package,
         Test_Function);

   Map_2_Key_0 : aliased constant String := "definite";
   Map_2_Key_1 : aliased constant String := "definite-elements";
   Map_2_Key_2 : aliased constant String := "indefinite";
   Map_2_Key_3 : aliased constant String := "indefinite-elements";
   Map_2_Key_4 : aliased constant String := "hash-package";
   Map_2_Key_5 : aliased constant String := "nodes";
   Map_2_Key_6 : aliased constant String := "function";
   Map_2_Key_7 : aliased constant String := "not-found";
   Map_2_Keys : constant array (0 .. 7) of access constant String
     := (Map_2_Key_0'Access,
         Map_2_Key_1'Access,
         Map_2_Key_2'Access,
         Map_2_Key_3'Access,
         Map_2_Key_4'Access,
         Map_2_Key_5'Access,
         Map_2_Key_6'Access,
         Map_2_Key_7'Access);
   Map_2_Elements : constant array (0 .. 7) of Map_Command
     := (Definite_Elements,
         Definite_Elements,
         Indefinite_Elements,
         Indefinite_Elements,
         Hash_Package,
         Nodes,
         Function_Name,
         Not_Found);

end Natools.Static_Hash_Maps.S_Expressions.Command_Maps;

Modified src/natools-static_hash_maps-s_expressions-hash_maps.sx from [bd439d8f06] to [a74b2795a7].

12
13
14
15
16
17
18


19
20
21
22
23
         (Pure_Package pure)
         (Preelaborate_Package preelaborate)
         (Test_Function test-function)))
   (Map_Command
      (hash-package Natools.Static_Hash_Maps.S_Expressions.Command_Map)
      (function To_Map_Command)
      (nodes


         (Hash_Package hash-package)
         (Nodes nodes)
         (Function_Name function)
         (Not_Found not-found))))








>
>





12
13
14
15
16
17
18
19
20
21
22
23
24
25
         (Pure_Package pure)
         (Preelaborate_Package preelaborate)
         (Test_Function test-function)))
   (Map_Command
      (hash-package Natools.Static_Hash_Maps.S_Expressions.Command_Map)
      (function To_Map_Command)
      (nodes
         (Definite_Elements definite definite-elements)
         (Indefinite_Elements indefinite indefinite-elements)
         (Hash_Package hash-package)
         (Nodes nodes)
         (Function_Name function)
         (Not_Found not-found))))

Modified src/natools-static_hash_maps-s_expressions.adb from [27c4cdae39] to [c67c4fb249].

134
135
136
137
138
139
140






141
142
143
144
145
146
147
         when Hash_Package =>
            if Event = Sx.Events.Add_Atom then
               Set_Hash_Package_Name
                 (Map, Sx.To_String (Arguments.Current_Atom));
            else
               Set_Hash_Package_Name (Map, "");
            end if;







         when Function_Name =>
            if Event = Sx.Events.Add_Atom then
               Set_Function_Name (Map, Sx.To_String (Arguments.Current_Atom));
            else
               Set_Function_Name (Map, "");
            end if;







>
>
>
>
>
>







134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
         when Hash_Package =>
            if Event = Sx.Events.Add_Atom then
               Set_Hash_Package_Name
                 (Map, Sx.To_String (Arguments.Current_Atom));
            else
               Set_Hash_Package_Name (Map, "");
            end if;

         when Definite_Elements =>
            Set_Definite (Map);

         when Indefinite_Elements =>
            Set_Indefinite (Map);

         when Function_Name =>
            if Event = Sx.Events.Add_Atom then
               Set_Function_Name (Map, Sx.To_String (Arguments.Current_Atom));
            else
               Set_Function_Name (Map, "");
            end if;

Modified src/natools-static_hash_maps-s_expressions.ads from [375a4ce6c6] to [6ccde42f99].

44
45
46
47
48
49
50


51
52
53
54
55
      Pure_Package,
      Preelaborate_Package,
      Test_Function,
      Extra_Declarations);

   type Map_Command is
     (Hash_Package,


      Nodes,
      Function_Name,
      Not_Found);

end Natools.Static_Hash_Maps.S_Expressions;







>
>





44
45
46
47
48
49
50
51
52
53
54
55
56
57
      Pure_Package,
      Preelaborate_Package,
      Test_Function,
      Extra_Declarations);

   type Map_Command is
     (Hash_Package,
      Definite_Elements,
      Indefinite_Elements,
      Nodes,
      Function_Name,
      Not_Found);

end Natools.Static_Hash_Maps.S_Expressions;