Skip to content

Commit c5cf594

Browse files
author
Katharina Ceesay-Seitz
committed
Destinguish between line comments for ports of the same type and for the whole port list
1 parent e57858f commit c5cf594

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

hdlparse/vhdl_parser.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,12 @@
104104
(r'--.*\n', None),
105105
],
106106
'generic_param_type': [
107-
(r'\s*(\w+)\s*', 'generic_param_type'),
107+
(r'\s*(\w+)[ \t\r\f\v]*', 'generic_param_type'),
108108
(r'\s*;\s*', None, '#pop'),
109109
(r"\s*:=\s*([\w']+)", 'generic_param_default'),
110+
(r'\)\s*;\s*--(.*)\n', 'line_comment', '#pop:2'),
111+
(r'\n\s*\)\s*;\s*--(.*)\n', 'generic_list_comment', '#pop:2'),
112+
(r'\n\s*', None),
110113
(r'\)\s*;', 'end_generic', '#pop:2'),
111114
(r'--#(.*)\n', 'metacomment'),
112115
(r'/\*', 'block_comment', 'block_comment'),
@@ -123,10 +126,13 @@
123126
],
124127
'port_param_type': [
125128
(r'\s*(in|out|inout|buffer)\s+(\w+)\s*\(', 'port_array_param_type', 'array_range'),
126-
(r'\s*(in|out|inout|buffer)\s+(\w+)\s*', 'port_param_type'),
129+
(r'\s*(in|out|inout|buffer)\s+(\w+)[ \t\r\f\v]*', 'port_param_type'),
127130
(r'\s*;\s*', None, '#pop'),
128131
(r"\s*:=\s*([\w']+)", 'port_param_default'),
129132
(r'--(.*)\n', 'line_comment'),
133+
(r'\)\s*;\s*--(.*)\n', 'line_comment', '#pop:2'),
134+
(r'\n\s*\)\s*;\s*--(.*)\n', 'port_list_comment', '#pop:2'),
135+
(r'\n\s*', None),
130136
(r'\)\s*;', 'end_port', '#pop:2'),
131137
(r'--#(.*)\n', 'metacomment'),
132138
(r'/\*', 'block_comment', 'block_comment'),
@@ -566,7 +572,8 @@ def parse_vhdl(text):
566572

567573
elif action == 'line_comment':
568574
for i in last_items:
569-
i.param_desc = groups[0]
575+
if not i.param_desc:
576+
i.param_desc = groups[0]
570577

571578
return objects
572579

@@ -774,8 +781,9 @@ def register_array_types_from_sources(self, source_files):
774781
component acomp is
775782
port (
776783
a,b,c : in std_ulogic; -- no default value
777-
f,g,h : inout bit := '1' -- default value '1'
778-
);
784+
f,g,h : inout bit := '1' -- bit ports
785+
); -- port list comment
786+
779787
end component;
780788
781789
end package;

0 commit comments

Comments
 (0)