Пример #1
0
 def _analyze(self, oFile, oLine, iLineNumber):
     sLine = utils.remove_comment(oLine.line)
     if sLine[-2:] == '--':
         sLine = sLine[:-2]
     if '-' in sLine:
         lLine = sLine.split()
         for sWord in lLine:
             if '-' in sWord:
                 if sWord == '-':
                     # already good.
                     continue
                 if re.match(r".*?'-'", sWord) is not None:
                     # found a std_logic don't care.
                     continue
                 if re.match(r'(?:".*"|[^"\n])*?-', sWord) is None:
                     # The - was in a quoted string.
                     # e.g. found a std_logic_vector constant with a don't care.
                     continue
                 #if re.match('^.*\W-[0-9]', sWord) is not None:
                 #    # found a negative number
                 #    continue
                 if re.match('^.*\w-', sWord):
                     dViolation = utils.create_violation_dict(iLineNumber)
                     self.add_violation(dViolation)
                 elif not re.match('^.*-[0-9]+\)?$', sWord):
                     dViolation = utils.create_violation_dict(iLineNumber)
                     self.add_violation(dViolation)
     else:
         if re.match('^.*[\w+|\)][+|/|*]', sLine) or re.match(
                 '^.*[+|/|*][\w+|\(]', sLine):
             if not re.match('^.*".*/.*"', sLine):
                 dViolation = utils.create_violation_dict(iLineNumber)
                 self.add_violation(dViolation)
Пример #2
0
 def update_line(self, sLine):
     '''
     This method updates the line, lineLower and lineNoComment attributes.
     '''
     self.line = sLine
     self.lineLower = sLine.lower()
     self.lineNoComment = utils.remove_comment(sLine)
Пример #3
0
 def update_line(self, sLine):
     '''
     This method updates the line, lineLower and lineNoComment attributes.
     '''
     self.line = sLine
     self.lineLower = sLine.lower()
     self.lineNoComment = utils.remove_comment(sLine)
     self.tokens, self.separators = tokens.create(sLine)
Пример #4
0
 def update_line_from_tokens(self):
     '''
     This method creates the line, lineLower and lineNoComment from the seperators and tokens list
     '''
     sLine = ''
     for sSep, sTok in zip(self.separators, self.tokens):
         sLine += sSep + sTok
     self.line = sLine
     self.lineLower = sLine.lower()
     self.lineNoComment = utils.remove_comment(sLine)
Пример #5
0
 def _analyze(self, oFile, oLine, iLineNumber):
     sLine = utils.remove_comment(oLine.line)
     if sLine[-2:] == '--':
         sLine = sLine[:-2]
     if '-' in sLine:
         lLine = sLine.split()
         for sWord in lLine:
             if '-' in sWord and not sWord == '-':
                 if re.match('^.*\w-', sWord):
                     self.add_violation(iLineNumber)
                 elif not re.match('^.*-[0-9]+\)?$', sWord):
                     self.add_violation(iLineNumber)
     else:
         if re.match('^.*[\w+|\)][+|/|*]', sLine) or re.match(
                 '^.*[+|/|*][\w+|\(]', sLine):
             if not re.match('^.*".*/.*"', sLine):
                 self.add_violation(iLineNumber)
Пример #6
0
 def _analyze(self, oFile, oLine, iLineNumber):
     if oLine.isSignal:
         self.sFullLine = ''
         self.iFailureLine = iLineNumber
     if oLine.insideSignal:
         self.sFullLine += oLine.line
     if oLine.isEndSignal:
         #<<<<<<< HEAD
         match = re.match(r'.*?signal\s+(?P<signals>[^:\n]*):',
                          utils.remove_comment(self.sFullLine),
                          flags=re.IGNORECASE)
         if match:
             sSignalList = match.group("signals")
             if sSignalList.count(',') > self.consecutive - 1:
                 dViolation = utils.create_violation_dict(self.iFailureLine)
                 dViolation['endLine'] = iLineNumber
                 dViolation['line'] = self.sFullLine
                 self.add_violation(dViolation)
