added comments already written aside from main
This commit is contained in:
parent
dcd4df18dd
commit
24f263b2d4
1 changed files with 38 additions and 38 deletions
76
pointer.adb
76
pointer.adb
|
@ -150,45 +150,45 @@ procedure pointer is
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function saisir2 return list is
|
function saisir2 return list is
|
||||||
liste : list;
|
Llist : list; --returned
|
||||||
ended : boolean := false;
|
ended : boolean := false; --end of first while
|
||||||
space : boolean := false;
|
space : boolean := false; --end of second
|
||||||
charac : character := ' ';
|
charac : character := ' '; -- to get the char
|
||||||
Num: integer:=0;
|
Num: integer:=0; -- value at the end of the 2nd while
|
||||||
val : integer := 0;
|
val : integer := 0; -- value from the char used to buid num
|
||||||
s : string(1..1);
|
s : string(1..1); -- because ada < C and we need to use the Integer'Value on a string as there can be no cast from char to int
|
||||||
I : integer := 0;
|
I : integer := 0;
|
||||||
aux : list;
|
aux : list; -- helper
|
||||||
first : boolean:= True;
|
first : boolean:= True; -- to mimick initialization
|
||||||
|
|
||||||
begin
|
begin
|
||||||
aux := liste; -- we set the
|
aux := Llist; -- we set the helper to list
|
||||||
while (not end_of_line) loop
|
while (not end_of_line) loop -- check the buffer for upcoming \n
|
||||||
while (not space and not end_of_line) loop
|
while (not space and not end_of_line) loop -- space is true when char = ' '
|
||||||
-- put_line("test");
|
-- put_line("test");
|
||||||
get(charac);
|
get(charac);
|
||||||
if(charac = ' ') then ended := True; space := True;
|
if(charac = ' ') then ended := True; space := True;
|
||||||
else
|
else
|
||||||
s(1):=charac;
|
s(1):=charac; -- change the char to a string for cast to int
|
||||||
val := integer'Value(s);
|
val := integer'Value(s);
|
||||||
-- put_Line("vous avez saisi " & charac);
|
put_Line("vous avez saisi " & charac); -- visual confirmation
|
||||||
Num := Num*10+val;
|
Num := Num*10+val; -- convert to base 10 value
|
||||||
end if;
|
end if;
|
||||||
end loop;
|
end loop;
|
||||||
space := False;
|
space := False; -- reset
|
||||||
if first then
|
if first then -- init
|
||||||
liste := new cell'(Num,Null);
|
Llist := new cell'(Num,Null);
|
||||||
first:= False;
|
first:= False;
|
||||||
aux := liste;
|
aux := Llist;
|
||||||
else
|
else
|
||||||
aux.all.next := new cell'(Num, Null);
|
aux.all.next := new cell'(Num, Null);
|
||||||
aux:= aux.all.next;
|
aux:= aux.all.next;
|
||||||
end if;
|
end if;
|
||||||
Num := 0;
|
Num := 0; --reset
|
||||||
end loop;
|
end loop;
|
||||||
return liste;
|
return Llist;
|
||||||
end saisir2;
|
end saisir2;
|
||||||
|
|
||||||
|
|
||||||
function saisir3 return returned3 is
|
function saisir3 return returned3 is
|
||||||
|
|
Loading…
Reference in a new issue