with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
   type Colour is (Red, Green, Blue);
   subtype Warm is Colour range Red .. Green;
   type Mixed is ('x', 'Y', Zed);
   type Byte is mod 256;
   subtype Small is Integer range -10 .. 10;

   procedure Read_Integer (S : String) is
   begin
      if Small'Valid_Value (S) then
         Put_Line (S & " ->" & Small'Image (Small'Value (S)));
      else
         Put_Line (S & " is not a Small");
      end if;
   end Read_Integer;

   procedure Read_Colour (S : String) is
   begin
      if Warm'Valid_Value (S) then
         Put_Line (S & " -> " & Warm'Image (Warm'Value (S)));
      else
         Put_Line (S & " is not a Warm");
      end if;
   end Read_Colour;
begin
   Read_Integer ("  7 ");
   Read_Integer ("-1_0");
   Read_Integer ("2#101#");
   Read_Integer ("11");
   Read_Integer ("1e1");
   Read_Integer ("x");
   Read_Colour ("green");
   Read_Colour (" Red ");
   Read_Colour ("BLUE");
   Read_Colour ("purple");
   if Byte'Valid_Value ("16#FF#") then
      Put_Line (Byte'Image (Byte'Value ("16#FF#")));
   end if;
   if not Byte'Valid_Value ("-0") and then not Byte'Valid_Value ("256") then
      Put_Line ("-0 and 256 are not Bytes");
   end if;
   if Mixed'Valid_Value ("'x'") and then Mixed'Valid_Value ("zed") and then not Mixed'Valid_Value ("'X'") then
      Put_Line (Mixed'Image (Mixed'Value ("'x'")) & " " & Mixed'Image (Mixed'Value ("zed")));
   end if;
   if Character'Valid_Value ("'A'") and then Character'Valid_Value ("nul") and then Character'Valid_Value ("RESERVED_153") then
      Put_Line (Integer'Image (Character'Pos (Character'Value ("'A'"))) & Integer'Image (Character'Pos (Character'Value ("nul")))
                & Integer'Image (Character'Pos (Character'Value ("RESERVED_153"))));
   end if;
   if Wide_Wide_Character'Valid_Value ("[""03B1""]") then
      Put_Line (Integer'Image (Wide_Wide_Character'Pos (Wide_Wide_Character'Value ("[""03B1""]"))));
   end if;
   if Float'Valid_Value (" 1.5E2 ") and then Long_Float'Valid_Value ("16#F.8#") and then not Float'Valid_Value ("1.")
     and then not Float'Valid_Value ("1E39") and then Long_Float'Valid_Value ("1E39")
     and then Long_Float'Valid_Value ("0.1")
   then
      Put_Line (Float'Image (Float'Value (" 1.5E2 ")) & Long_Float'Image (Long_Float'Value ("16#F.8#"))
                & Long_Float'Image (Long_Float'Value ("0.1")));
   end if;
   declare
      W : constant Wide_Wide_String := "  42";
   begin
      if Integer'Valid_Value (W) then
         Put_Line (Integer'Image (Integer'Wide_Wide_Value (W)));
      end if;
   end;
end Main;
