Updates for issue #393:

Refactoring of library and base rules:

  1)  Most library rules refactored to use new base item rules
  2)  Base item rules refactored to use the region method on vhdlFile
  3)  Tests updated
  4)  Documentation updated
This commit is contained in:
Jeremiah Leary 2020-07-26 12:54:43 -05:00
parent 69fc6fdef6
commit abe3cb3418
32 changed files with 410 additions and 119 deletions

View File

@ -45,6 +45,7 @@ context_003
###########
This rule checks for a blank line above the **context** keyword.
Comment are allowed.
**Violation**

View File

@ -129,7 +129,7 @@ This rule checks for excessive spaces after the **use** keyword.
library_007
###########
This rule checks for blank lines above the **use** keyword.
This rule removes blank lines above the **use** keyword.
**Violation**

View File

@ -65,6 +65,18 @@ class comment(item):
item.__init__(self, sString)
class logical_name(item):
def __init__(self, sString):
item.__init__(self, sString)
class selected_name(item):
def __init__(self, sString):
item.__init__(self, sString)
###############################################################################
# Context objects
###############################################################################
@ -150,10 +162,10 @@ class library_keyword(keyword):
def __init__(self, sString):
keyword.__init__(self, sString)
class library_identifier(identifier):
class library_logical_name(logical_name):
def __init__(self, sString):
identifier.__init__(self, sString)
logical_name.__init__(self, sString)
class library_comma(comma):
@ -175,10 +187,10 @@ class use_keyword(keyword):
def __init__(self, sString):
keyword.__init__(self, sString)
class use_identifier(identifier):
class use_selected_name(selected_name):
def __init__(self, sString):
identifier.__init__(self, sString)
selected_name.__init__(self, sString)
class use_semicolon(semicolon):

View File

@ -135,6 +135,8 @@ class rule_list():
'''
for phase in range(1, int(iFixPhase) + 1):
if phase in lSkipPhase:
if phase == 1:
self.oVhdlFile.set_indent_levels()
continue
for subphase in range(1, 4):

View File

@ -9,6 +9,6 @@ class rule_002(space_between_items_rule):
'''
def __init__(self):
space_between_items_rule.__init__(self, 'context', '002', parser.context_keyword, parser.context_identifier, 'context keyword')
space_between_items_rule.__init__(self, 'context', '002', parser.context_keyword, parser.context_identifier)
self.regionBegin = parser.context_keyword
self.regionEnd = parser.context_semicolon

View File

@ -10,3 +10,5 @@ class rule_003(insert_blank_line_above_line_containing_item_rule):
def __init__(self):
insert_blank_line_above_line_containing_item_rule.__init__(self, 'context', '003', parser.context_keyword, True)
self.regionBegin = parser.context_keyword
self.regionEnd = parser.context_semicolon

View File

@ -10,6 +10,6 @@ class rule_017(space_between_items_rule):
'''
def __init__(self):
space_between_items_rule.__init__(self, 'context', '017', parser.context_identifier, parser.context_is_keyword, 'context identifier')
space_between_items_rule.__init__(self, 'context', '017', parser.context_identifier, parser.context_is_keyword)
self.regionBegin = parser.context_keyword
self.regionEnd = parser.context_semicolon

View File

@ -10,6 +10,6 @@ class rule_018(space_between_items_rule):
'''
def __init__(self):
space_between_items_rule.__init__(self, 'context', '018', parser.context_end_keyword, parser.context_end_context_keyword, 'end keyword')
space_between_items_rule.__init__(self, 'context', '018', parser.context_end_keyword, parser.context_end_context_keyword)
self.regionBegin = parser.context_keyword
self.regionEnd = parser.context_semicolon

View File