Пример #7
0
 def _fix_violations(self, oFile):
     for dViolation in self.violations[::-1]:
         iLineNumber = utils.get_violation_line_number(dViolation)
         utils.remove_lines(oFile, iLineNumber, dViolation['endLine'])
         sLine = dViolation['line']
         sLine = utils.remove_comment(sLine)
         sLine = sLine.split(':')[0]
         iNumLines = sLine.count(',') + 1
         lSignals = _extract_signals(dViolation['line'])
         sAfterColon = _extract_after_colon(dViolation['line'])
         for i in range(0, iNumLines):
             utils.insert_line(oFile, i + iLineNumber)
             oLine = oFile.lines[i + iLineNumber]
             oLine.isSignal = True
             oLine.insideSignal = True
             oLine.isEndSignal = True
             oLine.isBlank = False
             oLine.update_line('  signal ' + lSignals[i] + ' : ' +
                               sAfterColon)
             utils.update_comment_line_attributes(oLine)
Пример #8
0
    def __init__(self, line):
        self.line = line
        self.lineLower = line.lower()
        self.lineNoComment = utils.remove_comment(line)
        self.tokens, self.separators = tokens.create(self.line)

        self.indentLevel = None
        # Misc attributes
        self.isBlank = False
        # Comment attributes
        self.isComment = False
        self.hasComment = False
        self.hasInlineComment = False
        self.commentColumn = None
        # Library attributes
        self.isLibrary = False
        self.isLibraryUse = False
        # Entity attributes
        self.insideEntity = False
        self.isEntityDeclaration = False
        self.isEndEntityDeclaration = False
        # Port attributes
        self.insidePortMap = False
        self.isPortDeclaration = False
        self.isPortKeyword = False
        self.isEndPortMap = False
        # Generic attributes
        self.insideGenericMap = False
        self.isGenericDeclaration = False
        self.isGenericKeyword = False
        self.isEndGenericMap = False
        # Architecture attributes
        self.insideArchitecture = False
        self.isArchitectureBegin = False
        self.isArchitectureKeyword = False
        self.isEndArchitecture = False
        self.insideArchitectureDeclarativeRegion = False
        # Signal attributes
        self.isSignal = False
        self.insideSignal = False
        self.isEndSignal = False
        # Constant attributes
        self.insideConstant = False
        self.isConstant = False
        self.isConstantEnd = False
        self.isConstantArray = False
        # Variable attributes
        self.isVariable = False
        # Process attributes
        self.insideProcess = False
        self.isProcessBegin = False
        self.isProcessKeyword = False
        self.isProcessLabel = False
        self.isProcessEndLabel = False
        self.isProcessDeclarative = False
        self.isEndProcess = False
        self.insideSensitivityList = False
        self.isSensitivityListBegin = False
        self.isSensitivityListEnd = False
        self.isClockStatement = False
        self.insideClockProcess = False
        self.insideResetProcess = False
        self.isProcessIs = False
        # Concurrent attributes
        self.insideConcurrent = False
        self.isConcurrentBegin = False
        self.isEndConcurrent = False
        self.hasConcurrentLabel = False
        # When attributes
        self.insideWhen = False
        self.isWhenKeyword = False
        self.isWhenElseKeyword = False
        self.isWhenEnd = False
        # If attributes
        self.insideIf = False
        self.isElseKeyword = False
        self.isElseIfKeyword = False
        self.isEndIfKeyword = False
        self.isIfEnd = False
        self.isIfKeyword = False
        self.isThenKeyword = False
        self.isLastEndIf = False
        self.isFirstIf = False
        # Case attributes
        self.insideCaseStatement = False
        self.insideCase = False
        self.insideCaseWhen = False
        self.isCaseIsKeyword = False
        self.isCaseKeyword = False
        self.isCaseWhenEnd = False
        self.isCaseWhenKeyword = False
        self.isEndCaseKeyword = False
        self.isCaseNull = False
        self.hasCaseLabel = False
        self.hasEndCaseLabel = False
        # Sequential attributes
        self.insideSequential = False
        self.isSequentialEnd = False
        self.isSequential = False
        self.sequentialAlignmentColumn = None
        # Component attributes
        self.insideComponent = False
        self.isComponentDeclaration = False
        self.isComponentEnd = False
        # Instantiation attributes
        self.insideInstantiation = False
        self.isInstantiationDeclaration = False
        self.isDirectInstantiationDeclaration = False
        self.insideInstantiationPortMap = False
        self.isInstantiationPortKeyword = False
        self.isInstantiationPortEnd = False
        self.isInstantiationPortAssignment = False
        self.insideInstantiationGenericMap = False
        self.isInstantiationGenericKeyword = False
        self.isInstantiationGenericEnd = False
        self.isInstantiationGenericAssignment = False
        # Package attributes
        self.insidePackage = False
        self.isPackageKeyword = False
        self.isPackageEnd = False
        # Package Body attributes
        self.insidePackageBody = False
        self.isPackageBodyKeyword = False
        self.isPackageBodyEnd = False
        # Generate attributes
        self.insideGenerate = False
        self.isGenerateBegin = False
        self.isGenerateKeyword = False
        self.isGenerateEnd = False
        self.isGenerateLabel = False
        self.isGenerateEndLabel = False
        self.insideGenerateCase = False
        self.insideGenerateCaseWhen = False
        self.isGenerateCaseWhen = False
        # Function attributes
        self.insideFunction = False
        self.insideFunctionDeclarative = False
        self.isFunctionParameter = False
        self.isFunctionParameterEnd = False
        self.isFunctionBegin = False
        self.isFunctionKeyword = False
        self.isFunctionEnd = False
        self.isFunctionReturn = False
        self.hasFunctionReturnType = False
        self.isFunctionReturnKeyword = False
        self.hasFunctionIs = False
        # For Loop attributes
        self.insideForLoop = False
        self.isForLoopKeyword = False
        self.isForLoopEnd = False
        self.isForLoopLabel = False
        # While Loop attributes
        self.insideWhileLoop = False
        self.isWhileLoopKeyword = False
        self.isWhileLoopEnd = False
        # Type attributes
        self.isTypeKeyword = False
        self.isTypeEnd = False
        # Subtype attributes
        self.insideSubtype = False
        self.isSubtypeKeyword = False
        self.isSubtypeEnd = False
        # Enumerated Type attributes
        self.insideTypeEnumerated = False
        self.isTypeEnumeratedKeyword = False
        self.isTypeEnumeratedEnd = False
        # Type Array attributes
        self.insideTypeArray = False
        self.isTypeArrayKeyword = False
        self.isTypeArrayEnd = False
        # Type Record attributes
        self.insideTypeRecord = False
        self.isTypeRecordKeyword = False
        self.isTypeRecordEnd = False
        # Variable Assignment attributes
        self.insideVariableAssignment = False
        self.isVariableAssignmentEnd = False
        self.isVariableAssignment = False
        self.variableAssignmentAlignmentColumn = None
        # Assert attributes
        self.isAssertKeyword = False
        self.isAssertEnd = False
        self.insideAssert = False
        # With attributes
        self.isWithKeyword = False
        # Attribute attributes
        self.isAttributeKeyword = False
        self.isAttributeEnd = False
        self.insideAttribute = False
        # File attributes
        self.isFileKeyword = False
        self.isFileEnd = False
        self.insideFile = False
        # Procedure attributes
        self.insideProcedure = False
        self.insideProcedureDeclarative = False
        self.isProcedureParameter = False
        self.isProcedureParameterEnd = False
        self.isProcedureBegin = False
        self.isProcedureKeyword = False
        self.isProcedureEnd = False
        self.isProcedureReturn = False
        self.isProcedureIs = False
        # Block attributes
        self.insideBlock = False
        self.isBlockBegin = False
        self.isBlockKeyword = False
        self.isEndBlock = False
        # Wait attributes
        self.isWait = False
        # Code tags
        self.hasCodeTag = False
        self.codeTags = {}
        # After attributes
        self.hasAfterKeyword = False