Skip to content

Commit 2ac87da

Browse files
committed
Parsing SV for virtual classes (WIP)
1 parent 5a839ec commit 2ac87da

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

hdl_checker/parsers/verilog_parser.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
"|".join(
5656
[
5757
r"(?P<package>\b{0})\s*::\s*(?:{0}|\*)".format(_VERILOG_IDENTIFIER),
58+
r"\bvirtual\s+class\s+(?P<class>\b{0})".format(
59+
_VERILOG_IDENTIFIER
60+
),
5861
r"(?<=`include\b)\s*\"(?P<include>.*?)\"",
5962
_COMMENT,
6063
]
@@ -115,17 +118,29 @@ def _getDependencies(self): # type: () -> Iterable[BaseDependencySpec]
115118
if self.filetype is FileType.verilog:
116119
continue
117120

118-
import_name = match.groupdict().get("package", None)
121+
name = match.groupdict().get("package", None)
119122

120123
# package 'std' seems to be built-in. Need to have a look a this
121124
# if include_name is not None and include_name != 'std':
122-
if import_name not in (None, "std"):
125+
if name not in (None, "std"):
123126
line_number = text[: match.end()].count("\n")
124127
column_number = len(text[: match.start()].split("\n")[-1])
125128

126129
yield RequiredDesignUnit(
127130
owner=self.filename,
128-
name=VerilogIdentifier(import_name), # type: ignore
131+
name=VerilogIdentifier(name), # type: ignore
132+
locations=(Location(line_number, column_number),),
133+
)
134+
135+
name = match.groupdict().get("class", None)
136+
137+
if name is not None:
138+
line_number = text[: match.end()].count("\n")
139+
column_number = len(text[: match.start()].split("\n")[-1])
140+
141+
yield RequiredDesignUnit(
142+
owner=self.filename,
143+
name=VerilogIdentifier(name),
129144
locations=(Location(line_number, column_number),),
130145
)
131146

0 commit comments

Comments
 (0)