diff --git a/vsg/line.py b/vsg/line.py index 6349b2ac..b7dcd11a 100644 --- a/vsg/line.py +++ b/vsg/line.py @@ -49,6 +49,7 @@ class line(): self.insideProcess = False self.isProcessBegin = False self.isProcessKeyword = False + self.isProcessLabel = False self.isProcessDeclarative = False self.isEndProcess = False self.insideSensitivityList = False diff --git a/vsg/rules/process/rule_005.py b/vsg/rules/process/rule_005.py index b0f6eb76..008bac5a 100644 --- a/vsg/rules/process/rule_005.py +++ b/vsg/rules/process/rule_005.py @@ -11,16 +11,13 @@ class rule_005(rule.rule): ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '005' + rule.rule.__init__(self, 'process', '005') self.solution = 'Lowercase the "process" keyword.' self.phase = 6 def analyze(self, oFile): for iLineNumber, oLine in enumerate(oFile.lines): - if oLine.isProcessKeyword: - if not re.match('^\s*.*process', oLine.line): + if oLine.isProcessKeyword and not re.match('^\s*.*process', oLine.line): self.add_violation(iLineNumber) def _fix_violations(self, oFile): diff --git a/vsg/rules/process/rule_007.py b/vsg/rules/process/rule_007.py index 74b801be..bf723c45 100644 --- a/vsg/rules/process/rule_007.py +++ b/vsg/rules/process/rule_007.py @@ -1,28 +1,12 @@ -from vsg import rule -from vsg import fix - -import re +from vsg.rules import single_space_after_rule -class rule_007(rule.rule): +class rule_007(single_space_after_rule): ''' Process rule 007 checks for a single space between the "end" and "process" keywords. ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '007' + single_space_after_rule.__init__(self, 'process', '007', 'isEndProcess', 'end') self.solution = 'Ensure there are only one space between the "end" and "process" keywords.' - self.phase = 2 - - def analyze(self, oFile): - for iLineNumber, oLine in enumerate(oFile.lines): - if oLine.isEndProcess: - if not re.match('^\s*\S+\s\S', oLine.line): - self.add_violation(iLineNumber) - - def _fix_violations(self, oFile): - for iLineNumber in self.violations: - fix.enforce_one_space_after_word(self, oFile.lines[iLineNumber], 'end') diff --git a/vsg/rules/process/rule_008.py b/vsg/rules/process/rule_008.py index 649b288b..9a1e8de1 100644 --- a/vsg/rules/process/rule_008.py +++ b/vsg/rules/process/rule_008.py @@ -1,27 +1,12 @@ -from vsg import rule -from vsg import utilities -from vsg import fix -from vsg import check +from vsg.rules import lower_case_rule -class rule_008(rule.rule): +class rule_008(lower_case_rule): ''' Process rule 008 checks the "end" keyword is lowercase. ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '008' + lower_case_rule.__init__(self, 'process', '008', 'isEndProcess', 'end') self.solution = 'Lowercase the "end" keyword.' - self.phase = 6 - - def analyze(self, oFile): - for iLineNumber, oLine in enumerate(oFile.lines): - if oLine.isEndProcess: - check.is_lowercase(self, utilities.get_first_word(oLine), iLineNumber) - - def _fix_violations(self, oFile): - for iLineNumber in self.violations: - fix.lower_case(self, oFile.lines[iLineNumber], 'end') diff --git a/vsg/rules/process/rule_009.py b/vsg/rules/process/rule_009.py index 93911e12..a9987edd 100644 --- a/vsg/rules/process/rule_009.py +++ b/vsg/rules/process/rule_009.py @@ -11,17 +11,14 @@ class rule_009(rule.rule): ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '009' + rule.rule.__init__(self, 'process', '009') self.solution = 'Lowercase the "process" keyword.' self.phase = 6 def analyze(self, oFile): for iLineNumber, oLine in enumerate(oFile.lines): - if oLine.isEndProcess: - if not re.match('^\s*\w+\s+process', oLine.line): - self.add_violation(iLineNumber) + if oLine.isEndProcess and not re.match('^\s*\w+\s+process', oLine.line): + self.add_violation(iLineNumber) def _fix_violations(self, oFile): for iLineNumber in self.violations: diff --git a/vsg/rules/process/rule_010.py b/vsg/rules/process/rule_010.py index 2ced8ef0..6bd4978f 100644 --- a/vsg/rules/process/rule_010.py +++ b/vsg/rules/process/rule_010.py @@ -12,9 +12,7 @@ class rule_010(rule.rule): ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '010' + rule.rule.__init__(self, 'process', '010') self.solution = 'Place "begin" keyword on seperate line.' self.phase = 1 diff --git a/vsg/rules/process/rule_011.py b/vsg/rules/process/rule_011.py index 1a5d4a2c..93d290ac 100644 --- a/vsg/rules/process/rule_011.py +++ b/vsg/rules/process/rule_011.py @@ -8,7 +8,4 @@ class rule_011(line_below_rule): ''' def __init__(self): - line_below_rule.__init__(self) - self.name = 'process' - self.identifier = '011' - self.condition = 'isEndProcess' + line_below_rule.__init__(self, 'process', '011', 'isEndProcess') diff --git a/vsg/rules/process/rule_012.py b/vsg/rules/process/rule_012.py index 3b408f9c..7e8cd803 100644 --- a/vsg/rules/process/rule_012.py +++ b/vsg/rules/process/rule_012.py @@ -10,9 +10,7 @@ class rule_012(rule.rule): ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '012' + rule.rule.__init__(self, 'process', '012') self.solution = 'Add "is" keyword after the closing parenthesis.' self.phase = 1 diff --git a/vsg/rules/process/rule_013.py b/vsg/rules/process/rule_013.py index 63dea1e6..79833261 100644 --- a/vsg/rules/process/rule_013.py +++ b/vsg/rules/process/rule_013.py @@ -11,18 +11,15 @@ class rule_013(rule.rule): ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '013' + rule.rule.__init__(self, 'process', '013') self.solution = 'Lowercase "is" keyword.' self.phase = 6 def analyze(self, oFile): for iLineNumber, oLine in enumerate(oFile.lines): - if oLine.isSensitivityListEnd: - if re.match('^.*\)\s*is', oLine.lineLower): - if not re.match('^.*\)\s*is', oLine.line): - self.add_violation(iLineNumber) + if oLine.isSensitivityListEnd and re.match('^.*\)\s*is', oLine.lineLower): + if not re.match('^.*\)\s*is', oLine.line): + self.add_violation(iLineNumber) def _fix_violations(self, oFile): for iLineNumber in self.violations: diff --git a/vsg/rules/process/rule_014.py b/vsg/rules/process/rule_014.py index 5e16f645..17cb37e5 100644 --- a/vsg/rules/process/rule_014.py +++ b/vsg/rules/process/rule_014.py @@ -11,18 +11,15 @@ class rule_014(rule.rule): ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '014' + rule.rule.__init__(self, 'process', '014') self.solution = 'Ensure only a single space exists between the ) and "is" keyword.' self.phase = 2 def analyze(self, oFile): for iLineNumber, oLine in enumerate(oFile.lines): - if oLine.isSensitivityListEnd: - if re.match('^.*\)\s*is', oLine.lineLower): - if not re.match('^.*\)\sis', oLine.lineLower): - self.add_violation(iLineNumber) + if oLine.isSensitivityListEnd and re.match('^.*\)\s*is', oLine.lineLower): + if not re.match('^.*\)\sis', oLine.lineLower): + self.add_violation(iLineNumber) def _fix_violations(self, oFile): for iLineNumber in self.violations: diff --git a/vsg/rules/process/rule_015.py b/vsg/rules/process/rule_015.py index 087146d3..c3e346f6 100644 --- a/vsg/rules/process/rule_015.py +++ b/vsg/rules/process/rule_015.py @@ -9,9 +9,7 @@ class rule_015(rule.rule): ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '015' + rule.rule.__init__(self, 'process', '015') self.solution = 'Add a space or a comment above the "process" keyword.' self.phase = 3 diff --git a/vsg/rules/process/rule_016.py b/vsg/rules/process/rule_016.py index 7c043c61..5098fef2 100644 --- a/vsg/rules/process/rule_016.py +++ b/vsg/rules/process/rule_016.py @@ -17,5 +17,5 @@ class rule_016(rule.rule): def analyze(self, oFile): for iLineNumber, oLine in enumerate(oFile.lines): - if oLine.isProcessKeyword and not re.match('^\s*\S+\s*:', oLine.line): + if oLine.isProcessKeyword and not oLine.isProcessLabel: self.add_violation(iLineNumber) diff --git a/vsg/rules/process/rule_017.py b/vsg/rules/process/rule_017.py index ce481560..c23aa0f1 100644 --- a/vsg/rules/process/rule_017.py +++ b/vsg/rules/process/rule_017.py @@ -1,5 +1,6 @@ from vsg import rule +from vsg import check from vsg import fix import re @@ -11,19 +12,15 @@ class rule_017(rule.rule): ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '017' + rule.rule.__init__(self, 'process', '017') self.solution = 'Uppercase process label.' self.phase = 6 def analyze(self, oFile): for iLineNumber, oLine in enumerate(oFile.lines): - if oLine.isProcessKeyword: - if re.match('^\s*\S+\s*:', oLine.line): - lLine = oLine.line.split(':') - if not lLine[0] == lLine[0].upper(): - self.add_violation(iLineNumber) + if oLine.isProcessLabel: + lLine = oLine.line.split(':') + check.is_uppercase(self, lLine[0], iLineNumber) def _fix_violations(self, oFile): for iLineNumber in self.violations: diff --git a/vsg/rules/process/rule_019.py b/vsg/rules/process/rule_019.py index 1c7f054c..20f2394e 100644 --- a/vsg/rules/process/rule_019.py +++ b/vsg/rules/process/rule_019.py @@ -12,17 +12,14 @@ class rule_019(rule.rule): ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '019' + rule.rule.__init__(self, 'process', '019') self.solution = 'Uppercase the label.' self.phase = 6 def analyze(self, oFile): for iLineNumber, oLine in enumerate(oFile.lines): - if oLine.isEndProcess: - if re.match('^\s*\w+\s+\w+\s+\w+', oLine.line): - check.is_uppercase(self, oLine.line.split()[2], iLineNumber) + if oLine.isEndProcess and re.match('^\s*\w+\s+\w+\s+\w+', oLine.line): + check.is_uppercase(self, oLine.line.split()[2], iLineNumber) def _fix_violations(self, oFile): for iLineNumber in self.violations: diff --git a/vsg/rules/process/rule_020.py b/vsg/rules/process/rule_020.py index 92f568d5..a8c4877c 100644 --- a/vsg/rules/process/rule_020.py +++ b/vsg/rules/process/rule_020.py @@ -12,9 +12,7 @@ class rule_020(rule.rule): ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '020' + rule.rule.__init__(self, 'process', '020') self.solution = 'Fix indentation of sensitivity list.' self.phase = 5 diff --git a/vsg/rules/process/rule_021.py b/vsg/rules/process/rule_021.py index 7f82be9e..18519907 100644 --- a/vsg/rules/process/rule_021.py +++ b/vsg/rules/process/rule_021.py @@ -9,9 +9,7 @@ class rule_021(rule.rule): ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '021' + rule.rule.__init__(self, 'process', '021') self.solution = 'Remove blank lines between the end of the sensitivity list and before the "begin" keyword.' self.phase = 3 diff --git a/vsg/rules/process/rule_022.py b/vsg/rules/process/rule_022.py index ff1a570d..b389cae1 100644 --- a/vsg/rules/process/rule_022.py +++ b/vsg/rules/process/rule_022.py @@ -8,7 +8,4 @@ class rule_022(line_below_rule): ''' def __init__(self): - line_below_rule.__init__(self) - self.name = 'process' - self.identifier = '022' - self.condition = 'isProcessBegin' + line_below_rule.__init__(self, 'process', '022', 'isProcessBegin') diff --git a/vsg/rules/process/rule_023.py b/vsg/rules/process/rule_023.py index 55ff2110..c7726b0a 100644 --- a/vsg/rules/process/rule_023.py +++ b/vsg/rules/process/rule_023.py @@ -8,7 +8,4 @@ class rule_023(line_above_rule): ''' def __init__(self): - line_above_rule.__init__(self) - self.name = 'process' - self.identifier = '023' - self.condition = 'isEndProcess' + line_above_rule.__init__(self, 'process', '023', 'isEndProcess') diff --git a/vsg/rules/process/rule_024.py b/vsg/rules/process/rule_024.py index d7cfdfa8..45fa408d 100644 --- a/vsg/rules/process/rule_024.py +++ b/vsg/rules/process/rule_024.py @@ -1,29 +1,12 @@ -from vsg import rule -from vsg import fix - -import re +from vsg.rules import single_space_before_character_rule -class rule_024(rule.rule): +class rule_024(single_space_before_character_rule): ''' Process rule 024 checks for a single space after the process label and the :. ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '024' + single_space_before_character_rule.__init__(self, 'process', '024', 'isProcessLabel', ':') self.solution = 'Ensure a single space exists between process label and :.' - self.phase = 2 - - def analyze(self, oFile): - for iLineNumber, oLine in enumerate(oFile.lines): - if oLine.isProcessKeyword: - if re.match('^\s*\S+\s*:', oLine.line): - if not re.match('^\s*\S+\s:', oLine.line): - self.add_violation(iLineNumber) - - def _fix_violations(self, oFile): - for iLineNumber in self.violations: - fix.enforce_one_space_before_word(self, oFile.lines[iLineNumber], ':') diff --git a/vsg/rules/process/rule_025.py b/vsg/rules/process/rule_025.py index 85d30e38..92b7812f 100644 --- a/vsg/rules/process/rule_025.py +++ b/vsg/rules/process/rule_025.py @@ -1,29 +1,12 @@ -from vsg import rule -from vsg import fix - -import re +from vsg.rules import single_space_after_character_rule -class rule_025(rule.rule): +class rule_025(single_space_after_character_rule): ''' Process rule 025 checks for a single space after the : and before the "process" keyword. ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '025' + single_space_after_character_rule.__init__(self, 'process', '025', 'isProcessLabel', ':') self.solution = 'Ensure a single space exists between the : and the "process" keyword.' - self.phase = 2 - - def analyze(self, oFile): - for iLineNumber, oLine in enumerate(oFile.lines): - if oLine.isProcessKeyword: - if re.match('^\s*\S+\s*:\s*\S+', oLine.line): - if not re.match('^\s*\S+\s*:\s\S', oLine.line): - self.add_violation(iLineNumber) - - def _fix_violations(self, oFile): - for iLineNumber in self.violations: - fix.enforce_one_space_after_word(self, oFile.lines[iLineNumber], ':') diff --git a/vsg/rules/process/rule_026.py b/vsg/rules/process/rule_026.py index 796378af..193b37e7 100644 --- a/vsg/rules/process/rule_026.py +++ b/vsg/rules/process/rule_026.py @@ -9,9 +9,7 @@ class rule_026(rule.rule): ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '026' + rule.rule.__init__(self, 'process', '026') self.solution = 'Ensure a single blank line between the end of the sensitivity list and the next non-blank line.' self.phase = 3 diff --git a/vsg/rules/process/rule_028.py b/vsg/rules/process/rule_028.py index fab48bbc..6b0d1c36 100644 --- a/vsg/rules/process/rule_028.py +++ b/vsg/rules/process/rule_028.py @@ -12,9 +12,7 @@ class rule_028(rule.rule): ''' def __init__(self): - rule.rule.__init__(self) - self.name = 'process' - self.identifier = '028' + rule.rule.__init__(self, 'process', '028') self.solution = 'Align closing parenthesis with opening parenthesis.' self.phase = 5 diff --git a/vsg/tests/line/test_line.py b/vsg/tests/line/test_line.py index 99d350bb..85bd1503 100644 --- a/vsg/tests/line/test_line.py +++ b/vsg/tests/line/test_line.py @@ -188,6 +188,12 @@ class testLineMethods(unittest.TestCase): oLine.isProcessKeyword = True self.assertEqual(oLine.isProcessKeyword, True) + def test_isProcessLabel_attribute(self): + oLine = line.line('contents of Line') + self.assertEqual(oLine.isProcessLabel, False) + oLine.isProcessLabel = True + self.assertEqual(oLine.isProcessLabel, True) + def test_isEndProcess_attribute(self): oLine = line.line('contents of Line') self.assertEqual(oLine.isEndProcess, False) diff --git a/vsg/tests/vhdlFile/test_vhdlFile.py b/vsg/tests/vhdlFile/test_vhdlFile.py index 46eace16..62d74872 100644 --- a/vsg/tests/vhdlFile/test_vhdlFile.py +++ b/vsg/tests/vhdlFile/test_vhdlFile.py @@ -334,6 +334,16 @@ class testVhdlFileMethods(unittest.TestCase): # Compare self.assertEqual(lActual, lExpected) + def test_isProcessLabel_assignment(self): + lExpected = [46,63,68,75,81,88,97] + # Generic actual list + lActual = [] + for iIndex, oLine in enumerate(oFileProcess.lines): + if oLine.isProcessLabel: + lActual.append(iIndex) + # Compare + self.assertEqual(lActual, lExpected) + def test_isEndProcess_assignment(self): lExpected = [9,15,22,30,36,42,48,53,60,65,72,79,86,94,103] # Generic actual list diff --git a/vsg/vhdlFile/classify/process.py b/vsg/vhdlFile/classify/process.py index b8f36a2b..b75a8e74 100644 --- a/vsg/vhdlFile/classify/process.py +++ b/vsg/vhdlFile/classify/process.py @@ -2,10 +2,15 @@ import re def process(dVars, oLine): - if re.match('^\s*process', oLine.lineLower) or re.match('^\s*\S+\s*:\s*process', oLine.lineLower) and not oLine.isComment: + if re.match('^\s*process', oLine.lineLower): oLine.isProcessKeyword = True oLine.insideProcess = True oLine.indentLevel = dVars['iCurrentIndentLevel'] + if re.match('^\s*\S+\s*:\s*process', oLine.lineLower): + oLine.isProcessKeyword = True + oLine.insideProcess = True + oLine.indentLevel = dVars['iCurrentIndentLevel'] + oLine.isProcessLabel = True if oLine.insideProcess: # Check sensitivity list if '(' in oLine.line and not oLine.insideSensitivityList and not dVars['fFoundProcessBegin'] and not dVars['SensitivityListFound']: