Closed michael-etzkorn closed 2 years ago
If you apply this change:
diff --git a/hdlparse/vhdl_parser.py b/hdlparse/vhdl_parser.py
index af9789d..05e424c 100644
--- a/hdlparse/vhdl_parser.py
+++ b/hdlparse/vhdl_parser.py
@@ -94,6 +94,7 @@ vhdl_tokens = {
'architecture': [
(r'end\s+\w+\s*;', 'end_arch', '#pop'),
(r'/\*', 'block_comment', 'block_comment'),
+ (r'type\s+(\w+)\s*is', 'type', 'type_decl'),
(r'--.*\n', None),
],
'generic_list': [
you get:
In [1]: import hdlparse.vhdl_parser as vhdl
In [2]: vhdl_ex = vhdl.VhdlExtractor()
In [3]: vhdl_objs = vhdl_ex.extract_objects("captouch.vhd")
In [4]: vhdl_objs
Out[4]:
[VhdlEntity('captouch'),
VhdlType('ctrl_state_t', 'enum_type'),
VhdlType('ctrl_t', 'record_type'),
VhdlType('out_filter_t', 'array_type')]
It's strange that you got one type at all, because the type parser was declared at the root and package level. I added the same line at the architecture
level .
Hi Andres, I've pushed your fix for type parsing to this branch. Hopefully this weekend I can reintroduce vvvverre's style changes so the style is consistent between the two parsers.
I'm also in favor of parsing the logic
type for systemverilog so I'll introduce a PR for that soon (even if this python parser isn't intended to be a full blown SV parser. It'll be nice to have some of the basics.)
I'm not sure if that should be included in another file ? (another parser for SV). But other than that this PR LGTM.
I'll approve, waiting for another reviewer before merge.
@umarcor this PR looks ready to be merged. Any objections?
@michael-etzkorn when you're ready for a new review, please use the button on the right navigation bar to retrigger a review.
This mirrors the pull request here https://github.com/kevinpt/hdlparse/pull/14 using the master branch of https://github.com/andresmanelli/hdlparse . I've briefly tested this with capstone.vhd from https://github.com/stnolting/captouch . It only seems to pick up the
out_filter_t
type, but at least it does some sort of parsing of the entity.Previous behavior:
vhdl_objs
would return as an empty list.I didn't go through and reapply @andresmanelli's changes. Instead, I just patched the branch with his vhdl_parser.py so @vvvverre's format changes would have to be redone.