text
stringlengths
0
234
if Value > Max then
Max := Value;
end if;
end if;
First := Last + 1;
Last := First;
elsif Last = Line'Last then
Get (Line (First .. Line'Last), Value, Last_Index);
Crabs.Append (Value);
if Value < Min then
Value := Min;
end if;
if Value > Max then
Value := Max;
end if;
Last := Last + 1;
else
Last := Last + 1;
end if;
end loop;
Function Definition: procedure Main is
Function Body: use Ada.Execution_Time,
Ada.Real_Time,
Ada.Strings.Unbounded,
Ada.Text_IO;
use Utils;
Max_Steps : constant := 10;
subtype Rule_Str is String (1 .. 2);
subtype Long_Long_Natural is Long_Long_Integer range 0 .. Long_Long_Integer'Last;
package Rule_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Rule_Str,
Element_Type => Character,
Hash => Ada.Strings.Hash,
Equivalent_Keys => "=",
"=" => "=");
package Rule_Counter_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Rule_Str,
Element_Type => Long_Long_Natural,
Hash => Ada.Strings.Hash,
Equivalent_Keys => "=",
"=" => "=");
use Rule_Maps;
use Rule_Counter_Maps;
File : File_Type;
Start_Time, End_Time : CPU_Time;
Execution_Duration : Time_Span;
File_Is_Empty : Boolean := True;
Result : Long_Long_Natural := Long_Long_Natural'First;
Rules : Rule_Maps.Map := Rule_Maps.Empty_Map;
Counter : Rule_Counter_Maps.Map := Rule_Counter_Maps.Empty_Map;
Polymer_Template : Unbounded_String;
begin
Get_File (File);
Polymer_Template := To_Unbounded_String (Get_Line (File));
-- Get all rules
begin
while not End_Of_File (File) loop
declare
Str : constant String := Get_Line (File);
begin
if Str'Length = 0 then
goto Continue_Next_Line;
end if;
declare
Pattern : constant String := " -> ";
Separator_Index : constant Integer :=
Ada.Strings.Fixed.Index (Source => Str (1 .. Str'Last), Pattern => Pattern);
Left_Str : constant String := Str (1 .. Separator_Index - 1);
Right_Str : constant String := Str (Separator_Index + Pattern'Length .. Str'Last);
begin
Rules.Include (Rule_Str (Left_Str), Right_Str (Right_Str'First));
Function Definition: procedure Main is
Function Body: use Ada.Execution_Time,
Ada.Real_Time,
Ada.Strings.Unbounded,
Ada.Text_IO;
use Utils;
Max_Steps : constant := 40;
subtype Rule_Str is String (1 .. 2);
subtype Long_Long_Natural is Long_Long_Integer range 0 .. Long_Long_Integer'Last;
package Rule_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Rule_Str,
Element_Type => Character,
Hash => Ada.Strings.Hash,
Equivalent_Keys => "=",
"=" => "=");