1------------------------------------------------------------------------------
2--                                                                          --
3--                            Matreshka Project                             --
4--                                                                          --
5--         Localization, Internationalization, Globalization for Ada        --
6--                                                                          --
7--                              Tools Component                             --
8--                                                                          --
9------------------------------------------------------------------------------
10--                                                                          --
11-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com>                --
12-- All rights reserved.                                                     --
13--                                                                          --
14-- Redistribution and use in source and binary forms, with or without       --
15-- modification, are permitted provided that the following conditions       --
16-- are met:                                                                 --
17--                                                                          --
18--  * Redistributions of source code must retain the above copyright        --
19--    notice, this list of conditions and the following disclaimer.         --
20--                                                                          --
21--  * Redistributions in binary form must reproduce the above copyright     --
22--    notice, this list of conditions and the following disclaimer in the   --
23--    documentation and/or other materials provided with the distribution.  --
24--                                                                          --
25--  * Neither the name of the Vadim Godunko, IE nor the names of its        --
26--    contributors may be used to endorse or promote products derived from  --
27--    this software without specific prior written permission.              --
28--                                                                          --
29-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      --
30-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        --
31-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    --
32-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     --
33-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   --
34-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
35-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR   --
36-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF   --
37-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     --
38-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS       --
39-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.             --
40--                                                                          --
41------------------------------------------------------------------------------
42--  $Revision: 2505 $ $Date: 2012-02-22 02:36:44 +0400 (Wed, 22 Feb 2012) $
43------------------------------------------------------------------------------
44
45with Ada.Wide_Wide_Text_IO;
46with League.Character_Sets;
47with Matreshka.Internals.Graphs;
48with Nodes;
49
50package body Debug is
51
52   procedure Print is
53      use Ada.Wide_Wide_Text_IO;
54
55      procedure Each_Condition (Cursor : Nodes.Start_Condition_Maps.Cursor);
56
57      procedure Each_Condition (Cursor : Nodes.Start_Condition_Maps.Cursor) is
58         Item : constant Nodes.Start_Condition :=
59           Nodes.Start_Condition_Maps.Element (Cursor);
60      begin
61         if Item.Exclusive then
62            Put_Line
63              ("%x " & Nodes.Start_Condition_Maps.Key (Cursor).
64                 To_Wide_Wide_String);
65         else
66            Put_Line
67              ("%s " & Nodes.Start_Condition_Maps.Key (Cursor).
68                 To_Wide_Wide_String);
69         end if;
70      end Each_Condition;
71
72      procedure Print_Macro (Position : Nodes.Macro_Maps.Cursor) is
73      begin
74         Put_Line (Nodes.Macro_Maps.Key (Position).To_Wide_Wide_String & " " &
75                     Nodes.Macro_Maps.Element (Position).To_Wide_Wide_String);
76      end Print_Macro;
77
78   begin
79      Nodes.Conditions.Iterate (Each_Condition'Access);
80
81      Nodes.Macros.Iterate (Print_Macro'Access);
82
83      Put_Line ("%%");
84
85      for J in 1 .. Nodes.Rules.Length loop
86         Put_Line (Nodes.Rules.Element (J).To_Wide_Wide_String & " " &
87                     Nodes.Actions.Element (J).To_Wide_Wide_String);
88      end loop;
89   end Print;
90
91   -----------------------------
92   -- Print_Character_Classes --
93   -----------------------------
94
95   procedure Print_Character_Classes
96     (Vector : Matreshka.Internals.Finite_Automatons.Vectors.Vector)
97   is
98      subtype Wide is Wide_Wide_Character range
99        Wide_Wide_Character'Val (0) .. Wide_Wide_Character'Val (16#10FFFF#);
100      use Ada.Wide_Wide_Text_IO;
101   begin
102      for J in Vector.First_Index .. Vector.Last_Index loop
103         Put_Line (Matreshka.Internals.Graphs.Edge_Identifier'Wide_Wide_Image
104                     (J));
105         declare
106            Item : constant League.Character_Sets.Universal_Character_Set :=
107              Vector.Element (J);
108         begin
109            for K in Wide loop
110               if Item.Has (K) then
111                  Put (K);
112               end if;
113            end loop;
114            New_Line;
115         end;
116      end loop;
117   end Print_Character_Classes;
118
119end Debug;
120