diff options
author | Tristan Gingold <tgingold@free.fr> | 2021-04-03 16:48:08 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2021-04-03 16:48:08 +0200 |
commit | 6617613f93e70df2e2b964f380652ea43e2bb2a5 (patch) | |
tree | 2ce620bb15fc0e5e59fc61e1f4e4a1936b985049 /src/vhdl | |
parent | bfc5f5c20b791e09b5a2d80aeea5ce77b84d309f (diff) | |
download | ghdl-6617613f93e70df2e2b964f380652ea43e2bb2a5.tar.gz ghdl-6617613f93e70df2e2b964f380652ea43e2bb2a5.tar.bz2 ghdl-6617613f93e70df2e2b964f380652ea43e2bb2a5.zip |
psl: prefix of goto/non-consecutive repetition is a bool. Fix #1708
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/vhdl-parse_psl.adb | 86 | ||||
-rw-r--r-- | src/vhdl/vhdl-prints.adb | 23 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_psl.adb | 20 |
3 files changed, 91 insertions, 38 deletions
diff --git a/src/vhdl/vhdl-parse_psl.adb b/src/vhdl/vhdl-parse_psl.adb index eaabd852b..b7d6c1df4 100644 --- a/src/vhdl/vhdl-parse_psl.adb +++ b/src/vhdl/vhdl-parse_psl.adb @@ -337,23 +337,26 @@ package body Vhdl.Parse_Psl is end Parse_Braced_SERE; -- Parse [ Count ] ']' - function Parse_Maybe_Count (Kind : Nkind; Seq : Node) return Node + function Parse_Brack_Star (Seq : Node) return Node is - N : Node; + Res : Node; begin - N := Create_Node_Loc (Kind); - Set_Sequence (N, Seq); + Res := Create_Node_Loc (N_Star_Repeat_Seq); + Set_Sequence (Res, Seq); + + -- Skip '[->' Scan; + if Current_Token /= Tok_Right_Bracket then - Parse_Count (N); + Parse_Count (Res); end if; if Current_Token /= Tok_Right_Bracket then Error_Msg_Parse ("missing ']'"); else Scan; end if; - return N; - end Parse_Maybe_Count; + return Res; + end Parse_Brack_Star; procedure Parse_Bracket_Range (N : Node) is begin @@ -396,6 +399,44 @@ package body Vhdl.Parse_Psl is end if; end Parse_Bracket_Number; + function Parse_Brack_Equal (Left : Node) return Node + is + Res : Node; + begin + Res := Create_Node_Loc (N_Equal_Repeat_Seq); + Set_Boolean (Res, Left); + + -- Skip '[=' + Scan; + Parse_Count (Res); + if Current_Token /= Tok_Right_Bracket then + Error_Msg_Parse ("missing ']'"); + else + Scan; + end if; + return Res; + end Parse_Brack_Equal; + + function Parse_Brack_Arrow (Left : Node) return Node + is + Res : Node; + begin + Res := Create_Node_Loc (N_Goto_Repeat_Seq); + Set_Boolean (Res, Left); + + -- Skip '[->' + Scan; + if Current_Token /= Tok_Right_Bracket then + Parse_Count (Res); + end if; + if Current_Token /= Tok_Right_Bracket then + Error_Msg_Parse ("missing ']'"); + else + Scan; + end if; + return Res; + end Parse_Brack_Arrow; + function Parse_Psl_Sequence_Or_SERE (Full_Hdl_Expr : Boolean) return Node is Res, N : Node; @@ -414,7 +455,7 @@ package body Vhdl.Parse_Psl is Res := N; end if; when Tok_Brack_Star => - return Parse_Maybe_Count (N_Star_Repeat_Seq, Null_Node); + return Parse_Brack_Star (Null_Node); when Tok_Left_Paren => if Parse.Flag_Parse_Parenthesis then Res := Create_Node_Loc (N_Paren_Bool); @@ -438,14 +479,24 @@ package body Vhdl.Parse_Psl is Res := Create_Node_Loc (N_Plus_Repeat_Seq); Scan; return Res; + when others => -- Repeated_SERE Res := Parse_Unary_Boolean (Full_Hdl_Expr); + + case Current_Token is + when Tok_Brack_Equal => + Res := Parse_Brack_Equal (Res); + when Tok_Brack_Arrow => + Res := Parse_Brack_Arrow (Res); + when others => + null; + end case; end case; loop case Current_Token is when Tok_Brack_Star => - Res := Parse_Maybe_Count (N_Star_Repeat_Seq, Res); + Res := Parse_Brack_Star (Res); when Tok_Brack_Plus_Brack => N := Create_Node_Loc (N_Plus_Repeat_Seq); Set_Sequence (N, Res); @@ -454,20 +505,11 @@ package body Vhdl.Parse_Psl is Scan; Res := N; when Tok_Brack_Arrow => - Res := Parse_Maybe_Count (N_Goto_Repeat_Seq, Res); + Error_Msg_Parse ("'[->' not allowed on a SERE"); + Res := Parse_Brack_Arrow (Res); when Tok_Brack_Equal => - N := Create_Node_Loc (N_Equal_Repeat_Seq); - Set_Sequence (N, Res); - - -- Skip '[=' - Scan; - Parse_Count (N); - if Current_Token /= Tok_Right_Bracket then - Error_Msg_Parse ("missing ']'"); - else - Scan; - end if; - Res := N; + Error_Msg_Parse ("'[=' not allowed on a SERE"); + Res := Parse_Brack_Equal (Res); when others => exit; end case; diff --git a/src/vhdl/vhdl-prints.adb b/src/vhdl/vhdl-prints.adb index 6016c23e2..35a6f4958 100644 --- a/src/vhdl/vhdl-prints.adb +++ b/src/vhdl/vhdl-prints.adb @@ -2032,19 +2032,26 @@ package body Vhdl.Prints is Print_Sequence (Ctxt, Get_Right (N), Prio); end Print_Binary_Sequence; - procedure Print_Repeat_Sequence - (Ctxt : in out Ctxt_Class; Tok : Token_Type; N : PSL_Node) + procedure Print_Seq_Repeat_Sere (Ctxt : in out Ctxt_Class; N : PSL_Node) is - S : PSL_Node; + S : constant PSL_Node := Get_Sequence (N); begin - S := Get_Sequence (N); if S /= Null_PSL_Node then Print_Sequence (Ctxt, S, Prio_SERE_Repeat); end if; + Disp_Token (Ctxt, Tok_Brack_Star); + Print_Count (Ctxt, N); + Disp_Token (Ctxt, Tok_Right_Bracket); + end Print_Seq_Repeat_Sere; + + procedure Print_Bool_Repeat_Sere + (Ctxt : in out Ctxt_Class; Tok : Token_Type; N : PSL_Node) is + begin + Print_Expr (Ctxt, Get_Boolean (N)); Disp_Token (Ctxt, Tok); Print_Count (Ctxt, N); Disp_Token (Ctxt, Tok_Right_Bracket); - end Print_Repeat_Sequence; + end Print_Bool_Repeat_Sere; procedure Print_Sequence (Ctxt : in out Ctxt_Class; Seq : PSL_Node; @@ -2075,11 +2082,11 @@ package body Vhdl.Prints is when N_And_Seq => Print_Binary_Sequence (Ctxt, Tok_Ampersand, Seq, Prio); when N_Star_Repeat_Seq => - Print_Repeat_Sequence (Ctxt, Tok_Brack_Star, Seq); + Print_Seq_Repeat_Sere (Ctxt, Seq); when N_Goto_Repeat_Seq => - Print_Repeat_Sequence (Ctxt, Tok_Brack_Arrow, Seq); + Print_Bool_Repeat_Sere (Ctxt, Tok_Brack_Arrow, Seq); when N_Equal_Repeat_Seq => - Print_Repeat_Sequence (Ctxt, Tok_Brack_Equal, Seq); + Print_Bool_Repeat_Sere (Ctxt, Tok_Brack_Equal, Seq); when N_Plus_Repeat_Seq => Print_Sequence (Ctxt, Get_Sequence (Seq), Prio); Disp_Token (Ctxt, Tok_Brack_Plus_Brack); diff --git a/src/vhdl/vhdl-sem_psl.adb b/src/vhdl/vhdl-sem_psl.adb index 7e1f805eb..f6be38207 100644 --- a/src/vhdl/vhdl-sem_psl.adb +++ b/src/vhdl/vhdl-sem_psl.adb @@ -435,20 +435,24 @@ package body Vhdl.Sem_Psl is Set_Right (Seq, R); return Seq; when N_Star_Repeat_Seq - | N_Plus_Repeat_Seq - | N_Equal_Repeat_Seq - | N_Goto_Repeat_Seq => + | N_Plus_Repeat_Seq => Res := Get_Sequence (Seq); if Res /= Null_PSL_Node then - Res := Sem_Sequence (Get_Sequence (Seq)); + Res := Sem_Sequence (Res); Set_Sequence (Seq, Res); end if; - -- TODO: Fix here if SERE is not of boolean type for - -- Equal Repeat and goto repeat!! + return Seq; + when N_Equal_Repeat_Seq + | N_Goto_Repeat_Seq => + Res := Get_Boolean (Seq); + if Res /= Null_PSL_Node then + Res := Sem_Boolean (Res); + Set_Boolean (Seq, Res); + end if; return Seq; when N_And_Bool - | N_Or_Bool - | N_Not_Bool => + | N_Or_Bool + | N_Not_Bool => return Sem_Boolean (Seq); when N_HDL_Expr => Res := Sem_Hdl_Expr (Seq); |