diff options
author | Tristan Gingold <tgingold@free.fr> | 2023-03-08 07:52:26 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2023-03-08 07:52:26 +0100 |
commit | 1cc4e516e137b9732ff098e59c433af4d75e016c (patch) | |
tree | dc381423a3535e0916cf1911f248f786cb9b68c4 /src/psl | |
parent | c6852822578a4d9a52ad60f4a9e06714731f08c2 (diff) | |
download | ghdl-1cc4e516e137b9732ff098e59c433af4d75e016c.tar.gz ghdl-1cc4e516e137b9732ff098e59c433af4d75e016c.tar.bz2 ghdl-1cc4e516e137b9732ff098e59c433af4d75e016c.zip |
psl-build.adb(build_plus_repeat): fix handling of single edge NFA
For #2373
Diffstat (limited to 'src/psl')
-rw-r--r-- | src/psl/psl-build.adb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/psl/psl-build.adb b/src/psl/psl-build.adb index 0609c7405..02c4961ff 100644 --- a/src/psl/psl-build.adb +++ b/src/psl/psl-build.adb @@ -418,17 +418,29 @@ package body PSL.Build is return Res; end Build_Star_Repeat; - function Build_Plus_Repeat (N : Node) return NFA is + function Build_Plus_Repeat (N : Node) return NFA + is Res : NFA; - Start, Final : NFA_State; + Start, Final, Src : NFA_State; T : NFA_Edge; begin Res := Build_SERE_FA (Get_Sequence (N)); Start := Get_Start_State (Res); Final := Get_Final_State (Res); + + -- Create edges from pre-final to start. T := Get_First_Dest_Edge (Final); while T /= No_Edge loop - Add_Edge (Get_Edge_Src (T), Start, Get_Edge_Expr (T)); + Src := Get_Edge_Src (T); + if Src /= Start then + -- Normal before-final to start. + Add_Edge (Src, Start, Get_Edge_Expr (T)); + else + -- Do not create edges from start to start, as this is not the + -- correct sequence (it will accept words like 001, while + -- the first letter must be 1). + Add_Edge (Final, Final, Get_Edge_Expr (T)); + end if; T := Get_Next_Src_Edge (T); end loop; return Res; |