Upadates for issue #91
1) Refactored update_inside_attributes by moving individual updates to their own functions.
This commit is contained in:
parent
c6c01a1462
commit
7865e92b3f
|
|
@ -2,75 +2,6 @@ import re
|
|||
from vsg import line
|
||||
|
||||
|
||||
def update_inside_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideEntity and not oPreviousLine.isEndEntityDeclaration:
|
||||
oCurrentLine.insideEntity = True
|
||||
|
||||
if oPreviousLine.insidePortMap and not oPreviousLine.isEndPortMap:
|
||||
oCurrentLine.insidePortMap = True
|
||||
|
||||
if oPreviousLine.insideGenericMap and not oPreviousLine.isEndGenericMap:
|
||||
oCurrentLine.insideGenericMap = True
|
||||
|
||||
if oPreviousLine.insideArchitecture and not oPreviousLine.isEndArchitecture:
|
||||
oCurrentLine.insideArchitecture = True
|
||||
|
||||
if oPreviousLine.insideProcess and not oPreviousLine.isEndProcess:
|
||||
oCurrentLine.insideProcess = True
|
||||
|
||||
if oPreviousLine.insideConcurrent and not oPreviousLine.isEndConcurrent:
|
||||
oCurrentLine.insideConcurrent = True
|
||||
|
||||
if oPreviousLine.insideSensitivityList and not oPreviousLine.isSensitivityListEnd:
|
||||
oCurrentLine.insideSensitivityList = True
|
||||
|
||||
if oPreviousLine.insideIf and not (oPreviousLine.isEndIfKeyword or oPreviousLine.isThenKeyword):
|
||||
oCurrentLine.insideIf = True
|
||||
|
||||
if oPreviousLine.insideType and not oPreviousLine.isTypeEnd:
|
||||
oCurrentLine.insideType = True
|
||||
|
||||
if oPreviousLine.insideCase and not oPreviousLine.isCaseIsKeyword:
|
||||
oCurrentLine.insideCase = True
|
||||
|
||||
if oPreviousLine.insideCaseWhen and not oPreviousLine.isCaseWhenEnd:
|
||||
oCurrentLine.insideCaseWhen = True
|
||||
|
||||
if oPreviousLine.insideSequential and not oPreviousLine.isSequentialEnd:
|
||||
oCurrentLine.insideSequential = True
|
||||
|
||||
if oPreviousLine.insideVariableAssignment and not oPreviousLine.isVariableAssignmentEnd:
|
||||
oCurrentLine.insideVariableAssignment = True
|
||||
|
||||
if oPreviousLine.insideComponent and not oPreviousLine.isComponentEnd:
|
||||
oCurrentLine.insideComponent = True
|
||||
|
||||
if oPreviousLine.insideInstantiation and not oPreviousLine.isInstantiationPortEnd:
|
||||
oCurrentLine.insideInstantiation = True
|
||||
|
||||
if oPreviousLine.insideInstantiationPortMap and not oPreviousLine.isInstantiationPortEnd:
|
||||
oCurrentLine.insideInstantiationPortMap = True
|
||||
|
||||
if oPreviousLine.insideInstantiationGenericMap and not oPreviousLine.isInstantiationGenericEnd:
|
||||
oCurrentLine.insideInstantiationGenericMap = True
|
||||
|
||||
if oPreviousLine.insidePackage and not oPreviousLine.isPackageEnd:
|
||||
oCurrentLine.insidePackage = True
|
||||
|
||||
if oPreviousLine.insidePackageBody and not oPreviousLine.isPackageBodyEnd:
|
||||
oCurrentLine.insidePackageBody = True
|
||||
|
||||
if oPreviousLine.insideFunction and not oPreviousLine.isFunctionEnd:
|
||||
oCurrentLine.insideFunction = True
|
||||
|
||||
if oPreviousLine.insideGenerate and not oPreviousLine.isGenerateEnd:
|
||||
oCurrentLine.insideGenerate = True
|
||||
|
||||
if oPreviousLine.insideForLoop and not oPreviousLine.isForLoopEnd:
|
||||
oCurrentLine.insideForLoop = True
|
||||
|
||||
|
||||
class vhdlFile():
|
||||
|
||||
def __init__(self, filename):
|
||||
|
|
@ -87,16 +18,15 @@ class vhdlFile():
|
|||
oFile.close()
|
||||
|
||||
def _processFile(self):
|
||||
fFoundArchitectureBegin = False
|
||||
fFoundProcessBegin = False
|
||||
fSensitivityListFound = False
|
||||
|
||||
fGenerateBeginFound = False
|
||||
dVars = {}
|
||||
dVars['fFoundProcessBegin'] = False
|
||||
dVars['SensitivityListFound'] = False
|
||||
|
||||
iOpenParenthesis = 0
|
||||
iCloseParenthesis = 0
|
||||
dVars['iOpenParenthesis'] = 0
|
||||
dVars['iCloseParenthesis'] = 0
|
||||
|
||||
iCurrentIndentLevel = 0
|
||||
dVars['iCurrentIndentLevel'] = 0
|
||||
|
||||
with open(self.filename) as oFile:
|
||||
for sLine in oFile:
|
||||
|
|
@ -112,10 +42,10 @@ class vhdlFile():
|
|||
oLine.commentColumn = oLine.line.find('--')
|
||||
if re.match('^\s*--', oLine.line):
|
||||
oLine.isComment = True
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
# Check for null statements
|
||||
if re.match('^\s*null\s*;', oLine.lineLower):
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
# Check for library lines
|
||||
if re.match('^\s*library', oLine.lineLower):
|
||||
oLine.isLibrary = True
|
||||
|
|
@ -128,14 +58,14 @@ class vhdlFile():
|
|||
if re.match('^\s*entity', oLine.lineLower):
|
||||
self.hasEntity = True
|
||||
oLine.isEntityDeclaration = True
|
||||
iCurrentIndentLevel = 1
|
||||
dVars['iCurrentIndentLevel'] = 1
|
||||
oLine.indentLevel = 0
|
||||
oLine.insideEntity = True
|
||||
# Check for the end of the entity
|
||||
if re.match('^\s*end', oLine.lineLower) and not oLine.insidePortMap and not oLine.insideGenericMap and oLine.insideEntity:
|
||||
oLine.isEndEntityDeclaration = True
|
||||
oLine.indentLevel = 0
|
||||
iCurrentIndentLevel = 0
|
||||
dVars['iCurrentIndentLevel'] = 0
|
||||
|
||||
# Check port map declarations
|
||||
if oLine.insideEntity or oLine.insideComponent:
|
||||
|
|
@ -144,10 +74,10 @@ class vhdlFile():
|
|||
oLine.insidePortMap = True
|
||||
if oLine.insideEntity:
|
||||
oLine.indentLevel = 1
|
||||
iCurrentIndentLevel = 2
|
||||
dVars['iCurrentIndentLevel'] = 2
|
||||
else:
|
||||
oLine.indentLevel = 2
|
||||
iCurrentIndentLevel = 3
|
||||
dVars['iCurrentIndentLevel'] = 3
|
||||
|
||||
if oLine.insidePortMap:
|
||||
if re.match('^\s*\w+.*:', oLine.line) and not oLine.isComment and not oLine.isPortKeyword:
|
||||
|
|
@ -156,39 +86,39 @@ class vhdlFile():
|
|||
oLine.indentLevel = 2
|
||||
else:
|
||||
oLine.indentLevel = 3
|
||||
iOpenParenthesis += oLine.line.count('(')
|
||||
iCloseParenthesis += oLine.line.count(')')
|
||||
if iOpenParenthesis == iCloseParenthesis:
|
||||
iOpenParenthesis = 0
|
||||
iCloseParenthesis = 0
|
||||
dVars['iOpenParenthesis'] += oLine.line.count('(')
|
||||
dVars['iCloseParenthesis'] += oLine.line.count(')')
|
||||
if dVars['iOpenParenthesis'] == dVars['iCloseParenthesis']:
|
||||
dVars['iOpenParenthesis'] = 0
|
||||
dVars['iCloseParenthesis'] = 0
|
||||
oLine.isEndPortMap = True
|
||||
if oLine.insideEntity:
|
||||
oLine.indentLevel = 1
|
||||
iCurrentIndentLevel = 1
|
||||
dVars['iCurrentIndentLevel'] = 1
|
||||
else:
|
||||
oLine.indentLevel = 2
|
||||
iCurrentIndentLevel = 2
|
||||
dVars['iCurrentIndentLevel'] = 2
|
||||
|
||||
# Check generic map declarations
|
||||
if oLine.insideEntity or oLine.insideComponent:
|
||||
if re.match('^\s*generic', oLine.lineLower) and not oLine.insideGenericMap:
|
||||
oLine.isGenericKeyword = True
|
||||
oLine.insideGenericMap = True
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
iCurrentIndentLevel += 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
dVars['iCurrentIndentLevel'] += 1
|
||||
if oLine.insideGenericMap:
|
||||
if re.match('^\s*\S+.*:', oLine.line):
|
||||
oLine.isGenericDeclaration = True
|
||||
if not oLine.isGenericKeyword:
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
iOpenParenthesis += oLine.line.count('(')
|
||||
iCloseParenthesis += oLine.line.count(')')
|
||||
if iOpenParenthesis == iCloseParenthesis:
|
||||
oLine.indentLevel = iCurrentIndentLevel - 1
|
||||
iOpenParenthesis = 0
|
||||
iCloseParenthesis = 0
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
dVars['iOpenParenthesis'] += oLine.line.count('(')
|
||||
dVars['iCloseParenthesis'] += oLine.line.count(')')
|
||||
if dVars['iOpenParenthesis'] == dVars['iCloseParenthesis']:
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel'] - 1
|
||||
dVars['iOpenParenthesis'] = 0
|
||||
dVars['iCloseParenthesis'] = 0
|
||||
oLine.isEndGenericMap = True
|
||||
iCurrentIndentLevel = iCurrentIndentLevel - 2
|
||||
dVars['iCurrentIndentLevel'] = dVars['iCurrentIndentLevel'] - 2
|
||||
|
||||
# Check architecture declarations
|
||||
if re.match('^\s*architecture', oLine.lineLower) and not oLine.insideArchitecture:
|
||||
|
|
@ -196,58 +126,56 @@ class vhdlFile():
|
|||
oLine.isArchitectureKeyword = True
|
||||
oLine.insideArchitecture = True
|
||||
oLine.indentLevel = 0
|
||||
iCurrentIndentLevel = 1
|
||||
dVars['iCurrentIndentLevel'] = 1
|
||||
if oLine.insideArchitecture:
|
||||
if re.match('^\s*begin', oLine.lineLower) and not fFoundArchitectureBegin and not oLine.insideFunction:
|
||||
fFoundArchitectureBegin = True
|
||||
if re.match('^\s*begin', oLine.lineLower) and not oLine.insideFunction and not oLine.insideProcess and not oLine.insideGenerate:
|
||||
oLine.isArchitectureBegin = True
|
||||
oLine.indentLevel = 0
|
||||
iCurrentIndentLevel = 1
|
||||
dVars['iCurrentIndentLevel'] = 1
|
||||
if not oLine.insideProcess and not oLine.insideCase and not oLine.insideComponent and not oLine.insideGenerate and not oLine.insideFunction and not oLine.insideForLoop:
|
||||
if re.match('^\s*end', oLine.lineLower):
|
||||
fFoundArchitectureBegin = False
|
||||
oLine.isEndArchitecture = True
|
||||
oLine.indentLevel = 0
|
||||
iCurrentIndentLevel = 0
|
||||
dVars['iCurrentIndentLevel'] = 0
|
||||
|
||||
# Check package body declarations
|
||||
if re.match('^\s*package\s+body', oLine.lineLower) and not oLine.insidePackageBody:
|
||||
oLine.isPackageBodyKeyword = True
|
||||
oLine.insidePackageBody = True
|
||||
oLine.indentLevel = 0
|
||||
iCurrentIndentLevel = 1
|
||||
dVars['iCurrentIndentLevel'] = 1
|
||||
if oLine.insidePackageBody:
|
||||
if not oLine.insideProcess and not oLine.insideCase and not oLine.insideComponent:
|
||||
if re.match('^\s*end\s+', oLine.lineLower):
|
||||
oLine.isPackageBodyEnd = True
|
||||
oLine.indentLevel = 0
|
||||
iCurrentIndentLevel = 0
|
||||
dVars['iCurrentIndentLevel'] = 0
|
||||
|
||||
# Check package declarations
|
||||
if re.match('^\s*package', oLine.lineLower) and not oLine.insidePackage and not oLine.insidePackageBody:
|
||||
oLine.isPackageKeyword = True
|
||||
oLine.insidePackage = True
|
||||
oLine.indentLevel = 0
|
||||
iCurrentIndentLevel = 1
|
||||
dVars['iCurrentIndentLevel'] = 1
|
||||
if oLine.insidePackage:
|
||||
if not oLine.insideProcess and not oLine.insideCase and not oLine.insideComponent:
|
||||
if re.match('^\s*end\s+', oLine.lineLower):
|
||||
oLine.isPackageEnd = True
|
||||
oLine.indentLevel = 0
|
||||
iCurrentIndentLevel = 0
|
||||
dVars['iCurrentIndentLevel'] = 0
|
||||
|
||||
# Check Component declarations
|
||||
if re.match('^\s*component', oLine.lineLower) and not oLine.insideComponent:
|
||||
oLine.isComponentDeclaration = True
|
||||
oLine.insideComponent = True
|
||||
oLine.indentLevel = 1
|
||||
iCurrentIndentLevel += 1
|
||||
dVars['iCurrentIndentLevel'] += 1
|
||||
|
||||
if oLine.insideComponent:
|
||||
if re.match('^\s*end\s+component', oLine.lineLower):
|
||||
oLine.isComponentEnd = True
|
||||
oLine.indentLevel = 1
|
||||
iCurrentIndentLevel -= 1
|
||||
dVars['iCurrentIndentLevel'] -= 1
|
||||
|
||||
# Check Signal declarations
|
||||
if oLine.insideArchitecture:
|
||||
|
|
@ -265,38 +193,38 @@ class vhdlFile():
|
|||
if oLine.insideArchitecture:
|
||||
if re.match('^\s*variable', oLine.lineLower):
|
||||
oLine.isVariable = True
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
|
||||
# Check process declarations
|
||||
if oLine.insideArchitecture:
|
||||
if re.match('^\s*process', oLine.lineLower) or re.match('^\s*\S+\s*:\s*process', oLine.lineLower) and not oLine.isComment:
|
||||
oLine.isProcessKeyword = True
|
||||
oLine.insideProcess = True
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
if oLine.insideProcess:
|
||||
# Check sensitivity list
|
||||
if '(' in oLine.line and not oLine.insideSensitivityList and not fFoundProcessBegin and not fSensitivityListFound:
|
||||
if '(' in oLine.line and not oLine.insideSensitivityList and not dVars['fFoundProcessBegin'] and not dVars['SensitivityListFound']:
|
||||
oLine.isSensitivityListBegin = True
|
||||
oLine.insideSensitivityList = True
|
||||
fSensitivityListFound = True
|
||||
dVars['SensitivityListFound'] = True
|
||||
if oLine.insideSensitivityList:
|
||||
iOpenParenthesis += oLine.line.count('(')
|
||||
iCloseParenthesis += oLine.line.count(')')
|
||||
if iOpenParenthesis == iCloseParenthesis:
|
||||
dVars['iOpenParenthesis'] += oLine.line.count('(')
|
||||
dVars['iCloseParenthesis'] += oLine.line.count(')')
|
||||
if dVars['iOpenParenthesis'] == dVars['iCloseParenthesis']:
|
||||
oLine.isSensitivityListEnd = True
|
||||
iOpenParenthesis = 0
|
||||
iCloseParenthesis = 0
|
||||
iCurrentIndentLevel += 1
|
||||
dVars['iOpenParenthesis'] = 0
|
||||
dVars['iCloseParenthesis'] = 0
|
||||
dVars['iCurrentIndentLevel'] += 1
|
||||
if re.match('^.*\s+begin', oLine.lineLower) or re.match('^\s*begin', oLine.lineLower):
|
||||
oLine.indentLevel = iCurrentIndentLevel - 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel'] - 1
|
||||
oLine.isProcessBegin = True
|
||||
fFoundProcessBegin = True
|
||||
dVars['fFoundProcessBegin'] = True
|
||||
if re.match('^\s*end\s+process', oLine.lineLower):
|
||||
oLine.indentLevel = iCurrentIndentLevel - 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel'] - 1
|
||||
oLine.isEndProcess = True
|
||||
fFoundProcessBegin = False
|
||||
iCurrentIndentLevel = iCurrentIndentLevel - 1
|
||||
fSensitivityListFound = False
|
||||
dVars['fFoundProcessBegin'] = False
|
||||
dVars['iCurrentIndentLevel'] = dVars['iCurrentIndentLevel'] - 1
|
||||
dVars['SensitivityListFound'] = False
|
||||
|
||||
# Check generate declarations
|
||||
if oLine.insideArchitecture:
|
||||
|
|
@ -305,22 +233,20 @@ class vhdlFile():
|
|||
if oLine.insideGenerate:
|
||||
if re.match('^\s*\w+\s*:\s*if\s.*\sgenerate', oLine.lineLower) or re.match('^\s*\w+\s*:\s*for\s.*\sgenerate', oLine.lineLower):
|
||||
oLine.isGenerateKeyword = True
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
iCurrentIndentLevel += 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
dVars['iCurrentIndentLevel'] += 1
|
||||
if re.match('^\s*begin', oLine.lineLower):
|
||||
oLine.isGenerateBegin = True
|
||||
oLine.indentLevel = iCurrentIndentLevel - 1
|
||||
fGenerateBeginFound = True
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel'] - 1
|
||||
if re.match('^\s*end\s+generate', oLine.lineLower):
|
||||
oLine.isGenerateEnd = True
|
||||
iCurrentIndentLevel -= 1
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
fGenerateBeginFound = False
|
||||
dVars['iCurrentIndentLevel'] -= 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
|
||||
# Check concurrent declarations
|
||||
if oLine.insideArchitecture and not oLine.insideProcess:
|
||||
if re.match('^\s*\w+\s*<=', oLine.line) or re.match('^\s*\w+\s*:\s*\w+\s*<=', oLine.line):
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
oLine.isConcurrentBegin = True
|
||||
oLine.insideConcurrent = True
|
||||
if oLine.insideConcurrent:
|
||||
|
|
@ -332,48 +258,48 @@ class vhdlFile():
|
|||
if re.match('^\s*for\s.*\sin\s.*\sloop', oLine.lineLower):
|
||||
oLine.isForLoopKeyword = True
|
||||
oLine.insideForLoop = True
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
iCurrentIndentLevel += 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
dVars['iCurrentIndentLevel'] += 1
|
||||
if re.match('^\s*end\s+loop', oLine.lineLower):
|
||||
oLine.isForLoopEnd = True
|
||||
iCurrentIndentLevel -= 1
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
dVars['iCurrentIndentLevel'] -= 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
|
||||
# Check if statements
|
||||
if oLine.insideProcess or oLine.insideFunction:
|
||||
if re.match('^\s*if', oLine.lineLower):
|
||||
oLine.isIfKeyword = True
|
||||
oLine.insideIf = True
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
iCurrentIndentLevel += 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
dVars['iCurrentIndentLevel'] += 1
|
||||
if re.match('^\s*elsif', oLine.lineLower) or re.match('^.*\selsif', oLine.lineLower):
|
||||
oLine.isElseIfKeyword = True
|
||||
oLine.insideIf = True
|
||||
oLine.indentLevel = iCurrentIndentLevel - 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel'] - 1
|
||||
if oLine.insideIf and 'then' in oLine.lineLower:
|
||||
oLine.isThenKeyword = True
|
||||
if re.match('^\s*else', oLine.lineLower) or re.match('^.*\selse', oLine.lineLower):
|
||||
oLine.isElseKeyword = True
|
||||
oLine.indentLevel = iCurrentIndentLevel - 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel'] - 1
|
||||
if re.match('^\s*end\s+if', oLine.lineLower) or re.match('^.*\send\s+if', oLine.lineLower):
|
||||
oLine.isEndIfKeyword = True
|
||||
iCurrentIndentLevel -= 1
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
dVars['iCurrentIndentLevel'] -= 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
|
||||
# Check case statements
|
||||
if oLine.insideProcess or oLine.insideFunction:
|
||||
if re.match('^\s*case[\s|\(]', oLine.lineLower):
|
||||
oLine.isCaseKeyword = True
|
||||
oLine.insideCase = True
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
iCurrentIndentLevel += 2
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
dVars['iCurrentIndentLevel'] += 2
|
||||
if oLine.insideCase:
|
||||
if re.match('^\s*.*[\s|\)]is\s', oLine.lineLower) or re.match('^\s*.*[\s|\)]is$', oLine.lineLower):
|
||||
oLine.isCaseIsKeyword = True
|
||||
if re.match('^\s*when\s', oLine.lineLower):
|
||||
oLine.isCaseWhenKeyword = True
|
||||
oLine.insideCaseWhen = True
|
||||
oLine.indentLevel = iCurrentIndentLevel - 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel'] - 1
|
||||
if self.lines[-1].isComment:
|
||||
self.lines[-1].indentLevel -= 1
|
||||
if oLine.insideCaseWhen:
|
||||
|
|
@ -381,50 +307,50 @@ class vhdlFile():
|
|||
oLine.isCaseWhenEnd = True
|
||||
if re.match('^\s*end\s+case', oLine.lineLower):
|
||||
oLine.isEndCaseKeyword = True
|
||||
oLine.indentLevel = iCurrentIndentLevel - 2
|
||||
iCurrentIndentLevel -= 2
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel'] - 2
|
||||
dVars['iCurrentIndentLevel'] -= 2
|
||||
|
||||
# Check function declarations
|
||||
if oLine.insideArchitecture:
|
||||
if re.match('^\s*function\s', oLine.lineLower) or re.match('^\s*impure\s', oLine.lineLower):
|
||||
oLine.isFunctionKeyword = True
|
||||
oLine.insideFunction = True
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
iCurrentIndentLevel += 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
dVars['iCurrentIndentLevel'] += 1
|
||||
if oLine.insideFunction:
|
||||
if re.match('^\s*begin', oLine.lineLower):
|
||||
oLine.isFunctionBegin = True
|
||||
oLine.indentLevel = iCurrentIndentLevel - 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel'] - 1
|
||||
if re.match('^\s*return', oLine.lineLower):
|
||||
oLine.isFunctionReturn = True
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
if re.match('^\s*end', oLine.lineLower) and not oLine.isEndIfKeyword and not oLine.isEndCaseKeyword and not oLine.isForLoopEnd:
|
||||
oLine.isFunctionEnd = True
|
||||
oLine.indentLevel = iCurrentIndentLevel - 1
|
||||
iCurrentIndentLevel -= 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel'] - 1
|
||||
dVars['iCurrentIndentLevel'] -= 1
|
||||
|
||||
# Check type declarations
|
||||
if oLine.insideArchitecture or oLine.insidePackage:
|
||||
if re.match('^\s*type\s', oLine.lineLower):
|
||||
oLine.isTypeKeyword = True
|
||||
oLine.insideType = True
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
iCurrentIndentLevel += 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
dVars['iCurrentIndentLevel'] += 1
|
||||
if oLine.insideType:
|
||||
if not oLine.isTypeKeyword and not oLine.isBlank:
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
if ';' in oLine.line:
|
||||
oLine.isTypeEnd = True
|
||||
iCurrentIndentLevel -= 1
|
||||
dVars['iCurrentIndentLevel'] -= 1
|
||||
if re.match('^\s*\)\s*;', oLine.line):
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
|
||||
# Check sequential statements
|
||||
if oLine.insideProcess:
|
||||
if re.match('^.*<=', oLine.line) and not oLine.isComment and not oLine.insideIf and not oLine.isElseKeyword:
|
||||
oLine.isSequential = True
|
||||
oLine.insideSequential = True
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
oLine.sequentialAlignmentColumn = oLine.line.find('<=')
|
||||
if oLine.insideSequential:
|
||||
if ';' in oLine.line:
|
||||
|
|
@ -435,7 +361,7 @@ class vhdlFile():
|
|||
if re.match('^.*:=', oLine.line) and not oLine.isComment and not oLine.insideIf and not oLine.isElseKeyword and not oLine.isVariable:
|
||||
oLine.isVariableAssignment = True
|
||||
oLine.insideVariableAssignment = True
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
oLine.variableAssignmentAlignmentColumn = oLine.line.find(':=')
|
||||
if oLine.insideVariableAssignment:
|
||||
if ';' in oLine.line:
|
||||
|
|
@ -446,24 +372,24 @@ class vhdlFile():
|
|||
if re.match('^\s*\w+\s*:\s*\w+', oLine.line):
|
||||
oLine.isInstantiationDeclaration = True
|
||||
oLine.insideInstantiation = True
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
iCurrentIndentLevel += 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
dVars['iCurrentIndentLevel'] += 1
|
||||
if oLine.insideInstantiation:
|
||||
if re.match('^.*\s*port\s+map', oLine.lineLower):
|
||||
if not oLine.indentLevel:
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
iCurrentIndentLevel += 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
dVars['iCurrentIndentLevel'] += 1
|
||||
oLine.isInstantiationPortKeyword = True
|
||||
oLine.insideInstantiationPortMap = True
|
||||
if re.match('^.*\s*generic\s+map', oLine.lineLower):
|
||||
if not oLine.indentLevel:
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
oLine.insideInstantiationGenericMap = True
|
||||
iCurrentIndentLevel += 1
|
||||
dVars['iCurrentIndentLevel'] += 1
|
||||
oLine.isInstantiationGenericKeyword = True
|
||||
if re.match('^.*=>', oLine.line):
|
||||
if not oLine.indentLevel:
|
||||
oLine.indentLevel = iCurrentIndentLevel
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel']
|
||||
if oLine.insideInstantiationPortMap:
|
||||
oLine.isInstantiationPortAssignment = True
|
||||
else:
|
||||
|
|
@ -471,15 +397,173 @@ class vhdlFile():
|
|||
if ');' in oLine.line and oLine.insideInstantiationPortMap:
|
||||
oLine.isInstantiationPortEnd = True
|
||||
if not oLine.indentLevel:
|
||||
oLine.indentLevel = iCurrentIndentLevel - 1
|
||||
iCurrentIndentLevel -= 2
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel'] - 1
|
||||
dVars['iCurrentIndentLevel'] -= 2
|
||||
if ')' in oLine.line and oLine.insideInstantiationGenericMap:
|
||||
oLine.isInstantiationGenericEnd = True
|
||||
if not oLine.indentLevel:
|
||||
oLine.indentLevel = iCurrentIndentLevel - 1
|
||||
iCurrentIndentLevel -= 1
|
||||
oLine.indentLevel = dVars['iCurrentIndentLevel'] - 1
|
||||
dVars['iCurrentIndentLevel'] -= 1
|
||||
|
||||
# Add line to file
|
||||
self.lines.append(oLine)
|
||||
|
||||
oFile.close()
|
||||
|
||||
|
||||
def update_entity_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideEntity and not oPreviousLine.isEndEntityDeclaration:
|
||||
oCurrentLine.insideEntity = True
|
||||
|
||||
|
||||
def update_port_map_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insidePortMap and not oPreviousLine.isEndPortMap:
|
||||
oCurrentLine.insidePortMap = True
|
||||
|
||||
|
||||
def update_generic_map_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideGenericMap and not oPreviousLine.isEndGenericMap:
|
||||
oCurrentLine.insideGenericMap = True
|
||||
|
||||
|
||||
def update_architecture_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideArchitecture and not oPreviousLine.isEndArchitecture:
|
||||
oCurrentLine.insideArchitecture = True
|
||||
|
||||
|
||||
def update_process_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideProcess and not oPreviousLine.isEndProcess:
|
||||
oCurrentLine.insideProcess = True
|
||||
|
||||
|
||||
def update_concurrent_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideConcurrent and not oPreviousLine.isEndConcurrent:
|
||||
oCurrentLine.insideConcurrent = True
|
||||
|
||||
|
||||
def update_sensitivity_list_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideSensitivityList and not oPreviousLine.isSensitivityListEnd:
|
||||
oCurrentLine.insideSensitivityList = True
|
||||
|
||||
|
||||
def update_if_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideIf and not (oPreviousLine.isEndIfKeyword or oPreviousLine.isThenKeyword):
|
||||
oCurrentLine.insideIf = True
|
||||
|
||||
|
||||
def update_type_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideType and not oPreviousLine.isTypeEnd:
|
||||
oCurrentLine.insideType = True
|
||||
|
||||
|
||||
def update_case_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideCase and not oPreviousLine.isCaseIsKeyword:
|
||||
oCurrentLine.insideCase = True
|
||||
|
||||
|
||||
def update_case_when_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideCaseWhen and not oPreviousLine.isCaseWhenEnd:
|
||||
oCurrentLine.insideCaseWhen = True
|
||||
|
||||
|
||||
def update_sequential_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideSequential and not oPreviousLine.isSequentialEnd:
|
||||
oCurrentLine.insideSequential = True
|
||||
|
||||
|
||||
def update_variable_assignment_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideVariableAssignment and not oPreviousLine.isVariableAssignmentEnd:
|
||||
oCurrentLine.insideVariableAssignment = True
|
||||
|
||||
|
||||
def update_component_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideComponent and not oPreviousLine.isComponentEnd:
|
||||
oCurrentLine.insideComponent = True
|
||||
|
||||
|
||||
def update_instantiation_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideInstantiation and not oPreviousLine.isInstantiationPortEnd:
|
||||
oCurrentLine.insideInstantiation = True
|
||||
|
||||
|
||||
def update_instantiation_port_map_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideInstantiationPortMap and not oPreviousLine.isInstantiationPortEnd:
|
||||
oCurrentLine.insideInstantiationPortMap = True
|
||||
|
||||
|
||||
def update_instantiation_generic_map_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideInstantiationGenericMap and not oPreviousLine.isInstantiationGenericEnd:
|
||||
oCurrentLine.insideInstantiationGenericMap = True
|
||||
|
||||
|
||||
def update_package_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insidePackage and not oPreviousLine.isPackageEnd:
|
||||
oCurrentLine.insidePackage = True
|
||||
|
||||
|
||||
def update_package_body_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insidePackageBody and not oPreviousLine.isPackageBodyEnd:
|
||||
oCurrentLine.insidePackageBody = True
|
||||
|
||||
|
||||
def update_function_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideFunction and not oPreviousLine.isFunctionEnd:
|
||||
oCurrentLine.insideFunction = True
|
||||
|
||||
|
||||
def update_generate_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideGenerate and not oPreviousLine.isGenerateEnd:
|
||||
oCurrentLine.insideGenerate = True
|
||||
|
||||
|
||||
def update_for_loop_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
if oPreviousLine.insideForLoop and not oPreviousLine.isForLoopEnd:
|
||||
oCurrentLine.insideForLoop = True
|
||||
|
||||
|
||||
def update_inside_attributes(oPreviousLine, oCurrentLine):
|
||||
|
||||
update_entity_attributes(oPreviousLine, oCurrentLine)
|
||||
update_port_map_attributes(oPreviousLine, oCurrentLine)
|
||||
update_generic_map_attributes(oPreviousLine, oCurrentLine)
|
||||
update_architecture_attributes(oPreviousLine, oCurrentLine)
|
||||
update_process_attributes(oPreviousLine, oCurrentLine)
|
||||
update_concurrent_attributes(oPreviousLine, oCurrentLine)
|
||||
update_sensitivity_list_attributes(oPreviousLine, oCurrentLine)
|
||||
update_if_attributes(oPreviousLine, oCurrentLine)
|
||||
update_type_attributes(oPreviousLine, oCurrentLine)
|
||||
update_case_attributes(oPreviousLine, oCurrentLine)
|
||||
update_case_when_attributes(oPreviousLine, oCurrentLine)
|
||||
update_sequential_attributes(oPreviousLine, oCurrentLine)
|
||||
update_variable_assignment_attributes(oPreviousLine, oCurrentLine)
|
||||
update_component_attributes(oPreviousLine, oCurrentLine)
|
||||
update_instantiation_attributes(oPreviousLine, oCurrentLine)
|
||||
update_instantiation_port_map_attributes(oPreviousLine, oCurrentLine)
|
||||
update_instantiation_generic_map_attributes(oPreviousLine, oCurrentLine)
|
||||
update_package_attributes(oPreviousLine, oCurrentLine)
|
||||
update_package_body_attributes(oPreviousLine, oCurrentLine)
|
||||
update_function_attributes(oPreviousLine, oCurrentLine)
|
||||
update_generate_attributes(oPreviousLine, oCurrentLine)
|
||||
update_for_loop_attributes(oPreviousLine, oCurrentLine)
|
||||
|
|
|
|||
Loading…
Reference in New Issue