instancier Gnat.Spelling_Checker_Generic...

Auteur Message
Bonjour, je sèche depuis 3 ou 4 heure devant un problème de compilation pour instancier le paquetage Gnat.Spelling_Checker_Generic ;

Je souhaiterais avec le code si dessous -générer des mot aléatoirement (non implémenté) et regarder s'il sont possiblement de mauvaise orthographe d'un mot réservé du langage Ada.

L'erreur reçue est :
Citation : 
adaline.adb:302:07: warning: in instantiation at g-spchge.adb:53
adaline.adb:302:07: warning: value not in range of type "Char_Type" defined at g-spchge.ads:46, instance at line 302
adaline.adb:302:07: warning: "Constraint_Error" will be raised at run time
adaline.adb:302:07: warning: in instantiation at g-spchge.adb:54
adaline.adb:302:07: warning: value not in range of type "Char_Type" defined at g-spchge.ads:46, instance at line 302
adaline.adb:302:07: warning: "Constraint_Error" will be raised at run time
adaline.adb:316:07: warning: in instantiation at g-spchge.adb:52
adaline.adb:316:07: warning: value not in range of type "Char_Type" defined at g-spchge.ads:46, instance at line 316
adaline.adb:316:07: warning: "Constraint_Error" will be raised at run time


Voici mon code, quelques 300 lignes dans un fichier principal :

Source ada : 

with Ada.Text_Io; with Ada.Wide_Text_Io;
with Ada.Wide_Wide_Text_Io; with Ada.Integer_Text_Io;
with Ada.Float_Text_Io; with Ada.Numerics;
with Ada.Calendar; with Ada.Finalization;

with System; use System;

with Ada.Strings.Fixed;
with Ada.Strings.Wide_Fixed;
with Ada.Strings.Wide_Wide_Fixed;
use Ada.Strings;
with Ada.Characters.Wide_Wide_Latin_9;
with Ada.Characters.Wide_Latin_9;
with Ada.Characters.Latin_9;
use Ada.Characters;
with Ada.Characters.Handling;
with Ada.Characters.Conversions;

with Ada.Exceptions;
use Ada.exceptions;
with Ada.Numerics.Discrete_Random;

with Gnat.Spelling_Checker_Generic;
with Gnat.Spelling_Checker;
use Gnat.Spelling_Checker;
procedure Adaline is

package Lang is

Quotation_Mark : constant Character := '"';

Number_Sign : constant Character := '#';

Ampersand : constant Character := '&';

