ADDED src/natools-static_hash_maps-s_expressions-command_map.adb Index: src/natools-static_hash_maps-s_expressions-command_map.adb ================================================================== --- src/natools-static_hash_maps-s_expressions-command_map.adb +++ src/natools-static_hash_maps-s_expressions-command_map.adb @@ -0,0 +1,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; ADDED src/natools-static_hash_maps-s_expressions-command_map.ads Index: src/natools-static_hash_maps-s_expressions-command_map.ads ================================================================== --- src/natools-static_hash_maps-s_expressions-command_map.ads +++ src/natools-static_hash_maps-s_expressions-command_map.ads @@ -0,0 +1,3 @@ +package Natools.Static_Hash_Maps.S_Expressions.Command_Map is + function Hash (S : String) return Natural; +end Natools.Static_Hash_Maps.S_Expressions.Command_Map; ADDED src/natools-static_hash_maps-s_expressions-command_maps.adb Index: src/natools-static_hash_maps-s_expressions-command_maps.adb ================================================================== --- src/natools-static_hash_maps-s_expressions-command_maps.adb +++ src/natools-static_hash_maps-s_expressions-command_maps.adb @@ -0,0 +1,32 @@ +-- Generated at 2014-05-21 20:03:41 +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 + N : constant Natural + := Natools.Static_Hash_Maps.S_Expressions.Command_Pkg.Hash (Key); + begin + if Map_1_Keys (N).all = Key then + return Map_1_Elements (N); + else + raise Constraint_Error with "Key """ & Key & """ not in map"; + end if; + end To_Package_Command; + + + function To_Map_Command (Key : String) return Map_Command is + N : constant Natural + := Natools.Static_Hash_Maps.S_Expressions.Command_Map.Hash (Key); + begin + if Map_2_Keys (N).all = Key then + return Map_2_Elements (N); + else + raise Constraint_Error with "Key """ & Key & """ not in map"; + end if; + end To_Map_Command; + +end Natools.Static_Hash_Maps.S_Expressions.Command_Maps; ADDED src/natools-static_hash_maps-s_expressions-command_maps.ads Index: src/natools-static_hash_maps-s_expressions-command_maps.ads ================================================================== --- src/natools-static_hash_maps-s_expressions-command_maps.ads +++ src/natools-static_hash_maps-s_expressions-command_maps.ads @@ -0,0 +1,35 @@ +-- Generated at 2014-05-21 20:03:41 +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 + + Map_1_Key_0 : aliased constant String := "private"; + Map_1_Key_1 : aliased constant String := "public"; + Map_1_Keys : constant array (0 .. 1) of access constant String + := (Map_1_Key_0'Access, + Map_1_Key_1'Access); + Map_1_Elements : constant array (0 .. 1) of Package_Command + := (Private_Child, + Public_Child); + + 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; ADDED src/natools-static_hash_maps-s_expressions-command_pkg.adb Index: src/natools-static_hash_maps-s_expressions-command_pkg.adb ================================================================== --- src/natools-static_hash_maps-s_expressions-command_pkg.adb +++ src/natools-static_hash_maps-s_expressions-command_pkg.adb @@ -0,0 +1,32 @@ +with Interfaces; use Interfaces; + +package body Natools.Static_Hash_Maps.S_Expressions.Command_Pkg is + + P : constant array (0 .. 0) of Natural := + (0 .. 0 => 2); + + T1 : constant array (0 .. 0) of Unsigned_8 := + (0 .. 0 => 4); + + T2 : constant array (0 .. 0) of Unsigned_8 := + (0 .. 0 => 3); + + G : constant array (0 .. 4) of Unsigned_8 := + (0, 0, 0, 1, 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 5; + F2 := (F2 + Natural (T2 (K)) * J) mod 5; + end loop; + return (Natural (G (F1)) + Natural (G (F2))) mod 2; + end Hash; + +end Natools.Static_Hash_Maps.S_Expressions.Command_Pkg; ADDED src/natools-static_hash_maps-s_expressions-command_pkg.ads Index: src/natools-static_hash_maps-s_expressions-command_pkg.ads ================================================================== --- src/natools-static_hash_maps-s_expressions-command_pkg.ads +++ src/natools-static_hash_maps-s_expressions-command_pkg.ads @@ -0,0 +1,3 @@ +package Natools.Static_Hash_Maps.S_Expressions.Command_Pkg is + function Hash (S : String) return Natural; +end Natools.Static_Hash_Maps.S_Expressions.Command_Pkg; ADDED src/natools-static_hash_maps-s_expressions-hash_maps.sx Index: src/natools-static_hash_maps-s_expressions-hash_maps.sx ================================================================== --- src/natools-static_hash_maps-s_expressions-hash_maps.sx +++ src/natools-static_hash_maps-s_expressions-hash_maps.sx @@ -0,0 +1,17 @@ +(Natools.Static_Hash_Maps.S_Expressions.Command_Maps + private + (Package_Command + (hash-package Natools.Static_Hash_Maps.S_Expressions.Command_Pkg) + (function To_Package_Command) + (nodes + (Private_Child private) + (Public_Child public))) + (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)))) +