Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Multiline comment containing semicolon : over port declaration breaks vhdl_parser.parse() #1069

Closed
SzymonHitachi opened this issue Oct 22, 2024 · 3 comments

Comments

@SzymonHitachi
Copy link

When parsing a comment in format

/* 
 COMMENT
 */
a : in std_logic;

E.g.
if COMMENT contains : e.g. if it's an url:

/* 
 https://support.xilinx.com
 */
a : in std_logic;

parser errors with

  File "vunit\vunit\source_file.py", line 221, in __init__
    design_file = vhdl_parser.parse(self.name)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "vunit\vunit\vhdl_parser.py", line 36, in parse
    return cached(
           ^^^^^^^
  File "vunit\vunit\cached.py", line 45, in cached
    result = function(content)
             ^^^^^^^^^^^^^^^^^
  File "vunit\vunit\vhdl_parser.py", line 77, in parse
    entities=list(VHDLEntity.find(code)),
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "vunit\vunit\vhdl_parser.py", line 363, in find
    yield VHDLEntity.parse(sub_code[: match.end()])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "vunit\vunit\vhdl_parser.py", line 386, in parse
    ports = cls._find_port_clause(code)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "vunit\vunit\vhdl_parser.py", line 450, in _find_port_clause
    return cls._parse_port_clause(code[match.start() : match.end() + closing_pos + match_semicolon.end()])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "vunit\vunit\vhdl_parser.py", line 548, in _parse_port_clause
    port_list.append(VHDLInterfaceElement.parse(interface_element, is_signal=True))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "vunit\vunit\vhdl_parser.py", line 667, in parse
    subtype_indication = VHDLSubtypeIndication.parse(interface_element_string.split(":")[1].strip())
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "vunit\vunit\vhdl_parser.py", line 612, in parse
    type_mark = subtype_indication_declaration.group("type_mark")
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'group'

probably due to interface_element_string.split(":") which probably shouldn't be done in multiline comment block

@SzymonHitachi SzymonHitachi changed the title [Bug] Multiline comment containing semicolon over port declaration breakes vhdl_parser.parse() [Bug] Multiline comment containing semicolon : over port declaration breaks vhdl_parser.parse() Oct 22, 2024
@LarsAsplund
Copy link
Collaborator

VUnit doesn't detect block comments. The reasoning for limiting its capabilities is the same as in #1068

@SzymonHitachi
Copy link
Author

Make sense. Would be a good idea to note it somewhere that : in multiline comments is not supported by VUnit, since I agree that fixing this might be problematic.

@LarsAsplund
Copy link
Collaborator

See #1080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants