anagram_1.0.0_49233f56/sources/anagram-grammars-ordered.ads

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
--  Copyright (c) 2010-2017 Maxim Reznik <reznikmm@gmail.com>
--
--  SPDX-License-Identifier: MIT
--  License-Filename: LICENSE
-------------------------------------------------------------

with Anagram.Grammars;
with Ada.Containers.Ordered_Maps;

package Anagram.Grammars.Ordered is

   type Partition_Count is new Natural;
   subtype Partition_Index is Partition_Count range 1 .. Partition_Count'Last;

   type Partition_Array is array (Attribute_Declaration_Index range <>)
     of Partition_Count;

   type Key is record
      Prod : Production_Index;
      Pass : Positive;
      Step : Positive;
   end record;

   function "<" (Left, Right : Key) return Boolean;

   type Action_Kinds is (Evaluate_Rule, Descent);

   type Action (Kind : Action_Kinds := Action_Kinds'First) is record
      case Kind is
         when Evaluate_Rule =>
            Rule : Rule_Index;
         when Descent =>
            Part : Part_Index;
            Pass : Positive;
      end case;
   end record;

   package Order_Maps is new Ada.Containers.Ordered_Maps (Key, Action);

   procedure Find_Order
     (Input      : Grammar;
      Found      : out Boolean;
      Partitions : out Partition_Array;
      Order      : out Order_Maps.Map);

   function To_Pass
     (Partitions : Partition_Array;
      Attr       : Attribute_Declaration_Index) return Natural;
   --  If Partitions in partition of some NT and Attr is synthesized attribute
   --  of NT, then return pass number where it will be calculated

end Anagram.Grammars.Ordered;