@ -10,6 +10,6 @@ class rule_019(space_between_items_rule):
'''
def __init__(self):
space_between_items_rule.__init__(self, 'context', '019', parser.context_end_context_keyword, parser.context_end_identifier, 'end keyword')
space_between_items_rule.__init__(self, 'context', '019', parser.context_end_context_keyword, parser.context_end_identifier)
self.regionBegin = parser.context_keyword
self.regionEnd = parser.context_semicolon

View File

@ -11,3 +11,5 @@ class rule_024(insert_blank_line_above_line_containing_item_rule):
def __init__(self):
insert_blank_line_above_line_containing_item_rule.__init__(self, 'context', '024', parser.context_end_keyword, False)
self.regionBegin = parser.context_keyword
self.regionEnd = parser.context_semicolon

View File

@ -11,3 +11,5 @@ class rule_027(remove_blank_lines_above_item_rule):
def __init__(self):
remove_blank_lines_above_item_rule.__init__(self, 'context', '027', parser.context_end_keyword)
self.regionBegin = parser.context_keyword
self.regionEnd = parser.context_semicolon

View File

@ -9,6 +9,6 @@ class rule_002(space_between_items_rule):
'''
def __init__(self):
space_between_items_rule.__init__(self, 'context_ref', '002', parser.context_reference_keyword, parser.context_reference_identifier, 'context keyword')
space_between_items_rule.__init__(self, 'context_ref', '002', parser.context_reference_keyword, parser.context_reference_identifier)
self.regionBegin = parser.context_reference_keyword
self.regionEnd = parser.context_reference_semicolon

View File

@ -24,7 +24,7 @@ class indent_item_rule(rule.rule):
def __init__(self, name, identifier, trigger):
rule.rule.__init__(self, name=name, identifier=identifier)
self.solution = 'Indent.'
self.phase = 3
self.phase = 4
self.trigger = trigger
def analyze(self, oFile):
@ -32,6 +32,8 @@ class indent_item_rule(rule.rule):
lRegions = oFile.get_lines_starting_with_item_or_whitespace_and_then_item(self.trigger)
for dRegion in lRegions:
for oLine in dRegion['lines'][::-1]:
if self._is_vsg_off(oLine):
continue
if oLine.get_indent_level() is None:
continue
if oLine.get_indent_level() == 0 and isinstance(oLine.get_object(0), parser.whitespace):

View File

@ -28,18 +28,20 @@ class insert_blank_line_above_line_containing_item_rule(rule.rule):
self.trigger = trigger
self.allowComment = allowComment
self.configuration.append('allowComment')
self.regionBegin = None
self.regionEnd = None
def analyze(self, oFile):
self._print_debug_message('Analyzing rule: ' + self.name + '_' + self.identifier)
lContexts = oFile.get_context_declarations()
for dContext in lContexts:
oPreviousLine = oFile.lines[dContext['metadata']['iStartLineNumber'] - 1]
for iLine, oLine in enumerate(dContext['lines']):
lRegions = oFile.get_region_bounded_by_items(self.regionBegin, self.regionEnd)
for dRegions in lRegions:
oPreviousLine = oFile.lines[dRegions['metadata']['iStartLineNumber'] - 1]
for iLine, oLine in enumerate(dRegions['lines']):
lObjects = oLine.get_objects()
for oObject in lObjects:
if isinstance(oObject, self.trigger) and not oPreviousLine.is_blank():
if not oPreviousLine.is_comment() or not self.allowComment:
self.add_violation(utils.create_violation_dict(dContext['metadata']['iStartLineNumber'] + iLine))
self.add_violation(utils.create_violation_dict(dRegions['metadata']['iStartLineNumber'] + iLine))
oPreviousLine = oLine
def _fix_violations(self, oFile):

View File

@ -1,11 +1,11 @@
from vsg.rules import indent_rule
from vsg import parser
from vsg.rules import indent_item_rule
class rule_001(indent_rule):
class rule_001(indent_item_rule):
'''
Library rule 001 checks for spaces at the beginning of the line.
Checks for indent off the library keyword.
'''
def __init__(self):
indent_rule.__init__(self, 'library', '001', 'isLibrary')
indent_item_rule.__init__(self, 'library', '001', parser.library_keyword)

