Index: generated/natools-static_maps-s_expressions-conditionals-strings-p.adb ================================================================== --- generated/natools-static_maps-s_expressions-conditionals-strings-p.adb +++ generated/natools-static_maps-s_expressions-conditionals-strings-p.adb @@ -1,20 +1,20 @@ with Interfaces; use Interfaces; package body Natools.Static_Maps.S_Expressions.Conditionals.Strings.P is P : constant array (0 .. 2) of Natural := - (2, 11, 13); + (1, 11, 13); T1 : constant array (0 .. 2) of Unsigned_8 := - (9, 9, 0); + (11, 3, 3); T2 : constant array (0 .. 2) of Unsigned_8 := - (6, 4, 5); + (14, 19, 16); - G : constant array (0 .. 16) of Unsigned_8 := - (0, 5, 0, 1, 0, 6, 0, 0, 7, 0, 0, 0, 0, 1, 1, 0, 3); + G : constant array (0 .. 22) of Unsigned_8 := + (0, 0, 0, 9, 0, 0, 0, 0, 2, 0, 3, 0, 0, 3, 1, 0, 7, 0, 4, 0, 1, 7, 0); function Hash (S : String) return Natural is F : constant Natural := S'First - 1; L : constant Natural := S'Length; F1, F2 : Natural := 0; @@ -21,12 +21,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 17; - F2 := (F2 + Natural (T2 (K)) * J) mod 17; + F1 := (F1 + Natural (T1 (K)) * J) mod 23; + F2 := (F2 + Natural (T2 (K)) * J) mod 23; end loop; - return (Natural (G (F1)) + Natural (G (F2))) mod 8; + return (Natural (G (F1)) + Natural (G (F2))) mod 11; end Hash; end Natools.Static_Maps.S_Expressions.Conditionals.Strings.P; Index: generated/natools-static_maps-s_expressions-conditionals-strings.ads ================================================================== --- generated/natools-static_maps-s_expressions-conditionals-strings.ads +++ generated/natools-static_maps-s_expressions-conditionals-strings.ads @@ -1,6 +1,6 @@ --- Generated at 2015-03-31 18:55:08 +0000 by Natools.Static_Hash_Maps +-- Generated at 2017-06-17 18:23:38 +0000 by Natools.Static_Hash_Maps -- from src/natools-s_expressions-conditionals-strings-maps.sx package Natools.Static_Maps.S_Expressions.Conditionals.Strings is pragma Pure; @@ -8,10 +8,11 @@ (Unknown_Parametric_Condition, Case_Insensitive, Case_Sensitive, Contains_All, Contains_Any, + Is_Equal_To, Starts_With); type Simple_Condition is (Unknown_Simple_Condition, Is_ASCII, @@ -27,28 +28,37 @@ Map_1_Key_2 : aliased constant String := "contains"; Map_1_Key_3 : aliased constant String := "contains-all"; Map_1_Key_4 : aliased constant String := "contains-all-of"; Map_1_Key_5 : aliased constant String := "contains-any"; Map_1_Key_6 : aliased constant String := "contains-any-of"; - Map_1_Key_7 : aliased constant String := "starts-with"; - Map_1_Keys : constant array (0 .. 7) of access constant String + Map_1_Key_7 : aliased constant String := "is"; + Map_1_Key_8 : aliased constant String := "is-equal-to"; + Map_1_Key_9 : aliased constant String := "="; + Map_1_Key_10 : aliased constant String := "starts-with"; + Map_1_Keys : constant array (0 .. 10) 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, Map_1_Key_5'Access, Map_1_Key_6'Access, - Map_1_Key_7'Access); - Map_1_Elements : constant array (0 .. 7) of Parametric_Condition + Map_1_Key_7'Access, + Map_1_Key_8'Access, + Map_1_Key_9'Access, + Map_1_Key_10'Access); + Map_1_Elements : constant array (0 .. 10) of Parametric_Condition := (Case_Insensitive, Case_Sensitive, Contains_All, Contains_All, Contains_All, Contains_Any, Contains_Any, + Is_Equal_To, + Is_Equal_To, + Is_Equal_To, Starts_With); Map_2_Key_0 : aliased constant String := "is-ascii"; Map_2_Key_1 : aliased constant String := "is-empty"; Map_2_Keys : constant array (0 .. 1) of access constant String Index: src/natools-s_expressions-conditionals-strings-maps.sx ================================================================== --- src/natools-s_expressions-conditionals-strings-maps.sx +++ src/natools-s_expressions-conditionals-strings-maps.sx @@ -6,10 +6,11 @@ (Unknown_Parametric_Condition, Case_Insensitive, Case_Sensitive, Contains_All, Contains_Any, + Is_Equal_To, Starts_With); type Simple_Condition is (Unknown_Simple_Condition, Is_ASCII, @@ -22,14 +23,15 @@ (nodes (Case_Insensitive case-insensitive) (Case_Sensitive case-sensitive) (Contains_All contains contains-all contains-all-of) (Contains_Any contains-any contains-any-of) + (Is_Equal_To is is-equal-to "=") (Starts_With starts-with))) (Simple_Condition (hash-package Natools.Static_Maps.S_Expressions.Conditionals.Strings.S) (function To_Simple) (not-found Unknown_Simple_Condition) (nodes (Is_ASCII is-ascii) (Is_Empty is-empty)))) Index: src/natools-s_expressions-conditionals-strings.adb ================================================================== --- src/natools-s_expressions-conditionals-strings.adb +++ src/natools-s_expressions-conditionals-strings.adb @@ -1,7 +1,7 @@ ------------------------------------------------------------------------------ --- Copyright (c) 2015, Natacha Porté -- +-- Copyright (c) 2015-2017, 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. -- -- -- @@ -34,10 +34,14 @@ -- Evaluate Element on all atoms of Arguments and combine them function Contains (Context : in Strings.Context; Data : in Atom) return Boolean; -- Check whether Context contains Data + + function Is_Equal_To (Context : in Strings.Context; Data : in Atom) + return Boolean; + -- Check whether Context is equal to Data function Is_Prefix (Context : in Strings.Context; Data : in Atom) return Boolean; -- Check whether Context starts with Data @@ -93,10 +97,26 @@ Ada.Strings.Forward, Ada.Characters.Handling.To_Lower'Access) > 0; end if; end Contains; + + function Is_Equal_To (Context : in Strings.Context; Data : in Atom) + return Boolean is + begin + if Context.Data.all'Length /= Data'Length then + return False; + end if; + + if Context.Settings.Case_Sensitive then + return Context.Data.all = To_String (Data); + else + return Fixed.Translate (Context.Data.all, To_Lower'Access) + = Fixed.Translate (To_String (Data), To_Lower'Access); + end if; + end Is_Equal_To; + function Is_Prefix (Context : in Strings.Context; Data : in Atom) return Boolean is begin if Context.Data.all'Length < Data'Length then @@ -163,10 +183,14 @@ when Contains_Any => return Conditional_On_Atoms (Context, Arguments, Contains'Access, False); + when Is_Equal_To => + return Conditional_On_Atoms + (Context, Arguments, Is_Equal_To'Access, False); + when Starts_With => return Conditional_On_Atoms (Context, Arguments, Is_Prefix'Access, False); end case; end Parametric_Evaluate;