Index: generated/natools-static_maps-s_expressions-templates-integers-mc.adb ================================================================== --- generated/natools-static_maps-s_expressions-templates-integers-mc.adb +++ generated/natools-static_maps-s_expressions-templates-integers-mc.adb @@ -4,19 +4,19 @@ P : constant array (0 .. 4) of Natural := (1, 2, 5, 6, 9); T1 : constant array (0 .. 4) of Unsigned_8 := - (15, 31, 41, 38, 11); + (0, 40, 7, 12, 15); T2 : constant array (0 .. 4) of Unsigned_8 := - (10, 33, 15, 23, 26); + (31, 48, 43, 13, 1); - G : constant array (0 .. 44) of Unsigned_8 := - (0, 0, 0, 0, 5, 17, 14, 0, 5, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 13, 21, - 0, 0, 0, 11, 18, 7, 0, 16, 4, 2, 9, 0, 0, 15, 0, 0, 0, 2, 3, 7, 13, 0, - 1); + G : constant array (0 .. 48) of Unsigned_8 := + (0, 14, 0, 0, 0, 0, 0, 18, 0, 17, 10, 5, 0, 18, 0, 0, 18, 8, 0, 16, 18, + 0, 0, 0, 0, 15, 23, 0, 1, 4, 13, 0, 0, 0, 0, 3, 5, 17, 0, 2, 0, 14, 6, + 0, 10, 21, 0, 0, 0); function Hash (S : String) return Natural is F : constant Natural := S'First - 1; L : constant Natural := S'Length; F1, F2 : Natural := 0; @@ -23,12 +23,12 @@ 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 45; - F2 := (F2 + Natural (T2 (K)) * J) mod 45; + F1 := (F1 + Natural (T1 (K)) * J) mod 49; + F2 := (F2 + Natural (T2 (K)) * J) mod 49; end loop; - return (Natural (G (F1)) + Natural (G (F2))) mod 22; + return (Natural (G (F1)) + Natural (G (F2))) mod 24; end Hash; end Natools.Static_Maps.S_Expressions.Templates.Integers.MC; Index: generated/natools-static_maps-s_expressions-templates-integers-t.adb ================================================================== --- generated/natools-static_maps-s_expressions-templates-integers-t.adb +++ generated/natools-static_maps-s_expressions-templates-integers-t.adb @@ -1,6 +1,6 @@ --- Generated at 2014-09-23 18:25:16 +0000 by Natools.Static_Hash_Maps +-- Generated at 2014-09-26 17:52:14 +0000 by Natools.Static_Hash_Maps -- from src/natools-s_expressions-templates-generic_integers-maps.sx with Natools.Static_Maps.S_Expressions.Templates.Integers.MC; with Natools.Static_Maps.S_Expressions.Templates.Integers.AC; function Natools.Static_Maps.S_Expressions.Templates.Integers.T Index: generated/natools-static_maps-s_expressions-templates-integers-t.ads ================================================================== --- generated/natools-static_maps-s_expressions-templates-integers-t.ads +++ generated/natools-static_maps-s_expressions-templates-integers-t.ads @@ -1,6 +1,6 @@ --- Generated at 2014-09-23 18:25:16 +0000 by Natools.Static_Hash_Maps +-- Generated at 2014-09-26 17:52:14 +0000 by Natools.Static_Hash_Maps -- from src/natools-s_expressions-templates-generic_integers-maps.sx function Natools.Static_Maps.S_Expressions.Templates.Integers.T return Boolean; pragma Pure (Natools.Static_Maps.S_Expressions.Templates.Integers.T); Index: generated/natools-static_maps-s_expressions-templates-integers.adb ================================================================== --- generated/natools-static_maps-s_expressions-templates-integers.adb +++ generated/natools-static_maps-s_expressions-templates-integers.adb @@ -1,6 +1,6 @@ --- Generated at 2014-09-23 18:25:16 +0000 by Natools.Static_Hash_Maps +-- Generated at 2014-09-26 17:52:14 +0000 by Natools.Static_Hash_Maps -- from src/natools-s_expressions-templates-generic_integers-maps.sx with Natools.Static_Maps.S_Expressions.Templates.Integers.MC; with Natools.Static_Maps.S_Expressions.Templates.Integers.AC; Index: generated/natools-static_maps-s_expressions-templates-integers.ads ================================================================== --- generated/natools-static_maps-s_expressions-templates-integers.ads +++ generated/natools-static_maps-s_expressions-templates-integers.ads @@ -1,6 +1,6 @@ --- Generated at 2014-09-23 18:25:16 +0000 by Natools.Static_Hash_Maps +-- Generated at 2014-09-26 17:52:14 +0000 by Natools.Static_Hash_Maps -- from src/natools-s_expressions-templates-generic_integers-maps.sx package Natools.Static_Maps.S_Expressions.Templates.Integers is pragma Pure; @@ -13,11 +13,13 @@ Base, Images, Padding, Padding_Left, Padding_Right, + Prefix, Sign, + Suffix, Width, Width_Max, Width_Min); type Align_Command is (Unknown_Align, Set_Left, Set_Center, Set_Right); @@ -40,18 +42,20 @@ Map_1_Key_10 : aliased constant String := "padding"; Map_1_Key_11 : aliased constant String := "padding-left"; Map_1_Key_12 : aliased constant String := "left-padding"; Map_1_Key_13 : aliased constant String := "padding-right"; Map_1_Key_14 : aliased constant String := "right-padding"; - Map_1_Key_15 : aliased constant String := "sign"; - Map_1_Key_16 : aliased constant String := "signs"; - Map_1_Key_17 : aliased constant String := "width"; - Map_1_Key_18 : aliased constant String := "width-max"; - Map_1_Key_19 : aliased constant String := "max-width"; - Map_1_Key_20 : aliased constant String := "width-min"; - Map_1_Key_21 : aliased constant String := "min-width"; - Map_1_Keys : constant array (0 .. 21) of access constant String + Map_1_Key_15 : aliased constant String := "prefix"; + Map_1_Key_16 : aliased constant String := "sign"; + Map_1_Key_17 : aliased constant String := "signs"; + Map_1_Key_18 : aliased constant String := "suffix"; + Map_1_Key_19 : aliased constant String := "width"; + Map_1_Key_20 : aliased constant String := "width-max"; + Map_1_Key_21 : aliased constant String := "max-width"; + Map_1_Key_22 : aliased constant String := "width-min"; + Map_1_Key_23 : aliased constant String := "min-width"; + Map_1_Keys : constant array (0 .. 23) of access constant String := (Map_1_Key_0'Access, Map_1_Key_1'Access, Map_1_Key_2'Access, Map_1_Key_3'Access, Map_1_Key_4'Access, @@ -69,12 +73,14 @@ Map_1_Key_16'Access, Map_1_Key_17'Access, Map_1_Key_18'Access, Map_1_Key_19'Access, Map_1_Key_20'Access, - Map_1_Key_21'Access); - Map_1_Elements : constant array (0 .. 21) of Main_Command + Map_1_Key_21'Access, + Map_1_Key_22'Access, + Map_1_Key_23'Access); + Map_1_Elements : constant array (0 .. 23) of Main_Command := (Align, Align_Center, Align_Center, Align_Left, Align_Left, @@ -86,12 +92,14 @@ Padding, Padding_Left, Padding_Left, Padding_Right, Padding_Right, + Prefix, Sign, Sign, + Suffix, Width, Width_Max, Width_Max, Width_Min, Width_Min); Index: src/natools-s_expressions-templates-generic_integers-maps.sx ================================================================== --- src/natools-s_expressions-templates-generic_integers-maps.sx +++ src/natools-s_expressions-templates-generic_integers-maps.sx @@ -11,11 +11,13 @@ Base, Images, Padding, Padding_Left, Padding_Right, + Prefix, Sign, + Suffix, Width, Width_Max, Width_Min); type Align_Command is (Unknown_Align, Set_Left, Set_Center, Set_Right);") @@ -32,11 +34,13 @@ (Base base) (Images image images) (Padding padding) (Padding_Left padding-left left-padding) (Padding_Right padding-right right-padding) + (Prefix prefix) (Sign sign signs) + (Suffix suffix) (Width width) (Width_Max width-max max-width) (Width_Min width-min min-width))) (Align_Command (hash-package Natools.Static_Maps.S_Expressions.Templates.Integers.AC) Index: src/natools-s_expressions-templates-generic_integers.adb ================================================================== --- src/natools-s_expressions-templates-generic_integers.adb +++ src/natools-s_expressions-templates-generic_integers.adb @@ -133,10 +133,13 @@ State.Set_Right_Padding (Arguments.Current_Atom); when others => null; end case; + when Commands.Prefix => + Parse (State.Prefix, Arguments); + when Commands.Sign => case Arguments.Current_Event is when Events.Add_Atom => State.Set_Positive_Sign (Arguments.Current_Atom); when others => @@ -149,10 +152,13 @@ State.Set_Negative_Sign (Arguments.Current_Atom); when others => null; end case; + when Commands.Suffix => + Parse (State.Suffix, Arguments); + when Commands.Width => case Arguments.Current_Event is when Events.Add_Atom => declare New_Width : constant Width @@ -546,16 +552,36 @@ else Has_Sign := False; end if; end if; - Output.Invert; - if Has_Sign then Length := Length + 1; end if; + Add_Prefix : + declare + Cursor : constant Atom_Maps.Cursor + := Template.Prefix.Find ((Value, Value)); + begin + if Atom_Maps.Has_Element (Cursor) then + Output.Append_Reverse (Atom_Maps.Element (Cursor).Query.Data.all); + end if; + end Add_Prefix; + + Output.Invert; + + Add_Suffix : + declare + Cursor : constant Atom_Maps.Cursor + := Template.Suffix.Find ((Value, Value)); + begin + if Atom_Maps.Has_Element (Cursor) then + Output.Append (Atom_Maps.Element (Cursor).Query.Data.all); + end if; + end Add_Suffix; + if Length > Template.Maximum_Width then return Safe_Atom (Template.Overflow_Message, ""); end if; if Length < Template.Minimum_Width then @@ -640,10 +666,42 @@ procedure Remove_Image (Object : in out Format; Value : in T) is begin Exclude (Object.Images, (Value, Value)); end Remove_Image; + + procedure Remove_Prefix + (Object : in out Format; + Value : in T) is + begin + Remove_Prefix (Object, (Value, Value)); + end Remove_Prefix; + + + procedure Remove_Prefix + (Object : in out Format; + Values : in Interval) is + begin + Set_Prefix (Object, Values, Atom_Refs.Null_Immutable_Reference); + end Remove_Prefix; + + + procedure Remove_Suffix + (Object : in out Format; + Value : in T) is + begin + Remove_Suffix (Object, (Value, Value)); + end Remove_Suffix; + + + procedure Remove_Suffix + (Object : in out Format; + Values : in Interval) is + begin + Set_Suffix (Object, Values, Atom_Refs.Null_Immutable_Reference); + end Remove_Suffix; + procedure Set_Align (Object : in out Format; Value : in Alignment) is begin Object.Align := Value; end Set_Align; @@ -748,10 +806,50 @@ Sign : in Atom) is begin Set_Positive_Sign (Object, Create (Sign)); end Set_Positive_Sign; + + procedure Set_Prefix + (Object : in out Format; + Value : in T; + Prefix : in Atom_Refs.Immutable_Reference) is + begin + Set_Prefix (Object, (Value, Value), Prefix); + end Set_Prefix; + + + procedure Set_Prefix + (Object : in out Format; + Value : in T; + Prefix : in Atom) is + begin + Set_Prefix (Object, Value, Create (Prefix)); + end Set_Prefix; + + + procedure Set_Prefix + (Object : in out Format; + Values : in Interval; + Prefix : in Atom_Refs.Immutable_Reference) is + begin + if Prefix.Is_Empty then + Exclude (Object.Prefix, Values); + else + Include (Object.Prefix, Values, Prefix); + end if; + end Set_Prefix; + + + procedure Set_Prefix + (Object : in out Format; + Values : in Interval; + Prefix : in Atom) is + begin + Set_Prefix (Object, Values, Create (Prefix)); + end Set_Prefix; + procedure Set_Right_Padding (Object : in out Format; Symbol : in Atom_Refs.Immutable_Reference) is begin @@ -764,10 +862,50 @@ Symbol : in Atom) is begin Set_Right_Padding (Object, Create (Symbol)); end Set_Right_Padding; + + procedure Set_Suffix + (Object : in out Format; + Value : in T; + Suffix : in Atom_Refs.Immutable_Reference) is + begin + Set_Suffix (Object, (Value, Value), Suffix); + end Set_Suffix; + + + procedure Set_Suffix + (Object : in out Format; + Value : in T; + Suffix : in Atom) is + begin + Set_Suffix (Object, Value, Create (Suffix)); + end Set_Suffix; + + + procedure Set_Suffix + (Object : in out Format; + Values : in Interval; + Suffix : in Atom_Refs.Immutable_Reference) is + begin + if Suffix.Is_Empty then + Exclude (Object.Suffix, Values); + else + Include (Object.Suffix, Values, Suffix); + end if; + end Set_Suffix; + + + procedure Set_Suffix + (Object : in out Format; + Values : in Interval; + Suffix : in Atom) is + begin + Set_Suffix (Object, Values, Create (Suffix)); + end Set_Suffix; + procedure Set_Symbols (Object : in out Format; Symbols : in Atom_Arrays.Immutable_Reference) is begin Index: src/natools-s_expressions-templates-generic_integers.ads ================================================================== --- src/natools-s_expressions-templates-generic_integers.ads +++ src/natools-s_expressions-templates-generic_integers.ads @@ -24,12 +24,14 @@ -- (image (0 "symbol 0") (2 "symbol 2") ...) -- -- (max-width "max width" ["overflow text"]) -- -- (min-width "min width") -- -- (padding "left-symbol" "right-symbol") -- -- (padding "symbol") -- +-- (prefix (0 "prefix 0") (2 "prefix 2") ...) -- -- (right-padding "symbol") -- -- (sign "plus sign" ["minus sign"]) -- +-- (suffix (0 "suffix 0") (2 "suffix 2") ...) -- -- (width "fixed width") -- -- (width "min width" "max width" ["overflow text"]) -- -- Top-level atoms are taken as the image for the next number. -- ------------------------------------------------------------------------------ @@ -199,17 +201,63 @@ (Object : in out Format; Sign : in Atom_Refs.Immutable_Reference); procedure Set_Positive_Sign (Object : in out Format; Sign : in Atom); + + procedure Remove_Prefix + (Object : in out Format; + Value : in T); + procedure Set_Prefix + (Object : in out Format; + Value : in T; + Prefix : in Atom_Refs.Immutable_Reference); + procedure Set_Prefix + (Object : in out Format; + Value : in T; + Prefix : in Atom); + procedure Remove_Prefix + (Object : in out Format; + Values : in Interval); + procedure Set_Prefix + (Object : in out Format; + Values : in Interval; + Prefix : in Atom_Refs.Immutable_Reference); + procedure Set_Prefix + (Object : in out Format; + Values : in Interval; + Prefix : in Atom); procedure Set_Right_Padding (Object : in out Format; Symbol : in Atom_Refs.Immutable_Reference); procedure Set_Right_Padding (Object : in out Format; Symbol : in Atom); + + procedure Remove_Suffix + (Object : in out Format; + Value : in T); + procedure Set_Suffix + (Object : in out Format; + Value : in T; + Suffix : in Atom_Refs.Immutable_Reference); + procedure Set_Suffix + (Object : in out Format; + Value : in T; + Suffix : in Atom); + procedure Remove_Suffix + (Object : in out Format; + Values : in Interval); + procedure Set_Suffix + (Object : in out Format; + Values : in Interval; + Suffix : in Atom_Refs.Immutable_Reference); + procedure Set_Suffix + (Object : in out Format; + Values : in Interval; + Suffix : in Atom); procedure Set_Symbols (Object : in out Format; Symbols : in Atom_Arrays.Immutable_Reference); procedure Set_Symbols @@ -242,8 +290,10 @@ Maximum_Width : Width := Width'Last; Overflow_Message : Atom_Refs.Immutable_Reference; Images : Atom_Maps.Map; + Prefix : Atom_Maps.Map; + Suffix : Atom_Maps.Map; end record; end Natools.S_Expressions.Templates.Generic_Integers;