View File

@ -1,12 +1,14 @@
from vsg.rules import single_space_after_rule
from vsg import parser
from vsg.rules import space_between_items_rule
class rule_002(single_space_after_rule):
'''
Library rule 002 checks for a single space after the library keyword.
class rule_002(space_between_items_rule):
'''
Checks for a single space between the library keyword and the library logical name
'''
def __init__(self):
single_space_after_rule.__init__(self, 'library', '002', 'isLibrary', 'library')
self.solution = 'Remove extra spaces after "library" keyword.'
space_between_items_rule.__init__(self, 'library', '002', parser.library_keyword, parser.library_logical_name)
self.regionBegin = parser.library_keyword
self.regionEnd = parser.library_semicolon

View File

@ -1,11 +1,14 @@
from vsg.rules import line_above_rule
from vsg import parser
from vsg.rules import insert_blank_line_above_line_containing_item_rule
class rule_003(line_above_rule):
class rule_003(insert_blank_line_above_line_containing_item_rule):
'''
Library rule 003 checks for a blank line above the library keyword.
Checks for a blank line above the "library" keyword.
'''
def __init__(self):
line_above_rule.__init__(self, 'library', '003', 'isLibrary')
insert_blank_line_above_line_containing_item_rule.__init__(self, 'library', '003', parser.library_keyword)
self.regionBegin = parser.library_keyword
self.regionEnd = parser.library_semicolon

View File

@ -1,16 +1,13 @@
from vsg.rules import case_rule
from vsg import utils
from vsg import parser
from vsg.rules import case_item_rule
class rule_004(case_rule):
class rule_004(case_item_rule):
'''
Library rule 004 checks the "library" keyword has proper case.
Checks the "library" keyword has proper case.
'''
def __init__(self):
case_rule.__init__(self, 'library', '004', 'isLibrary')
self.solution = 'Change "library" keyword to '
def _extract(self, oLine):
return utils.extract_words(oLine, ['library'])
case_item_rule.__init__(self, 'library', '004', parser.library_keyword)
self.regionBegin = parser.library_keyword
self.regionEnd = parser.library_semicolon

View File

@ -1,16 +1,13 @@
from vsg.rules import case_rule
from vsg import utils
from vsg import parser
from vsg.rules import case_item_rule
class rule_005(case_rule):
class rule_005(case_item_rule):
'''
Library rule 005 checks the "use" keyword has proper case.
Checks the "use" keyword has proper case.
'''
def __init__(self):
case_rule.__init__(self, 'library', '005', 'isLibraryUse')
self.solution = 'Change "use" keyword to '
def _extract(self, oLine):
return utils.extract_words(oLine, ['use'])
case_item_rule.__init__(self, 'library', '005', parser.use_keyword)
self.regionBegin = parser.use_keyword
self.regionEnd = parser.use_semicolon

View File

@ -1,13 +1,14 @@
from vsg import parser
from vsg.rules import space_between_items_rule
from vsg.rules import single_space_after_rule
class rule_006(single_space_after_rule):
'''
Library rule 006 checks for a single space after the use keyword.
class rule_006(space_between_items_rule):
'''
Checks for a single space between the use keyword and the use logical name
'''
def __init__(self):
single_space_after_rule.__init__(self, 'library', '006', 'isLibraryUse', 'use')
self.solution = 'Remove extra spaces after "use" keyword.'
space_between_items_rule.__init__(self, 'library', '006', parser.use_keyword, parser.use_selected_name)
self.regionBegin = parser.use_keyword
self.regionEnd = parser.use_semicolon

View File

@ -1,11 +1,11 @@
from vsg.rules import indent_rule
from vsg import parser
from vsg.rules import indent_item_rule
class rule_008(indent_rule):
class rule_008(indent_item_rule):
'''
Library rule 008 checks indentation of the use keyword.
Checks for indent off the use keyword.
'''
def __init__(self):
indent_rule.__init__(self, 'library', '008', 'isLibraryUse')
indent_item_rule.__init__(self, 'library', '008', parser.use_keyword)

View File

@ -36,13 +36,12 @@ class space_between_items_rule(rule.rule):
Instructions on how to fix the violation.
'''
def __init__(self, name, identifier, left, right, word):
def __init__(self, name, identifier, left, right):
rule.rule.__init__(self, name=name, identifier=identifier)
self.phase = 2
self.solution = None
self.spaces = 1
self.configuration.append('spaces')
self.sWord = word
self.left = left
self.right = right
self.regionBegin = None

View File

@ -0,0 +1,65 @@
context c1 is
library ieee;
end context c1;
-- try multiline
context c1 is
library ieee;
end context c1;
context c1 is
library ieee;
end context c1;
context c1 is
library ieee;
end context c1;
context c1 is
library ieee;
end context c1;
-- Try single line
context c1 is
library ieee; use ieee.std_logic_1164;
end context c1;
context c1 is
library ieee; use ieee.std_logic_1164;
end context c1;
context c1 is
library ieee; use ieee.std_logic_1164;
end context c1;
-- Check comments
context c1 is -- comment 1
-- comment 2
-- comment 3
library ieee; -- comment 4
end context c1; -- comment 5
-- comment 6
-- comment 7
-- comment 8

View File

@ -0,0 +1,45 @@
import shutil
import sys
import os
import unittest
from unittest import mock
from vsg import __main__
from vsg.tests import utils
sFileName = 'context_classification_test_input.vhd'
sFixedFileName = 'context_classification_test_input.fixed.vhd'
sFile = os.path.join(os.path.dirname(__file__), sFileName)
sFixedFile = os.path.join(os.path.dirname(__file__), sFixedFileName)
class test_context_using_main(unittest.TestCase):
def setUp(self):
if os.path.isfile(sFileName):
os.remove(sFileName)
shutil.copyfile(sFile, sFileName)
def tearDown(self):
os.remove(sFileName)
@mock.patch('sys.stdout')
def test_classification_file(self, mock_stdout):
self.maxDiff = None
try:
sys.argv = ['vsg', '-f', sFileName, '--fix']
__main__.main()
except SystemExit as e:
self.assertEqual(e.code, 0)
lActual = []
utils.read_file(sFileName, lActual)
lExpected = []
utils.read_file(sFixedFile, lExpected)
self.assertEqual(lExpected, lActual)

View File

@ -0,0 +1,66 @@
context c1 is
library ieee;
context cr1;
end context c1;
-- try multiline
context c1 is
library ieee;
context cr1,cr2;
end context c1;
context c1 is
library ieee;
end context c1;
context c1 is
context cr1,cr2;
library ieee;
end context c1;
context c1 is
library ieee;
end context c1;
-- Try single line
context c1 is
library ieee; use ieee.std_logic_1164;
context cr1,cr2;
end context c1;
-- Check comments
context c1 is -- comment 1
-- comment 2
-- comment 3
library ieee; -- comment 4
end context c1; -- comment 5
-- comment 6
-- comment 7
-- comment 8
library ieee;
context
cr1
,
cr2
;

View File

@ -0,0 +1,46 @@
import shutil
import sys
import os
import unittest
from unittest import mock
from vsg import __main__
from vsg.tests import utils
sFileName = 'context_reference_classification_test_input.vhd'
sFixedFileName = 'context_reference_classification_test_input.fixed.vhd'
sFile = os.path.join(os.path.dirname(__file__), sFileName)
sFixedFile = os.path.join(os.path.dirname(__file__), sFixedFileName)
class test_context_reference_using_main(unittest.TestCase):
def setUp(self):
if os.path.isfile(sFileName):
os.remove(sFileName)
shutil.copyfile(sFile, sFileName)
def tearDown(self):
os.remove(sFileName)
@mock.patch('sys.stdout')
def test_classification_file(self, mock_stdout):
self.maxDiff = None
try:
sys.argv = ['vsg', '-f', sFileName, '--fix']
__main__.main()
except SystemExit as e:
pass
# self.assertEqual(e.code, 0)
lActual = []
utils.read_file(sFileName, lActual)
lExpected = []
utils.read_file(sFixedFile, lExpected)
self.assertEqual(lExpected, lActual)

View File

@ -19,9 +19,25 @@ class testRuleLibraryMethods(unittest.TestCase):
self.assertEqual(oRule.name, 'library')
self.assertEqual(oRule.identifier, '001')
dExpected = utils.add_violation_list([7,9,21])
lExpected = []
dViolation = utils.add_violation(7)
dViolation['action'] = 'remove'
dViolation['solution'] = 'Remove spaces before "library"'
lExpected.append(dViolation)
dViolation = utils.add_violation(9)
dViolation['action'] = 'remove'
dViolation['solution'] = 'Remove spaces before "Library"'
lExpected.append(dViolation)
dViolation = utils.add_violation(21)
dViolation['action'] = 'remove'
dViolation['solution'] = 'Remove spaces before "library"'
lExpected.append(dViolation)
oRule.analyze(oFile)
self.assertEqual(oRule.violations, dExpected)
self.assertEqual(lExpected, oRule.violations)
def test_rule_002(self):
oRule = library.rule_002()
@ -29,9 +45,22 @@ class testRuleLibraryMethods(unittest.TestCase):
self.assertEqual(oRule.name, 'library')
self.assertEqual(oRule.identifier, '002')
dExpected = utils.add_violation_list([13,20,21])
lExpected = []
dViolation = utils.add_violation(13)
dViolation['solution'] = 'Ensure there are only 1 space(s) between "library" and "lib4"'
lExpected.append(dViolation)
dViolation = utils.add_violation(20)
dViolation['solution'] = 'Ensure there are only 1 space(s) between "LIBRARY" and "lib5"'
lExpected.append(dViolation)
dViolation = utils.add_violation(21)
dViolation['solution'] = 'Ensure there are only 1 space(s) between "library" and "lib6"'
lExpected.append(dViolation)
oRule.analyze(oFile)
self.assertEqual(oRule.violations, dExpected)
self.assertEqual(lExpected, oRule.violations)
def test_rule_003(self):
oRule = library.rule_003()
@ -39,9 +68,9 @@ class testRuleLibraryMethods(unittest.TestCase):
self.assertEqual(oRule.name, 'library')
self.assertEqual(oRule.identifier, '003')
dExpected = [utils.add_violation(21)]
lExpected = [utils.add_violation(21)]
oRule.analyze(oFile)
self.assertEqual(oRule.violations, dExpected)
self.assertEqual(lExpected, oRule.violations)
def test_rule_004(self):
oRule = library.rule_004()
@ -51,15 +80,15 @@ class testRuleLibraryMethods(unittest.TestCase):
lExpected = []
dViolation = utils.add_violation(9)
dViolation['words_to_fix'] = {'Library'}
dViolation['solution'] = 'Change "Library" to "library"'
lExpected.append(dViolation)
dViolation = utils.add_violation(20)
dViolation['words_to_fix'] = {'LIBRARY'}
dViolation['solution'] = 'Change "LIBRARY" to "library"'
lExpected.append(dViolation)
oRule.analyze(oFile)
self.assertEqual(oRule.violations, lExpected)
self.assertEqual(lExpected, oRule.violations)
def test_rule_005(self):
oRule = library.rule_005()
@ -67,11 +96,21 @@ class testRuleLibraryMethods(unittest.TestCase):
self.assertEqual(oRule.name, 'library')
self.assertEqual(oRule.identifier, '005')
lExpected = [{'lines':[{'number': 26}], 'words_to_fix': {'USE'}},
{'lines':[{'number': 27}], 'words_to_fix': {'Use'}},
{'lines':[{'number': 30}], 'words_to_fix': {'uSe'}}]
lExpected = []
dViolation = utils.add_violation(26)
dViolation['solution'] = 'Change "USE" to "use"'
lExpected.append(dViolation)
dViolation = utils.add_violation(27)
dViolation['solution'] = 'Change "Use" to "use"'
lExpected.append(dViolation)
dViolation = utils.add_violation(30)
dViolation['solution'] = 'Change "uSe" to "use"'
lExpected.append(dViolation)
oRule.analyze(oFile)
self.assertEqual(oRule.violations, lExpected)
self.assertEqual(lExpected, oRule.violations)
def test_rule_006(self):
oRule = library.rule_006()
@ -79,9 +118,18 @@ class testRuleLibraryMethods(unittest.TestCase):
self.assertEqual(oRule.name, 'library')
self.assertEqual(oRule.identifier, '006')
dExpected = utils.add_violation_list([27,30])
lExpected = []
dViolation = utils.add_violation(27)
dViolation['solution'] = 'Ensure there are only 1 space(s) between "Use" and "lib6.comp4.all"'
lExpected.append(dViolation)
dViolation = utils.add_violation(30)
dViolation['solution'] = 'Ensure there are only 1 space(s) between "uSe" and "lib6.comp5.all"'
lExpected.append(dViolation)
oRule.analyze(oFile)
self.assertEqual(oRule.violations, dExpected)
self.assertEqual(lExpected, oRule.violations)
def test_rule_007(self):
oRule = library.rule_007()
@ -94,14 +142,41 @@ class testRuleLibraryMethods(unittest.TestCase):
self.assertEqual(oRule.violations, dExpected)
def test_rule_008(self):
self.maxDiff = None
oRule = library.rule_008()
self.assertTrue(oRule)
self.assertEqual(oRule.name, 'library')
self.assertEqual(oRule.identifier, '008')
lExpected = []
dViolation = utils.add_violation(14)
dViolation['action'] = 'insert'
dViolation['iSpaces'] = ' '
dViolation['solution'] = 'Indent 2 spaces'
lExpected.append(dViolation)
dViolation = utils.add_violation(16)
dViolation['action'] = 'insert'
dViolation['iSpaces'] = ' '
dViolation['solution'] = 'Indent 2 spaces'
lExpected.append(dViolation)
dViolation = utils.add_violation(26)
dViolation['action'] = 'insert'
dViolation['iSpaces'] = ' '
dViolation['solution'] = 'Indent 2 spaces'
lExpected.append(dViolation)
dViolation = utils.add_violation(30)
dViolation['action'] = 'change'
dViolation['iSpaces'] = ' '
dViolation['solution'] = 'Indent 2 spaces'
lExpected.append(dViolation)
dExpected = utils.add_violation_list([14,16,26,30])
oRule.analyze(oFile)
self.assertEqual(oRule.violations, dExpected)
self.assertEqual(lExpected, oRule.violations)
def test_rule_009(self):

View File

@ -55,16 +55,6 @@ class testVhdlFileMethods(unittest.TestCase):
else:
self.assertFalse(oLine.isBlank)
def test_library_assignment(self):
lExpected = [3,7,9,13,20,21,32,36]
# Compare
for iIndex, oLine in enumerate(oFileLibrary.lines):
if iIndex in lExpected:
self.assertTrue(oLine.isLibrary)
self.assertEqual(oLine.indentLevel, 0)
else:
self.assertFalse(oLine.isLibrary)
def test_library_use_assignment(self):
lExpected = [4,5,10,14,16,23,24,26,27,30,34,38]
# Compare

View File

@ -36,7 +36,7 @@ class test_library(unittest.TestCase):
self.assertEqual(lExpected, lActual)
def test_library_identifier(self):
def test_library_logical_name(self):
lExpected = []
lExpected.append((3,2))
@ -63,7 +63,7 @@ class test_library(unittest.TestCase):
lActual = []
for iLine, lLine in enumerate(oFile.get_lines()):
for iItem, oItem in enumerate(lLine.objects):
if isinstance(oItem, parser.library_identifier):
if isinstance(oItem, parser.library_logical_name):
lActual.append((iLine, iItem))
self.assertEqual(lExpected, lActual)

View File

@ -23,7 +23,6 @@ def context(self, dVars, lTokens, lObjects, oLine):
* bInsideContext
* bContextEndFound
* bContextIsFound
* iCurrentIndentLevel
'''
for iToken, sToken in enumerate(lTokens):
if dVars['bInsideContext']:
@ -106,7 +105,6 @@ def classify_context_keyword(sToken, iToken, lObjects, dVars, oLine):
if sToken.lower() == 'context':
lObjects[iToken] = parser.keyword(sToken)
dVars['bInsideContext'] = True
dVars['iCurrentIndentLevel'] += 1
def classify_context_reference_keyword(sToken, iToken, lObjects, dVars, oLine):

