Merge branch 'jeremiah-c-leary:master' into issue-1330
This commit is contained in:
commit
f59cd83971
|
|
@ -289,13 +289,39 @@
|
|||
62 |
|
||||
<class 'vsg.parser.blank_line'>
|
||||
--------------------------------------------------------------------------------
|
||||
63 | begin
|
||||
<class 'vsg.token.architecture_body.begin_keyword'>
|
||||
63 | type EXAMPLE_T is record
|
||||
<class 'vsg.token.full_type_declaration.type_keyword'>
|
||||
<class 'vsg.token.full_type_declaration.identifier'>
|
||||
<class 'vsg.token.full_type_declaration.is_keyword'>
|
||||
<class 'vsg.token.record_type_definition.record_keyword'>
|
||||
--------------------------------------------------------------------------------
|
||||
64 |
|
||||
64 | axis : m_axis_o(0)'SUBTYPE;
|
||||
<class 'vsg.token.identifier_list.identifier'>
|
||||
<class 'vsg.token.element_declaration.colon'>
|
||||
<class 'vsg.token.attribute_name.name'>
|
||||
<class 'vsg.parser.open_parenthesis'>
|
||||
<class 'vsg.parser.todo'>
|
||||
<class 'vsg.parser.close_parenthesis'>
|
||||
<class 'vsg.token.attribute_name.tic'>
|
||||
<class 'vsg.token.attribute_name.attribute'>
|
||||
<class 'vsg.token.element_declaration.semicolon'>
|
||||
--------------------------------------------------------------------------------
|
||||
65 | end record EXAMPLE_T;
|
||||
<class 'vsg.token.record_type_definition.end_keyword'>
|
||||
<class 'vsg.token.record_type_definition.end_record_keyword'>
|
||||
<class 'vsg.token.record_type_definition.record_type_simple_name'>
|
||||
<class 'vsg.token.full_type_declaration.semicolon'>
|
||||
--------------------------------------------------------------------------------
|
||||
66 |
|
||||
<class 'vsg.parser.blank_line'>
|
||||
--------------------------------------------------------------------------------
|
||||
65 | end architecture RTL;
|
||||
67 | begin
|
||||
<class 'vsg.token.architecture_body.begin_keyword'>
|
||||
--------------------------------------------------------------------------------
|
||||
68 |
|
||||
<class 'vsg.parser.blank_line'>
|
||||
--------------------------------------------------------------------------------
|
||||
69 | end architecture RTL;
|
||||
<class 'vsg.token.architecture_body.end_keyword'>
|
||||
<class 'vsg.token.architecture_body.end_architecture_keyword'>
|
||||
<class 'vsg.token.architecture_body.architecture_simple_name'>
|
||||
|
|
|
|||
|
|
@ -60,6 +60,10 @@ architecture RTL of ENTITY_NAME is
|
|||
sud3 = 10 sud2;
|
||||
end units physical_type_simple_name;
|
||||
|
||||
type EXAMPLE_T is record
|
||||
axis : m_axis_o(0)'SUBTYPE;
|
||||
end record EXAMPLE_T;
|
||||
|
||||
begin
|
||||
|
||||
end architecture RTL;
|
||||
|
|
|
|||
|
|
@ -76,9 +76,9 @@
|
|||
<class 'vsg.token.signal_declaration.signal_keyword'>
|
||||
<class 'vsg.token.signal_declaration.identifier'>
|
||||
<class 'vsg.token.signal_declaration.colon'>
|
||||
<class 'vsg.token.type_mark.name'>
|
||||
<class 'vsg.token.type_mark.tic'>
|
||||
<class 'vsg.token.type_mark.attribute'>
|
||||
<class 'vsg.token.attribute_name.name'>
|
||||
<class 'vsg.token.attribute_name.tic'>
|
||||
<class 'vsg.token.attribute_name.attribute'>
|
||||
<class 'vsg.token.signal_declaration.semicolon'>
|
||||
--------------------------------------------------------------------------------
|
||||
13 |
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from vsg import parser
|
||||
|
||||
|
||||
class name(parser.name):
|
||||
"""
|
||||
unique_id = attribute_name : name
|
||||
"""
|
||||
|
||||
def __init__(self, sString):
|
||||
super().__init__(sString)
|
||||
|
||||
|
||||
class tic(parser.tic):
|
||||
"""
|
||||
unique_id = attribute_name : tic
|
||||
"""
|
||||
|
||||
def __init__(self, sString):
|
||||
super().__init__(sString)
|
||||
|
||||
|
||||
class attribute(parser.attribute):
|
||||
"""
|
||||
unique_id = attribute_name : attribute
|
||||
"""
|
||||
|
||||
def __init__(self, sString):
|
||||
super().__init__(sString)
|
||||
|
|
@ -9,21 +9,3 @@ class name(parser.name):
|
|||
|
||||
def __init__(self, sString):
|
||||
super().__init__(sString)
|
||||
|
||||
|
||||
class tic(parser.tic):
|
||||
"""
|
||||
unique_id = type_mark : tic
|
||||
"""
|
||||
|
||||
def __init__(self, sString):
|
||||
super().__init__(sString)
|
||||
|
||||
|
||||
class attribute(parser.attribute):
|
||||
"""
|
||||
unique_id = type_mark : attribute
|
||||
"""
|
||||
|
||||
def __init__(self, sString):
|
||||
super().__init__(sString)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from vsg import parser
|
||||
from vsg.token import attribute_name as token
|
||||
from vsg.vhdlFile import utils
|
||||
from vsg.vhdlFile.classify import expression, signature
|
||||
|
||||
|
||||
def detect(iToken, lObjects):
|
||||
"""
|
||||
attribute_name ::=
|
||||
prefix [ signature ] ' attribute_designator [ ( expression ) ]
|
||||
"""
|
||||
|
||||
# Skip over prefix
|
||||
iCurrent = utils.find_next_token(iToken, lObjects)
|
||||
iCurrent = utils.find_next_token(iCurrent + 1, lObjects)
|
||||
|
||||
if utils.token_is_open_parenthesis(iCurrent, lObjects):
|
||||
iCurrent += 1
|
||||
iCurrent = utils.skip_tokens_until_matching_closing_paren(iCurrent, lObjects)
|
||||
iCurrent += 1
|
||||
|
||||
# Check for signature
|
||||
if utils.is_next_token("[", iCurrent, lObjects):
|
||||
return True
|
||||
|
||||
# Check for tic
|
||||
if utils.is_next_token("'", iCurrent, lObjects):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def classify(iToken, lObjects):
|
||||
iCurrent = utils.assign_next_token(token.name, iToken, lObjects)
|
||||
iCurrent = utils.find_next_token(iCurrent, lObjects)
|
||||
|
||||
if utils.token_is_open_parenthesis(iCurrent, lObjects):
|
||||
iCurrent = utils.assign_token(lObjects, iCurrent, parser.open_parenthesis)
|
||||
iCurrent = utils.assign_tokens_until_matching_closing_paren(parser.todo, iCurrent, lObjects)
|
||||
iCurrent = utils.assign_token(lObjects, iCurrent, parser.close_parenthesis)
|
||||
|
||||
signature.detect(iCurrent, lObjects)
|
||||
|
||||
iCurrent = utils.assign_next_token_required("'", token.tic, iCurrent, lObjects)
|
||||
iCurrent = utils.assign_next_token(token.attribute, iCurrent, lObjects)
|
||||
|
||||
return iCurrent
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
from vsg import parser
|
||||
from vsg.token import type_mark as token
|
||||
from vsg.vhdlFile import utils
|
||||
from vsg.vhdlFile.classify import attribute_name
|
||||
|
||||
|
||||
def classify(iToken, lObjects):
|
||||
|
|
@ -11,10 +12,10 @@ def classify(iToken, lObjects):
|
|||
*type*_name
|
||||
| *subtype*_name
|
||||
"""
|
||||
|
||||
if attribute_name.detect(iToken, lObjects):
|
||||
return attribute_name.classify(iToken, lObjects)
|
||||
|
||||
iCurrent = utils.assign_next_token(token.name, iToken, lObjects)
|
||||
|
||||
if utils.is_next_token("'", iCurrent, lObjects):
|
||||
iCurrent = utils.assign_next_token(token.tic, iCurrent, lObjects)
|
||||
iCurrent = utils.assign_next_token(token.attribute, iCurrent, lObjects)
|
||||
|
||||
return iCurrent
|
||||
|
|
|
|||
|
|
@ -1017,3 +1017,14 @@ def extract_line_with_token_index_of(iToken, lObjects):
|
|||
for oObject in lObjects[iStart:iEnd]:
|
||||
sReturn += oObject.get_value()
|
||||
return sReturn
|
||||
|
||||
|
||||
def skip_tokens_until_matching_closing_paren(iToken, lObjects):
|
||||
iCounter = 1
|
||||
iCurrent = iToken
|
||||
while iCurrent < len(lObjects):
|
||||
iCurrent = find_next_token(iCurrent, lObjects)
|
||||
iCounter = update_paren_counter(iCurrent, lObjects, iCounter)
|
||||
if token_is_close_parenthesis(iCurrent, lObjects) and iCounter == 0:
|
||||
return iCurrent
|
||||
iCurrent += 1
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from vsg import config, exceptions, parser, token, tokens
|
|||
from vsg.token import (
|
||||
adding_operator,
|
||||
aggregate,
|
||||
attribute_name,
|
||||
choices,
|
||||
direction,
|
||||
exponent,
|
||||
|
|
@ -448,7 +449,12 @@ def post_token_assignments(lTokens):
|
|||
iParenId = 0
|
||||
lParenId = []
|
||||
for iToken, oToken in enumerate(lTokens):
|
||||
if isinstance(oToken, resolution_indication.resolution_function_name) or isinstance(oToken, type_mark.name) or isinstance(oToken, todo.name):
|
||||
if (
|
||||
isinstance(oToken, resolution_indication.resolution_function_name)
|
||||
or isinstance(oToken, type_mark.name)
|
||||
or isinstance(oToken, attribute_name.name)
|
||||
or isinstance(oToken, todo.name)
|
||||
):
|
||||
sValue = oToken.get_value()
|
||||
sLowerValue = oToken.get_lower_value()
|
||||
### IEEE values
|
||||
|
|
@ -476,7 +482,7 @@ def post_token_assignments(lTokens):
|
|||
elif sValue.lower() == "unsigned":
|
||||
lTokens[iToken] = types.unsigned(sValue)
|
||||
|
||||
elif isinstance(oToken, type_mark.attribute):
|
||||
elif isinstance(oToken, attribute_name.attribute):
|
||||
sValue = oToken.get_value()
|
||||
if sValue.lower() in predefined_attribute.values:
|
||||
lTokens[iToken] = predefined_attribute.keyword(sValue)
|
||||
|
|
|
|||
Loading…
Reference in New Issue