Commit e915ea6f authored by Tristan Gingold's avatar Tristan Gingold

vhdl_parser.py: minor simplification.

parent a3cb3858
...@@ -47,22 +47,15 @@ class VHDLParser(DepParser): ...@@ -47,22 +47,15 @@ class VHDLParser(DepParser):
def _preprocess(vhdl_file): def _preprocess(vhdl_file):
"""Preprocess the supplied VHDL file instance""" """Preprocess the supplied VHDL file instance"""
def _preprocess_file(file_content, file_name, library):
"""Preprocess the suplied string using the arguments"""
def _remove_comments_and_strings(text):
"""Remove the comments and strings from the VHDL code"""
pattern = re.compile('--.*?$|".?"',
re.DOTALL | re.MULTILINE)
return re.sub(pattern, "", text)
logging.debug(
"preprocess file %s (of length %d) in library %s",
file_name, len(file_content), library)
return _remove_comments_and_strings(file_content)
file_path = vhdl_file.file_path file_path = vhdl_file.file_path
buf = open(file_path, "r").read() buf = open(file_path, "r").read()
return _preprocess_file(file_content=buf, logging.debug(
file_name=file_path, "preprocess file %s (of length %d) in library %s",
library=vhdl_file.library) file_path, len(buf), vhdl_file.library)
# Remove the comments and strings from the VHDL code
pattern = re.compile('--.*?$|".?"', re.DOTALL | re.MULTILINE)
return re.sub(pattern, "", buf)
buf = _preprocess(dep_file) buf = _preprocess(dep_file)
# use packages # use packages
use_pattern = re.compile( use_pattern = re.compile(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment