The remove_comments(code) function is overly simplistic. It matches any two adjacent - characters until the end of the line. '-' is also used as a "don't care" value for std_logic. If there is an std_logic_vector literal where there are two don't care values in a row (e.g. '----'), it is parsed as a comment and the rest of the line is removed, causing the parse to fail.
|
VHDL_REMOVE_COMMENT_RE = re.compile(r'--[^\n]*') |
|
|
|
|
|
def _comment_repl(match): |
|
""" |
|
Replace comment with equal amount of whitespace to make |
|
lexical position unaffected |
|
""" |
|
text = match.group(0) |
|
return " " * len(text) |
|
|
|
|
|
def remove_comments(code): |
|
""" |
|
Return the code with comments removed |
|
""" |
|
return VHDL_REMOVE_COMMENT_RE.sub(_comment_repl, code) |
The
remove_comments(code)function is overly simplistic. It matches any two adjacent-characters until the end of the line.'-'is also used as a "don't care" value forstd_logic. If there is anstd_logic_vectorliteral where there are two don't care values in a row (e.g.'----'), it is parsed as a comment and the rest of the line is removed, causing the parse to fail.vunit/vunit/vhdl_parser.py
Lines 991 to 1007 in 12be973