Ce qui est drôle c'est que le programme arrête juste après le morceau montré !
with ada.Text_IO;
use ada.Text_IO;
with ada.Integer_Text_IO; use ada.Integer_Text_IO;
procedure compression is
type Tableau is array(Positive) of Natural;
FICHIER: File_Type;
FICHIER_ECRIRE: File_Type;
factor, number: Natural;
Col_1: count := 1;
type etat is (facteur, virgule, fois, valeur);
etat_is: etat := facteur;
begin
begin
Open(FICHIER, In_File, "LECTURE");
exception
when others => Put_Line("ici ?"); CLOSE(FICHIER);
---------------------------
end;
create(FICHIER, Out_File,"ECRITURE");
Set_Input(fichier); Set_Output(FICHIER_ECRIRE);
c
while not End_Of_File(FICHIER) loop
declare
C: Character;
begin
Get_Immediate(C);
if c not in '0'..'9' then raise Constraint_Error; end if;
case etat_is is
when facteur =>
case C is
when '*' =>
Set_Col(Current_Input,col_1);
Get(Current_Input,factor);
Col_1 := col + 1;
Set_Col(col_1);
etat_is := fois;
when '0'..'9' => null;
when others => raise Constraint_Error;
end case;
when virgule =>
case C is
when '0'..'9' => null;
when others => raise Constraint_Error;
end case;
when fois =>
case C is
when '0'..'9' =>
col_1 := Col(File => Current_Input);
etat_is := facteur;
when others => raise Constraint_Error;
end case;
when valeur =>
case C is
when '0'..'9' => null;
when ',' =>
set_col(File => Current_Input,
To =>Col_1) ;
get(number);
col_1 := col+1;
Set_Col(File => Current_Input,
To => col_1);
for Ind in 1..factor loop
put(number,Width => 1);
end loop;
etat_is := virgule;
when others => raise Constraint_Error;
end case;
end case;
exception
when others =>
Close(FICHIER_ECRIRE);
close(FICHIER);
raise;
end;
end loop;
close(FICHIER);
if etat_is = valeur then
set_col(File => Current_Input,
To =>Col_1) ;
get(number);
col_1 := col+1;
Set_Col(File => Current_Input,
To => col_1);
for Ind in 1..factor loop
put(number,Width => 1);
end loop;
end if;
close(FICHIER_ECRIRE);
end compression;