aboutsummaryrefslogtreecommitdiffstats
path: root/src/psl
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2023-01-31 18:47:49 +0100
committerTristan Gingold <tgingold@free.fr>2023-01-31 18:47:49 +0100
commit00053acee65234c5d96c329e573f219d031c6aca (patch)
treed595c2873e1655e25210272b47a2cb201845c10b /src/psl
parent50758607ddb6c5c96fc4d26e795cb37d83272768 (diff)
downloadghdl-00053acee65234c5d96c329e573f219d031c6aca.tar.gz
ghdl-00053acee65234c5d96c329e573f219d031c6aca.tar.bz2
ghdl-00053acee65234c5d96c329e573f219d031c6aca.zip
psl-disp_nfas: add Dump_NFA
Diffstat (limited to 'src/psl')
-rw-r--r--src/psl/psl-disp_nfas.adb54
-rw-r--r--src/psl/psl-disp_nfas.ads3
2 files changed, 57 insertions, 0 deletions
diff --git a/src/psl/psl-disp_nfas.adb b/src/psl/psl-disp_nfas.adb
index 649d29ce3..c63995ca3 100644
--- a/src/psl/psl-disp_nfas.adb
+++ b/src/psl/psl-disp_nfas.adb
@@ -16,6 +16,7 @@
with Ada.Text_IO; use Ada.Text_IO;
with Types; use Types;
+with PSL.Types;
with PSL.Prints; use PSL.Prints;
package body PSL.Disp_NFAs is
@@ -124,4 +125,57 @@ package body PSL.Disp_NFAs is
end Debug_NFA;
pragma Unreferenced (Debug_NFA);
+
+ procedure Dump_NFA (N : NFA)
+ is
+ use PSL.Types;
+ procedure Disp_State (S : NFA_State)
+ is
+ Str : constant String := Int32'Image (Get_State_Label (S));
+ S1 : constant String := NFA_State'Image (S);
+ begin
+ Put (Str (2 .. Str'Last));
+ Put ("[");
+ Put (S1 (2 .. S1'Last));
+ Put ("]");
+ end Disp_State;
+
+ S : NFA_State;
+ E : NFA_Edge;
+ begin
+ if N = No_NFA then
+ return;
+ end if;
+
+ Put ("start: ");
+ Disp_State (Get_Start_State (N));
+ Put (", final: ");
+ Disp_State (Get_Final_State (N));
+ Put (", active: ");
+ S := Get_Active_State (N);
+ if S = No_State then
+ Put ("-");
+ else
+ Disp_State (S);
+ end if;
+ if Get_Epsilon_NFA (N) then
+ Put (", epsilon");
+ end if;
+ New_Line;
+
+ S := Get_First_State (N);
+ while S /= No_State loop
+ E := Get_First_Src_Edge (S);
+ while E /= No_Edge loop
+ Disp_State (S);
+ Put (" -> ");
+ Disp_State (Get_Edge_Dest (E));
+ Put (": ");
+ Print_Expr (Get_Edge_Expr (E));
+ New_Line;
+ E := Get_Next_Src_Edge (E);
+ end loop;
+ S := Get_Next_State (S);
+ end loop;
+ end Dump_NFA;
end PSL.Disp_NFAs;
diff --git a/src/psl/psl-disp_nfas.ads b/src/psl/psl-disp_nfas.ads
index f40e8699d..bdfce022b 100644
--- a/src/psl/psl-disp_nfas.ads
+++ b/src/psl/psl-disp_nfas.ads
@@ -25,4 +25,7 @@ package PSL.Disp_NFAs is
procedure Disp_State (S : NFA_State);
procedure Disp_NFA (N : NFA; Name : String := "nfa");
+
+ -- For debug.
+ procedure Dump_NFA (N : NFA);
end PSL.Disp_NFAs;