anagram_1.0.0_49233f56/sources/anagram-grammars-conflicts.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
--  Copyright (c) 2010-2017 Maxim Reznik <reznikmm@gmail.com>
--
--  SPDX-License-Identifier: MIT
--  License-Filename: LICENSE
-------------------------------------------------------------

--  This package resolves conflict in a parse table using precedence and
--  associativiti information of terminals and productions.

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

package Anagram.Grammars.Conflicts is

   type Resolver is tagged private;

   procedure Resolve
     (Self  : in out Resolver;
      Input : Grammar;
      Table : in out LR_Tables.Table);

private

   package Priority_Maps is new Ada.Containers.Ordered_Maps
     (Precedence_Level, Associate_Kind);

   type Resolver is tagged record
      Checks : Priority_Maps.Map;
   end record;

   procedure Check_Priority
     (Self : in out Resolver;
      Prec : Precedence_Value);

   procedure Try_To_Resolve
     (Self     : in out Resolver;
      Input    : Grammar;
      Table    : in out LR_Tables.Table;
      State    : LR.State_Index;
      Terminal : Terminal_Index);

end Anagram.Grammars.Conflicts;