Adding rule for closing parenthesis in generics.
This commit is contained in:
parent
6169387ec1
commit
34e150eb5a
|
|
@ -761,3 +761,37 @@ class rule_032(entity_rule):
|
|||
if re.match('\s*entity', sLine.lower()):
|
||||
fEntityFound = True
|
||||
self.violations = lFailureLines
|
||||
|
||||
|
||||
class rule_033(entity_rule):
|
||||
'''Entity rule 033 checks the indentation of closing parenthesis for generic maps.'''
|
||||
|
||||
def __init__(self):
|
||||
entity_rule.__init__(self)
|
||||
self.identifier = '033'
|
||||
self.description = 'Closing parenthesis must be on a line by itself and above the "port" keyword.'
|
||||
|
||||
def analyze(self, lines):
|
||||
lFailureLines = []
|
||||
fEntityFound = False
|
||||
fGenericMapFound = False
|
||||
fClosingParenFound = False
|
||||
for iLineNumber, sLine in enumerate(lines):
|
||||
if fEntityFound:
|
||||
if fGenericMapFound:
|
||||
if re.match('^\s*\)', sLine):
|
||||
if not re.match('^\s\s\)', sLine):
|
||||
lFailureLines.append(iLineNumber + 1)
|
||||
else:
|
||||
fClosingParenFound = True
|
||||
if re.match('^\s*port\s', sLine.lower()):
|
||||
fEntityFound = False
|
||||
fGenericMapFound = False
|
||||
if not fClosingParenFound:
|
||||
lFailureLines.append(iLineNumber + 1)
|
||||
fClosingParenFound = False
|
||||
if re.match('^\s*generic', sLine.lower()):
|
||||
fGenericMapFound = True
|
||||
if re.match('\s*entity', sLine.lower()):
|
||||
fEntityFound = True
|
||||
self.violations = lFailureLines
|
||||
|
|
|
|||
|
|
@ -89,3 +89,15 @@ entity ENTITY1 is
|
|||
IO_PORT3 : inout std_logic
|
||||
);
|
||||
end ENTITY1
|
||||
|
||||
|
||||
entity ENTITY1 is
|
||||
generic (
|
||||
G_GENERIC1 : std_logic := '0';
|
||||
G_GENERIC2 : std_logic := '1');
|
||||
port (
|
||||
I_PORT1 : in std_logic;
|
||||
O_PORT2 : out std_logic;
|
||||
IO_PORT3 : inout std_logic
|
||||
);
|
||||
end ENTITY1
|
||||
|
|
|
|||
|
|
@ -435,6 +435,18 @@ class testRuleEntityMethods(unittest.TestCase):
|
|||
oRule.analyze(lLines)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
def test_rule_033_exists(self):
|
||||
oRule = rule_entity.rule_033()
|
||||
self.assertTrue(oRule)
|
||||
self.assertEqual(oRule.name, 'entity')
|
||||
self.assertEqual(oRule.identifier, '033')
|
||||
|
||||
def test_rule_033(self):
|
||||
oRule = rule_entity.rule_033()
|
||||
|
||||
dExpected = [98]
|
||||
oRule.analyze(lLines)
|
||||
self.assertEqual(oRule.violations, dExpected)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in New Issue