View File

@ -8,25 +8,17 @@ def library(dVars, lTokens, lObjects, oLine):
'''
Classifies library declarations.
library identifier [, identifier] ;
Sets the following line attributes:
* isLibrary
library logical_name [, logical_name] ;
Modifies the following variables:
* bInsideLibrary
'''
## This will be depricated when the object method is done for libraries
if not oLine.insideEntity and not oLine.insideArchitecture and not oLine.insidePackage and not oLine.insidePackageBody:
check_library_keyword(oLine)
for iToken, sToken in enumerate(lTokens):
if dVars['bInsideLibrary']:
classify_library_identifier(sToken, iToken, lObjects, dVars)
classify_library_logical_name(sToken, iToken, lObjects, dVars)
classify_comma(sToken, iToken, lObjects, dVars)
@ -47,21 +39,12 @@ def classify_comma(sToken, iToken, lObjects, dVars):
lObjects[iToken] = parser.library_comma()
def classify_library_identifier(sToken, iToken, lObjects, dVars):
def classify_library_logical_name(sToken, iToken, lObjects, dVars):
if not isinstance(lObjects[iToken], parser.whitespace) and not isinstance(lObjects[iToken], parser.comment):
lObjects[iToken] = parser.library_identifier(sToken)
lObjects[iToken] = parser.library_logical_name(sToken)
def classify_library_keyword(sToken, iToken, lObjects, dVars, oLine):
if sToken.lower() == 'library':
lObjects[iToken] = parser.library_keyword(sToken)
dVars['bInsideLibrary'] = True
if iToken < 2:
oLine.indentLevel = dVars['iCurrentIndentLevel']
def check_library_keyword(oLine):
if re.match('^\s*library', oLine.lineLower):
oLine.isLibrary = True
oLine.indentLevel = 0

View File

@ -42,7 +42,7 @@ def classify_semicolon(sToken, iToken, lObjects, dVars):
def classify_use_identifier(sToken, iToken, lObjects, dVars):
if not isinstance(lObjects[iToken], parser.whitespace) and not isinstance(lObjects[iToken], parser.comment):
lObjects[iToken] = parser.use_identifier(sToken)
lObjects[iToken] = parser.use_selected_name(sToken)
def classify_use_keyword(sToken, iToken, lObjects, dVars):
@ -51,7 +51,6 @@ def classify_use_keyword(sToken, iToken, lObjects, dVars):
dVars['bInsideUse'] = True
def check_use_keyword(oLine):
if re.match('^\s*use', oLine.lineLower):
oLine.isLibraryUse = True