diff options
-rw-r--r-- | pyGHDL/libghdl/file_comments.py | 2 | ||||
-rw-r--r-- | src/vhdl/vhdl-parse.adb | 31 | ||||
-rw-r--r-- | testsuite/pyunit/libghdl/DesignComment.vhdl (renamed from testsuite/pyunit/DesignComment.vhdl) | 0 |
3 files changed, 32 insertions, 1 deletions
diff --git a/pyGHDL/libghdl/file_comments.py b/pyGHDL/libghdl/file_comments.py index 1a942d008..a1ca11384 100644 --- a/pyGHDL/libghdl/file_comments.py +++ b/pyGHDL/libghdl/file_comments.py @@ -83,7 +83,7 @@ def Get_Comment(File: SourceFileEntry, Idx: Comment_Index) -> str: buf = files_map.Get_File_Buffer(File) s = Get_Comment_Start(File, Idx); l = Get_Comment_Last(File, Idx); - return buf[s:l].decode("iso-8859-1") + return buf[s:l+1].decode("iso-8859-1") @export @BindToLibGHDL("file_comments__get_next_comment") diff --git a/src/vhdl/vhdl-parse.adb b/src/vhdl/vhdl-parse.adb index 7e47e05cb..dee22aaed 100644 --- a/src/vhdl/vhdl-parse.adb +++ b/src/vhdl/vhdl-parse.adb @@ -1714,6 +1714,7 @@ package body Vhdl.Parse is Set_Start_Location (First, Get_Token_Location); end if; + -- Comments for the interface. if Flag_Gather_Comments then Gather_Comments (First); end if; @@ -5696,6 +5697,12 @@ package body Vhdl.Parse is -- Skip 'is'. Expect_Scan (Tok_Is); + -- Comments after 'entity' but before the first generic or port are + -- attached to the entity. + if Flag_Gather_Comments then + Gather_Comments (Res); + end if; + Parse_Generic_Port_Clauses (Res); Parse_Declarative_Part (Res, Res); @@ -10541,6 +10548,12 @@ package body Vhdl.Parse is -- Skip 'is'. Expect_Scan (Tok_Is); + -- Comments after 'architecture' but before the first declaration are + -- attached to the architecture. + if Flag_Gather_Comments then + Gather_Comments (Res); + end if; + Parse_Declarative_Part (Res, Res); -- Skip 'begin'. @@ -11032,6 +11045,12 @@ package body Vhdl.Parse is -- Skip 'is'. Expect_Scan (Tok_Is); + -- Comments after 'context' but before the first clause are attached + -- to the context. + if Flag_Gather_Comments then + Gather_Comments (Res); + end if; + Parse_Configuration_Declarative_Part (Res); Set_Block_Configuration (Res, Parse_Block_Configuration); @@ -11132,6 +11151,12 @@ package body Vhdl.Parse is Set_Identifier (Res, Id); Set_Parent (Res, Parent); + -- Comments after 'package' but before the first declaration are + -- attached to the package. + if Flag_Gather_Comments then + Gather_Comments (Res); + end if; + if Current_Token = Tok_Generic then Check_Vhdl_At_Least_2008 ("generic packages"); Set_Package_Header (Res, Parse_Package_Header); @@ -11592,6 +11617,12 @@ package body Vhdl.Parse is -- Skip 'is' Scan; + -- Comments after 'context' but before the first clause are attached + -- to the context. + if Flag_Gather_Comments then + Gather_Comments (Decl); + end if; + Parse_Context_Clause (Decl); Expect (Tok_End); diff --git a/testsuite/pyunit/DesignComment.vhdl b/testsuite/pyunit/libghdl/DesignComment.vhdl index 5cd555d33..5cd555d33 100644 --- a/testsuite/pyunit/DesignComment.vhdl +++ b/testsuite/pyunit/libghdl/DesignComment.vhdl |