diff --git a/vunit/com/codec_vhdl_package.py b/vunit/com/codec_vhdl_package.py index e543c62d2..74d6b312f 100644 --- a/vunit/com/codec_vhdl_package.py +++ b/vunit/com/codec_vhdl_package.py @@ -18,10 +18,9 @@ class CodecVHDLPackage(VHDLPackage): """Class derived from VHDLPackage to provide codec generator functionality for the data types definied in the package.""" - def __init__(self, identifier, constant_declarations, # pylint: disable=too-many-arguments + def __init__(self, identifier, enumeration_types, record_types, array_types): super(CodecVHDLPackage, self).__init__(identifier, - constant_declarations, enumeration_types, record_types, array_types) @@ -35,12 +34,11 @@ def parse(cls, code): """ # Extract identifier identifier = cls._package_start_re.match(code).group('id') - constant_declarations = cls._find_constant_declarations(code) enumeration_types = [e for e in CodecVHDLEnumerationType.find(code)] record_types = [r for r in CodecVHDLRecordType.find(code)] array_types = [a for a in CodecVHDLArrayType.find(code)] - return cls(identifier, constant_declarations, enumeration_types, record_types, array_types) + return cls(identifier, enumeration_types, record_types, array_types) @classmethod def find_named_package(cls, code, name): diff --git a/vunit/test/unit/test_vhdl_parser.py b/vunit/test/unit/test_vhdl_parser.py index 18ac2432b..ae0420f0b 100644 --- a/vunit/test/unit/test_vhdl_parser.py +++ b/vunit/test/unit/test_vhdl_parser.py @@ -222,23 +222,6 @@ def test_parsing_simple_package(self): """) self.assertEqual(package.identifier, "simple") - def test_parsing_package_with_constants(self): - package = self.parse_single_package("""\ -package name is - constant foo : integer := 15 - 1 * 2; - constant bar : boolean := false or true; -end package; -""") - self.assertEqual(package.identifier, "name") - constants = package.constant_declarations - self.assertEqual(len(constants), 2) - self.assertEqual(constants[0].identifier, "foo") - self.assertEqual(constants[0].expression, "15 - 1 * 2") - self.assertEqual(constants[0].subtype_indication.type_mark, "integer") - self.assertEqual(constants[1].identifier, "bar") - self.assertEqual(constants[1].expression, "false or true") - self.assertEqual(constants[1].subtype_indication.type_mark, "boolean") - def test_parsing_context(self): context = self.parse_single_context("""\ context foo is diff --git a/vunit/vhdl_parser.py b/vunit/vhdl_parser.py index cf834e5fc..2d9939cc6 100644 --- a/vunit/vhdl_parser.py +++ b/vunit/vhdl_parser.py @@ -207,10 +207,9 @@ class VHDLPackage(object): """ Representation of a VHDL package """ - def __init__(self, identifier, constant_declarations, # pylint: disable=too-many-arguments + def __init__(self, identifier, enumeration_types, record_types, array_types): self.identifier = identifier - self.constant_declarations = constant_declarations self.enumeration_types = enumeration_types self.record_types = record_types self.array_types = array_types @@ -251,34 +250,11 @@ def parse(cls, code): """ # Extract identifier identifier = cls._package_start_re.match(code).group('id') - constant_declarations = cls._find_constant_declarations(code) enumeration_types = [e for e in VHDLEnumerationType.find(code)] record_types = [r for r in VHDLRecordType.find(code)] array_types = [a for a in VHDLArrayType.find(code)] - return cls(identifier, constant_declarations, enumeration_types, record_types, array_types) - - @classmethod - def _find_constant_declarations(cls, code): - """ - Append all constant declarations found within the code to constant_declarations list - """ - re_flags = re.MULTILINE | re.IGNORECASE | re.VERBOSE - constant_start = re.compile(r""" - ^ # Beginning of line - [\s]* # Potential whitespaces - constant # constant keyword - \s+ # At least one whitespace - (?P[a-zA-Z][\w]*) # An identifier - [\s]* # Potential whitespaces - : # Colon - """, re_flags) - - constant_declarations = [] - for constant in constant_start.finditer(code): - sub_code = code[constant.start():].strip().splitlines()[0].strip() - constant_declarations.append(VHDLConstantDeclaration.parse(sub_code)) - return constant_declarations + return cls(identifier, enumeration_types, record_types, array_types) class VHDLEntity(object):