From 5cfb8e78cd5d7bdc83494bd72cbe17bf4921bda8 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Wed, 14 Aug 2019 08:22:20 +0200 Subject: vhdl: add PSL keywords to vhdl08 reserved words. --- src/vhdl/vhdl-formatters.adb | 2 +- src/vhdl/vhdl-parse.adb | 70 +++++++++++++++++++++----------------------- src/vhdl/vhdl-parse_psl.adb | 8 ++--- src/vhdl/vhdl-prints.adb | 12 ++++---- src/vhdl/vhdl-scanner.adb | 42 ++++++++++++++++++++------ src/vhdl/vhdl-tokens.adb | 28 +++++++++--------- src/vhdl/vhdl-tokens.ads | 14 ++++----- 7 files changed, 98 insertions(+), 78 deletions(-) (limited to 'src/vhdl') diff --git a/src/vhdl/vhdl-formatters.adb b/src/vhdl/vhdl-formatters.adb index f6103f571..807436033 100644 --- a/src/vhdl/vhdl-formatters.adb +++ b/src/vhdl/vhdl-formatters.adb @@ -36,7 +36,7 @@ package body Vhdl.Formatters is or else Current_Token = Tok_Subtype) then null; - elsif (Tok = Tok_Psl_Default + elsif (Tok = Tok_Default or else Tok = Tok_Psl_Clock) and then Current_Token = Tok_Identifier then diff --git a/src/vhdl/vhdl-parse.adb b/src/vhdl/vhdl-parse.adb index 8800da259..e10786022 100644 --- a/src/vhdl/vhdl-parse.adb +++ b/src/vhdl/vhdl-parse.adb @@ -4981,38 +4981,34 @@ package body Vhdl.Parse is -- Skip ';'. Scan; end if; - when Tok_Identifier => - if Vhdl_Std >= Vhdl_08 - and then Current_Identifier = Name_Default - then - -- This identifier is a PSL keyword. - Xrefs.Xref_Keyword (Get_Token_Location); + when Tok_Default => + -- This identifier is a PSL keyword. + Xrefs.Xref_Keyword (Get_Token_Location); - -- Check whether default clock are allowed in this region. - case Get_Kind (Parent) is - when Iir_Kind_Function_Body - | Iir_Kind_Procedure_Body - | Iir_Kinds_Process_Statement - | Iir_Kind_Protected_Type_Body - | Iir_Kind_Package_Declaration - | Iir_Kind_Package_Body - | Iir_Kind_Protected_Type_Declaration => - Error_Msg_Parse - ("PSL default clock declaration not allowed here"); - when Iir_Kind_Entity_Declaration - | Iir_Kind_Architecture_Body - | Iir_Kind_Block_Statement - | Iir_Kind_Generate_Statement_Body => - null; - when others => - Error_Kind ("parse_declarative_part", Parent); - end case; - Decl := Parse_Psl_Default_Clock; - else - Error_Msg_Parse - ("object class keyword such as 'variable' is expected"); - Resync_To_End_Of_Declaration; - end if; + -- Check whether default clock are allowed in this region. + case Get_Kind (Parent) is + when Iir_Kind_Function_Body + | Iir_Kind_Procedure_Body + | Iir_Kinds_Process_Statement + | Iir_Kind_Protected_Type_Body + | Iir_Kind_Package_Declaration + | Iir_Kind_Package_Body + | Iir_Kind_Protected_Type_Declaration => + Error_Msg_Parse + ("PSL default clock declaration not allowed here"); + when Iir_Kind_Entity_Declaration + | Iir_Kind_Architecture_Body + | Iir_Kind_Block_Statement + | Iir_Kind_Generate_Statement_Body => + null; + when others => + Error_Kind ("parse_declarative_part", Parent); + end case; + Decl := Parse_Psl_Default_Clock; + when Tok_Identifier => + Error_Msg_Parse + ("object class keyword such as 'variable' is expected"); + Resync_To_End_Of_Declaration; when Tok_Semi_Colon => Error_Msg_Parse ("';' (semi colon) not allowed alone"); Scan; @@ -8836,23 +8832,23 @@ package body Vhdl.Parse is Stmt := Parse_Component_Instantiation (Unit); Set_Has_Component (Stmt, Has_Component); end; - when Tok_Psl_Default => + when Tok_Default => Postponed_Not_Allowed; Label_Not_Allowed; Stmt := Parse_Psl_Default_Clock; - when Tok_Psl_Property - | Tok_Psl_Sequence + when Tok_Property + | Tok_Sequence | Tok_Psl_Endpoint => Postponed_Not_Allowed; Label_Not_Allowed; Stmt := Parse_Psl_Declaration; - when Tok_Psl_Assume => + when Tok_Assume => Postponed_Not_Allowed; Stmt := Parse_Psl_Assume_Directive; - when Tok_Psl_Cover => + when Tok_Cover => Postponed_Not_Allowed; Stmt := Parse_Psl_Cover_Directive; - when Tok_Psl_Restrict => + when Tok_Restrict => Postponed_Not_Allowed; Stmt := Parse_Psl_Restrict_Directive; when Tok_Wait diff --git a/src/vhdl/vhdl-parse_psl.adb b/src/vhdl/vhdl-parse_psl.adb index 561f9caff..b4957b1ab 100644 --- a/src/vhdl/vhdl-parse_psl.adb +++ b/src/vhdl/vhdl-parse_psl.adb @@ -812,9 +812,9 @@ package body Vhdl.Parse_Psl is Kind : Nkind; begin case Tok is - when Tok_Psl_Property => + when Tok_Property => Kind := N_Property_Declaration; - when Tok_Psl_Sequence => + when Tok_Sequence => Kind := N_Sequence_Declaration; when Tok_Psl_Endpoint => Kind := N_Endpoint_Declaration; @@ -838,9 +838,9 @@ package body Vhdl.Parse_Psl is Pkind := N_Const_Parameter; when Tok_Psl_Boolean => Pkind := N_Boolean_Parameter; - when Tok_Psl_Property => + when Tok_Property => Pkind := N_Property_Parameter; - when Tok_Psl_Sequence => + when Tok_Sequence => Pkind := N_Sequence_Parameter; when others => Error_Msg_Parse ("parameter type expected"); diff --git a/src/vhdl/vhdl-prints.adb b/src/vhdl/vhdl-prints.adb index b66bb57ed..09c6f5ff4 100644 --- a/src/vhdl/vhdl-prints.adb +++ b/src/vhdl/vhdl-prints.adb @@ -2116,7 +2116,7 @@ package body Vhdl.Prints is if Vhdl_Std < Vhdl_08 then OOB.Put ("--psl "); end if; - Disp_Token (Ctxt, Tok_Psl_Default, Tok_Psl_Clock); + Disp_Token (Ctxt, Tok_Default, Tok_Psl_Clock); Disp_Token (Ctxt, Tok_Is); Disp_Psl_Expression (Ctxt, Get_Psl_Boolean (Stmt)); Disp_Token (Ctxt, Tok_Semi_Colon); @@ -2132,13 +2132,13 @@ package body Vhdl.Prints is end if; case Get_Kind (Decl) is when N_Property_Declaration => - Disp_Token (Ctxt, Tok_Psl_Property); + Disp_Token (Ctxt, Tok_Property); Disp_Ident (Ctxt, Get_Identifier (Decl)); Disp_Token (Ctxt, Tok_Is); Disp_Psl_Expression (Ctxt, Get_Property (Decl)); Disp_Token (Ctxt, Tok_Semi_Colon); when N_Sequence_Declaration => - Disp_Token (Ctxt, Tok_Psl_Sequence); + Disp_Token (Ctxt, Tok_Sequence); Disp_Ident (Ctxt, Get_Identifier (Decl)); Disp_Token (Ctxt, Tok_Is); Print_Sequence (Ctxt, Get_Sequence (Decl)); @@ -3926,7 +3926,7 @@ package body Vhdl.Prints is end if; Disp_Label (Ctxt, Stmt); Disp_Postponed (Ctxt, Stmt); - Disp_Token (Ctxt, Tok_Psl_Assume); + Disp_Token (Ctxt, Tok_Assume); Disp_Psl_Expression (Ctxt, Get_Psl_Property (Stmt)); Disp_Token (Ctxt, Tok_Semi_Colon); Close_Hbox (Ctxt); @@ -3941,7 +3941,7 @@ package body Vhdl.Prints is OOB.Put ("--psl "); end if; Disp_Label (Ctxt, Stmt); - Disp_Token (Ctxt, Tok_Psl_Cover); + Disp_Token (Ctxt, Tok_Cover); Print_Sequence (Ctxt, Get_Psl_Sequence (Stmt)); Disp_Report_Expression (Ctxt, Stmt); Disp_Token (Ctxt, Tok_Semi_Colon); @@ -3957,7 +3957,7 @@ package body Vhdl.Prints is OOB.Put ("--psl "); end if; Disp_Label (Ctxt, Stmt); - Disp_Token (Ctxt, Tok_Psl_Restrict); + Disp_Token (Ctxt, Tok_Restrict); Print_Sequence (Ctxt, Get_Psl_Sequence (Stmt)); Disp_Token (Ctxt, Tok_Semi_Colon); Close_Hbox (Ctxt); diff --git a/src/vhdl/vhdl-scanner.adb b/src/vhdl/vhdl-scanner.adb index 2f08ffbab..e71b2936e 100644 --- a/src/vhdl/vhdl-scanner.adb +++ b/src/vhdl/vhdl-scanner.adb @@ -1255,13 +1255,37 @@ package body Vhdl.Scanner is end if; when Std_Names.Name_Id_Vhdl08_Reserved_Words => if Vhdl_Std < Vhdl_08 then - if Is_Warning_Enabled (Warnid_Reserved_Word) then + -- Some vhdl08 reserved words are PSL keywords. + if Flag_Psl then + case Current_Identifier is + when Std_Names.Name_Sequence => + Current_Token := Tok_Sequence; + when Std_Names.Name_Property => + Current_Token := Tok_Property; + when Std_Names.Name_Assume => + Current_Token := Tok_Assume; + when Std_Names.Name_Cover => + Current_Token := Tok_Cover; + when Std_Names.Name_Default => + Current_Token := Tok_Default; + when Std_Names.Name_Restrict => + Current_Token := Tok_Restrict; + when Std_Names.Name_Restrict_Guarantee => + Current_Token := Tok_Restrict_Guarantee; + when others => + Current_Token := Tok_Identifier; + end case; + else + Current_Token := Tok_Identifier; + end if; + if Is_Warning_Enabled (Warnid_Reserved_Word) + and then Current_Token = Tok_Identifier + then Warning_Msg_Scan (Warnid_Reserved_Word, "using %i vhdl-2008 reserved word as an identifier", +Current_Identifier); end if; - Current_Token := Tok_Identifier; end if; when Std_Names.Name_Id_Vhdl00_Reserved_Words => if Vhdl_Std < Vhdl_00 then @@ -1302,21 +1326,21 @@ package body Vhdl.Scanner is when Std_Names.Name_Boolean => Current_Token := Tok_Psl_Boolean; when Std_Names.Name_Sequence => - Current_Token := Tok_Psl_Sequence; + Current_Token := Tok_Sequence; when Std_Names.Name_Property => - Current_Token := Tok_Psl_Property; + Current_Token := Tok_Property; when Std_Names.Name_Endpoint => Current_Token := Tok_Psl_Endpoint; when Std_Names.Name_Assume => - Current_Token := Tok_Psl_Assume; + Current_Token := Tok_Assume; when Std_Names.Name_Cover => - Current_Token := Tok_Psl_Cover; + Current_Token := Tok_Cover; when Std_Names.Name_Default => - Current_Token := Tok_Psl_Default; + Current_Token := Tok_Default; when Std_Names.Name_Restrict => - Current_Token := Tok_Psl_Restrict; + Current_Token := Tok_Restrict; when Std_Names.Name_Restrict_Guarantee => - Current_Token := Tok_Psl_Restrict_Guarantee; + Current_Token := Tok_Restrict_Guarantee; when Std_Names.Name_Inf => Current_Token := Tok_Inf; when Std_Names.Name_Within => diff --git a/src/vhdl/vhdl-tokens.adb b/src/vhdl/vhdl-tokens.adb index 1f17c5092..b06f916d7 100644 --- a/src/vhdl/vhdl-tokens.adb +++ b/src/vhdl/vhdl-tokens.adb @@ -352,10 +352,24 @@ package body Vhdl.Tokens is return "protected"; -- VHDL 08 + when Tok_Assume => + return "assume"; when Tok_Context => return "context"; + when Tok_Cover => + return "cover"; + when Tok_Default => + return "default"; when Tok_Parameter => return "parameter"; + when Tok_Property => + return "property"; + when Tok_Restrict => + return "restrict"; + when Tok_Restrict_Guarantee => + return "restrict_guarantee"; + when Tok_Sequence => + return "sequence"; -- AMS-VHDL when Tok_Across => @@ -412,24 +426,10 @@ package body Vhdl.Tokens is when Tok_Arobase => return "@"; - when Tok_Psl_Default => - return "default"; when Tok_Psl_Clock => return "clock"; - when Tok_Psl_Property => - return "property"; - when Tok_Psl_Sequence => - return "sequence"; when Tok_Psl_Endpoint => return "endpoint"; - when Tok_Psl_Assume => - return "assume"; - when Tok_Psl_Cover => - return "cover"; - when Tok_Psl_Restrict => - return "restrict"; - when Tok_Psl_Restrict_Guarantee => - return "restrict_guarantee"; when Tok_Psl_Const => return "const"; when Tok_Psl_Boolean => diff --git a/src/vhdl/vhdl-tokens.ads b/src/vhdl/vhdl-tokens.ads index f8e2dd14e..739134d2c 100644 --- a/src/vhdl/vhdl-tokens.ads +++ b/src/vhdl/vhdl-tokens.ads @@ -237,8 +237,15 @@ package Vhdl.Tokens is Tok_Protected, -- Added by vhdl 2008: + Tok_Assume, Tok_Context, + Tok_Cover, + Tok_Default, Tok_Parameter, + Tok_Property, + Tok_Restrict, + Tok_Restrict_Guarantee, + Tok_Sequence, -- AMS reserved words Tok_Across, @@ -256,15 +263,8 @@ package Vhdl.Tokens is Tok_Tolerance, -- PSL words - Tok_Psl_Default, Tok_Psl_Clock, - Tok_Psl_Property, - Tok_Psl_Sequence, Tok_Psl_Endpoint, - Tok_Psl_Assume, - Tok_Psl_Cover, - Tok_Psl_Restrict, - Tok_Psl_Restrict_Guarantee, Tok_Psl_Const, Tok_Psl_Boolean, -- cgit v1.2.3