vhdl-style-guide/vsg/vhdlFile/classify/attribute.py

30 lines
836 B
Python

import re
def attribute(dVars, lTokens, lObjects, oLine):
classify_attribute_keyword(dVars, oLine)
if oLine.insideAttribute:
classify_attribute_line(dVars, oLine)
classify_attribute_end(dVars, oLine)
def classify_attribute_keyword(dVars, oLine):
if re.match('^\s*attribute', oLine.line, re.IGNORECASE):
oLine.isAttributeKeyword = True
oLine.insideAttribute = True
oLine.indentLevel = dVars['iCurrentIndentLevel']
dVars['iCurrentIndentLevel'] += 1
def classify_attribute_end(dVars, oLine):
if ';' in oLine.line:
oLine.isAttributeEnd = True
dVars['iCurrentIndentLevel'] -= 1
def classify_attribute_line(dVars, oLine):
if not oLine.isAttributeKeyword:
oLine.indentLevel = dVars['iCurrentIndentLevel']
oLine.insideAttribute = True