Issue#1057: Fixing classification of formal_part. (#1060)
This commit is contained in:
parent
5c85734a07
commit
e5ca972b09
|
|
@ -29,6 +29,11 @@ begin
|
|||
PORT_3 => w_port_3
|
||||
);
|
||||
|
||||
U_INST2 : INST2
|
||||
generic map (
|
||||
W_GEN_1(W_GEN_1) => 3,
|
||||
G_GEN_2(W_GEN_1) => 10
|
||||
);
|
||||
|
||||
end architecture ARCH;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class test_generic_map_rule(unittest.TestCase):
|
|||
self.assertEqual(oRule.name, 'generic_map')
|
||||
self.assertEqual(oRule.identifier, '601')
|
||||
|
||||
lExpected = [22, 23, 24]
|
||||
lExpected = [22, 23, 24, 34]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
|
@ -35,7 +35,7 @@ class test_generic_map_rule(unittest.TestCase):
|
|||
self.assertEqual(oRule.name, 'generic_map')
|
||||
self.assertEqual(oRule.identifier, '601')
|
||||
|
||||
lExpected = [22, 23, 24]
|
||||
lExpected = [22, 23, 24, 34]
|
||||
|
||||
oRule.analyze(self.oFile)
|
||||
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,80 @@
|
|||
--------------------------------------------------------------------------------
|
||||
0 |
|
||||
--------------------------------------------------------------------------------
|
||||
1 | architecture rtl of fifo is
|
||||
<class 'vsg.token.architecture_body.architecture_keyword'>
|
||||
<class 'vsg.token.architecture_body.identifier'>
|
||||
<class 'vsg.token.architecture_body.of_keyword'>
|
||||
<class 'vsg.token.architecture_body.entity_name'>
|
||||
<class 'vsg.token.architecture_body.is_keyword'>
|
||||
--------------------------------------------------------------------------------
|
||||
2 |
|
||||
<class 'vsg.parser.blank_line'>
|
||||
--------------------------------------------------------------------------------
|
||||
3 | begin
|
||||
<class 'vsg.token.architecture_body.begin_keyword'>
|
||||
--------------------------------------------------------------------------------
|
||||
4 |
|
||||
<class 'vsg.parser.blank_line'>
|
||||
--------------------------------------------------------------------------------
|
||||
5 | dut : entity work.ampersand
|
||||
<class 'vsg.token.component_instantiation_statement.instantiation_label'>
|
||||
<class 'vsg.token.component_instantiation_statement.label_colon'>
|
||||
<class 'vsg.token.instantiated_unit.entity_keyword'>
|
||||
<class 'vsg.token.instantiated_unit.library_name'>
|
||||
<class 'vsg.token.instantiated_unit.dot'>
|
||||
<class 'vsg.token.instantiated_unit.entity_name'>
|
||||
--------------------------------------------------------------------------------
|
||||
6 | generic map (
|
||||
<class 'vsg.token.generic_map_aspect.generic_keyword'>
|
||||
<class 'vsg.token.generic_map_aspect.map_keyword'>
|
||||
<class 'vsg.token.generic_map_aspect.open_parenthesis'>
|
||||
--------------------------------------------------------------------------------
|
||||
7 | g_FIRST => c_FIRST,
|
||||
<class 'vsg.token.association_element.formal_part'>
|
||||
<class 'vsg.token.association_element.assignment'>
|
||||
<class 'vsg.token.association_element.actual_part'>
|
||||
<class 'vsg.token.association_list.comma'>
|
||||
--------------------------------------------------------------------------------
|
||||
8 | g_SECOND(0) => c_SECOND
|
||||
<class 'vsg.token.association_element.formal_part'>
|
||||
<class 'vsg.parser.open_parenthesis'>
|
||||
<class 'vsg.parser.todo'>
|
||||
<class 'vsg.parser.close_parenthesis'>
|
||||
<class 'vsg.token.association_element.assignment'>
|
||||
<class 'vsg.token.association_element.actual_part'>
|
||||
--------------------------------------------------------------------------------
|
||||
9 | )
|
||||
<class 'vsg.token.generic_map_aspect.close_parenthesis'>
|
||||
--------------------------------------------------------------------------------
|
||||
10 | port map (
|
||||
<class 'vsg.token.port_map_aspect.port_keyword'>
|
||||
<class 'vsg.token.port_map_aspect.map_keyword'>
|
||||
<class 'vsg.token.port_map_aspect.open_parenthesis'>
|
||||
--------------------------------------------------------------------------------
|
||||
11 | i_thing => inthing,
|
||||
<class 'vsg.token.association_element.formal_part'>
|
||||
<class 'vsg.token.association_element.assignment'>
|
||||
<class 'vsg.token.association_element.actual_part'>
|
||||
<class 'vsg.token.association_list.comma'>
|
||||
--------------------------------------------------------------------------------
|
||||
12 | o_thing(0) => outthing
|
||||
<class 'vsg.token.association_element.formal_part'>
|
||||
<class 'vsg.parser.open_parenthesis'>
|
||||
<class 'vsg.parser.todo'>
|
||||
<class 'vsg.parser.close_parenthesis'>
|
||||
<class 'vsg.token.association_element.assignment'>
|
||||
<class 'vsg.token.association_element.actual_part'>
|
||||
--------------------------------------------------------------------------------
|
||||
13 | );
|
||||
<class 'vsg.token.port_map_aspect.close_parenthesis'>
|
||||
<class 'vsg.token.component_instantiation_statement.semicolon'>
|
||||
--------------------------------------------------------------------------------
|
||||
14 |
|
||||
<class 'vsg.parser.blank_line'>
|
||||
--------------------------------------------------------------------------------
|
||||
15 | 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'>
|
||||
<class 'vsg.token.architecture_body.semicolon'>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
architecture rtl of fifo is
|
||||
|
||||
begin
|
||||
|
||||
dut : entity work.ampersand
|
||||
generic map (
|
||||
g_FIRST => c_FIRST,
|
||||
g_SECOND(0) => c_SECOND
|
||||
)
|
||||
port map (
|
||||
i_thing => inthing,
|
||||
o_thing(0) => outthing
|
||||
);
|
||||
|
||||
end architecture rtl;
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
import os
|
||||
|
||||
import unittest
|
||||
|
||||
from vsg.tests import utils
|
||||
from vsg import vhdlFile
|
||||
|
||||
sLrmUnit = utils.extract_lrm_unit_name(__name__)
|
||||
|
||||
lFile, eError =vhdlFile.utils.read_vhdlfile(os.path.join(os.path.dirname(__file__), sLrmUnit,'classification_test_input.vhd'))
|
||||
oFile = vhdlFile.vhdlFile(lFile)
|
||||
|
||||
|
||||
class test_token(unittest.TestCase):
|
||||
|
||||
def test_classification(self):
|
||||
self.maxDiff = None
|
||||
sTestDir = os.path.join(os.path.dirname(__file__), sLrmUnit)
|
||||
|
||||
lExpected = []
|
||||
utils.read_file(os.path.join(sTestDir, 'classification_results.txt'), lExpected, False)
|
||||
|
||||
lActual = []
|
||||
|
||||
for oObject in utils.extract_objects(oFile, True):
|
||||
lActual.append(str(oObject))
|
||||
|
||||
self.assertEqual(lExpected, lActual)
|
||||
|
||||
|
|
@ -3,6 +3,8 @@ from vsg.token import association_element as token
|
|||
|
||||
from vsg.vhdlFile import utils
|
||||
|
||||
from vsg.vhdlFile.classify import formal_part
|
||||
|
||||
|
||||
def detect(iCurrent, lObjects):
|
||||
'''
|
||||
|
|
@ -36,12 +38,9 @@ def detect(iCurrent, lObjects):
|
|||
|
||||
def classify(iStart, iEnd, lObjects, sEnd):
|
||||
iCurrent = iStart
|
||||
sPrint = ''
|
||||
for oObject in lObjects[iStart:iEnd + 1]:
|
||||
sPrint += oObject.get_value()
|
||||
# Classify formal part if it exists
|
||||
if utils.find_in_index_range('=>', iStart, iEnd, lObjects):
|
||||
iCurrent = utils.assign_tokens_until('=>', token.formal_part, iCurrent, lObjects)
|
||||
iCurrent = formal_part.classify(token.formal_part, iCurrent, lObjects)
|
||||
iCurrent = utils.assign_next_token_required('=>', token.assignment, iCurrent, lObjects)
|
||||
|
||||
# Classify actual part
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
from vsg import parser
|
||||
|
||||
from vsg.vhdlFile import utils
|
||||
|
||||
|
||||
def classify(oTokenType, iToken, lObjects):
|
||||
'''
|
||||
formal_part ::=
|
||||
formal_designator
|
||||
| function_name ( formal_designator )
|
||||
| type_mark ( formal_designator )
|
||||
|
||||
An association element will end with =>
|
||||
'''
|
||||
# Assign first token as formal part
|
||||
iCurrent = utils.assign_next_token(oTokenType, iToken, lObjects)
|
||||
|
||||
# Assign remaining tokens as todo
|
||||
while not utils.are_next_consecutive_tokens_ignoring_whitespace(['=>'], iCurrent, lObjects):
|
||||
iCurrent = utils.assign_next_token(parser.todo, iCurrent, lObjects)
|
||||
|
||||
return iCurrent
|
||||
Loading…
Reference in New Issue