Apostrophe : constant Character := ''';

Left_Parenthesis : constant Character := '(';

Right_Parenthesis : constant Character := ')';

Asterisk : constant Character := '*';

Plus_Sign : constant Character := '+';

Comma : constant Character := ',';

Minus : constant Character := '-';

Point : constant Character := '.';

Colon : constant Character := ':';

Semicolon : constant Character := ';';

Less_Than : constant Character := '<';

Equal : constant Character := '=';

Greater_Than : constant Character := '>';

Underline : constant Character := '_';

Vertical_Line : constant Character := '|';

Divide : constant Character := '/';

Exclamation : constant Character := '!';

Percent_Sign : constant Character := '%';

Arrow : constant String := "=>";

Double_Point : constant String := "..";

Double_Star : constant String := "**";

Becomes : constant String := ":=";

Not_Equal : constant String := "/=";

Greater_Than_Or_Equal : constant String := ">=";

Les_Than_Equal : constant String := "<=";

Left_Label_Bracket : constant String := "<<";

Right_Label_Bracket : constant String := ">>";

Box : constant String := "<>";

subtype Letters is Character range 'a'..'z';

subtype Numbers is Character range '0'..'9';

Comment : constant String := "--";





generic

Letters_Quantity_Min : Positive := 2;
Letters_Quantity_Max : Positive := 12;
Numbers_Quantity_Min : Positive := 1;
Numbers_Quantity_Max : Positive := 3;
package Imaginary is


subtype Letters_Quantity is Positive range Letters_Quantity_Min .. Letters_Quantity_Max;
subtype Numbers_Quantity is Positive range Numbers_Quantity_Min .. Numbers_Quantity_Max;


generic
type Letters_digit is (<>);
type String_Type is array (Positive range <>) of Letters_Digit;
package Letters_Image is
function Imagine (Size_Max : in Letters_Quantity) return String_Type;
procedure Reset;
end Letters_Image;

generic
type Numbers_Digit is (<>);
type String_Type is array (Positive range <>) of Numbers_Digit;
package Numbers_Image is
function Imagine (Size_Max : in Numbers_Quantity) return String_Type;
procedure Reset;
end Numbers_Image;

end Imaginary;






type Letters_Word is array (positive range <>) of Letters;


type Numbers_Word is array (Positive range <>) of Numbers;

Reserved_Words : constant array (Positive range <>) of access Letters_word :=
(
new Letters_Word ' ("abort"),
new Letters_Word ' ("else"),
new Letters_Word ' ("new"),
new Letters_Word ' ("return"),
new Letters_Word ' ("abs"),
new Letters_Word ' ("elsif"),
new Letters_Word ' ("not"),
new Letters_Word ' ("reverse"),
new Letters_Word ' ("abstract"),
new Letters_Word ' ("end"),
new Letters_Word ' ("null"),
new Letters_Word ' ("accept"),
new Letters_Word ' ("entry"),
new Letters_Word ' ("select"),
new Letters_Word ' ("access"),
new Letters_Word ' ("exception"),
new Letters_Word ' ("of"),
new Letters_Word ' ("separate"),
new Letters_Word ' ("aliased"),
new Letters_Word ' ("exit"),
new Letters_Word ' ("or"),
new Letters_Word ' ("some"),
new Letters_Word ' ("all"),
new Letters_Word ' ("others"),
new Letters_Word ' ("subtype"),
new Letters_Word ' ("and"),
new Letters_Word ' ("for"),
new Letters_Word ' ("out"),
new Letters_Word ' ("synchronized"),
new Letters_Word ' ("array"),
new Letters_Word ' ("function"),
new Letters_Word ' ("overriding"),
new Letters_Word ' ("at"),
new Letters_Word ' ("tagged"),
new Letters_Word ' ("generic"),
new Letters_Word ' ("package"),
new Letters_Word ' ("task"),
new Letters_Word ' ("begin"),
new Letters_Word ' ("goto"),
new Letters_Word ' ("pragma"),
new Letters_Word ' ("terminate"),
new Letters_Word ' ("body"),
new Letters_Word ' ("private"),
new Letters_Word ' ("then"),
new Letters_Word ' ("if"),
new Letters_Word ' ("procedure"),
new Letters_Word ' ("type"),
new Letters_Word ' ("case"),
new Letters_Word ' ("in"),
new Letters_Word ' ("protected"),
new Letters_Word ' ("constant"),
new Letters_Word ' ("interface"),
new Letters_Word ' ("until"),
new Letters_Word ' ("is"),
new Letters_Word ' ("raise"),
new Letters_Word ' ("use"),
new Letters_Word ' ("declare"),
new Letters_Word ' ("range"),
new Letters_Word ' ("delay"),
new Letters_Word ' ("limited"),
new Letters_Word ' ("record"),
new Letters_Word ' ("when"),
new Letters_Word ' ("delta"),
new Letters_Word ' ("loop"),
new Letters_Word ' ("rem"),
new Letters_Word ' ("while"),
new Letters_Word ' ("digits"),
new Letters_Word ' ("renames"),
new Letters_Word ' ("with"),
new Letters_Word ' ("do"),
new Letters_Word ' ("mod"),
new Letters_Word ' ("requeue") ,
new Letters_Word ' ("xor")
);

Line_Length_Max : constant Natural := 256;

Space_Replace : constant Character := '_';


end Lang;

package body Lang is


package body Imaginary is

package body Letters_Image is
function Imagine (Size_Max : in Letters_Quantity) return String_Type is

Word_Image : String_Type(1..Size_Max);
begin

if Size_Max > 2 then

Word_Image := Letters_Digit'First & Imagine (Size_Max - 1);
end if;

return Word_Image;
end Imagine;

procedure Reset is
begin
null;
end Reset;
end Letters_Image;

package body Numbers_Image is

function Imagine (Size_Max : in Numbers_Quantity) return String_Type is
Word_Image : String_Type(1..Size_Max);
begin

if Size_Max > 1 then

Word_Image := Numbers_Digit'First & Imagine (Size_Max - 1 );
end if;

return Word_Image;
end Imagine;

procedure Reset is
begin
null;
end Reset;
end Numbers_Image;

end Imaginary;
end Lang;

use Lang;

Letters_Inf : Positive := 2;
Letters_Sup : Positive := 12;
Numbers_Inf : Positive := 1;
Numbers_Sup : Positive := 3;



begin

declare

package Images is new Lang.Imaginary(Letters_inf, Letters_sup, Numbers_Inf, Numbers_Sup);

subtype Letters_Range is Positive range Letters_Inf .. Letters_Sup;

type Letters_array is array (Positive range <>) of Letters;

package Letters_Imagines is new Images.Letters_Image (Letters, Letters_Word);

package Letters_Rand is new Ada.Numerics.Discrete_Random(Images.Letters_Quantity);

Letters_Gen : Letters_Rand.Generator;

use Letters_Imagines;

function Letters_Check is new Gnat.Spelling_Checker_Generic.Is_Bad_Spelling_Of (Letters, Letters_array);

subtype Numbers_Range is Positive range Numbers_Inf .. Numbers_Sup;

type Numbers_array is array (positive range <>) of Numbers;

package Numbers_Imagines is new Images.Numbers_Image (Numbers, Numbers_Array);

package Numbers_Rand is new Ada.Numerics.Discrete_Random(Images.Numbers_Quantity);

Numbers_Gen : Numbers_Rand.Generator;

use Numbers_Imagines;

function Numbers_Check is new Gnat.Spelling_Checker_Generic.Is_Bad_Spelling_Of (Numbers, Numbers_word);
begin

Letters_Rand.Reset(Letters_Gen);
Numbers_Rand.Reset(Numbers_Gen);

declare

Letters_Quantity_Max : Images.Letters_Quantity := Letters_Rand.Random(Letters_Gen);
Numbers_Quantity_Max : Images.Numbers_Quantity := Numbers_Rand.Random(Numbers_Gen);

Is_Valid_Word : Boolean := False;
begin

loop

declare

New_Letters_Word : Letters_word(1..Letters_Quantity_Max) := Letters_word(Letters_Imagines.Imagine(Letters_Quantity_Max));
New_Numbers_Word : Numbers_word(1..Numbers_Quantity_Max) := Numbers_word(Numbers_Imagines.imagine(Numbers_Quantity_Max));


begin
for Reserved_Index in Reserved_Words'Range loop
if Letters_Check(Letters_Array(Reserved_Words(Reserved_Index).all), Letters_Array(New_Letters_Word)) then
Is_Valid_Word := False;
exit;
end if;
end loop;
end;

exit when not Is_Valid_Word;

end loop;
end;
end;
end Adaline;


Merci pour le coup de main.
je viens vous donnez pour le fun... le résultat :

un petit programme qui devrait compiler si seulement is était complet.

Source ada : 

procedure pkpnhupooa is begin kcvj ; oxmlqh ; vipojyyizdjp ; mbntpomp ; sjmvylkvqa ; vkahkeewcxw ; af ; sei ; hpenfbim ; qemhkv ; oshbm ; end;


Alors, c'est sur un ligne, c'est générer moitier aléatoirement moitié logiquement.

Je n'ai pas encore trouvé l'ordre de mes opérations mais je vous tiendrais au courant.

C'est pour développer avec Ada.