Yurttas/PL/IL/Ada-95/OO/GEO/build list.adb

 1with Ada.Text_IO; use Ada.Text_IO;
 2
 3with Geometry.Lists; use Geometry;
 4with Geometry.IO;    use Geometry.IO;
 5
 6procedure Build_List(The_List : in out Lists.Cell_Ptr) is
 7
 8-- Builds a list by calling appropriate get functions and
 9-- uses Add_To_List to add them to the partly built list.
10-- The_List is initially null. This could be rewritten as
11-- a function.
12
13  Code_Letter : Character;
14
15  Object_Ptr : Lists.Pointer;
16
17begin
18  loop
19    loop -- to skip leading spaces
20      Get(Code_Letter);
21      exit when Code_Letter /= ' ';
22    end loop;
23
24    case Code_Letter is
25      when 'C' | 'c' =>  -- expect a circle
26                         Object_Ptr := Get_Circle;
27      when 'T' | 't' =>  -- expect a triangle
28                         Object_Ptr := Get_Triangle;
29      when 'S' | 's' =>  -- expect a square
30                         Object_Ptr := Get_Square;
31      when others => exit;
32    end case;
33
34    Lists.Add_To_List(The_List, Object_Ptr);
35  end loop;
36
37end Build_List;