From 2d356c4a165f4fb52182a60ebf5a9a6730a97202 Mon Sep 17 00:00:00 2001 From: Jeremiah Leary Date: Tue, 4 Apr 2023 06:11:16 -0500 Subject: [PATCH] Issue#928: Fixing classification of discrete_subtype_indication. (#930) --- .../classification_results.txt | 19 ++++++++++++++++--- .../classification_test_input.vhd | 2 ++ vsg/vhdlFile/classify/alias_declaration.py | 1 - vsg/vhdlFile/classify/array_constraint.py | 10 ++++++++++ vsg/vhdlFile/classify/constraint.py | 4 ++++ vsg/vhdlFile/classify/index_constraint.py | 1 - 6 files changed, 32 insertions(+), 5 deletions(-) diff --git a/vsg/tests/vhdlFile/signal_declaration/classification_results.txt b/vsg/tests/vhdlFile/signal_declaration/classification_results.txt index 679001cf..2ef8d3f3 100644 --- a/vsg/tests/vhdlFile/signal_declaration/classification_results.txt +++ b/vsg/tests/vhdlFile/signal_declaration/classification_results.txt @@ -84,13 +84,26 @@ 13 | -------------------------------------------------------------------------------- -14 | begin - +14 | signal slv : std_logic_vector(integer_range_subtype); + + + + + + + + -------------------------------------------------------------------------------- 15 | -------------------------------------------------------------------------------- -16 | end architecture RTL; +16 | begin + +-------------------------------------------------------------------------------- +17 | + +-------------------------------------------------------------------------------- +18 | end architecture RTL; diff --git a/vsg/tests/vhdlFile/signal_declaration/classification_test_input.vhd b/vsg/tests/vhdlFile/signal_declaration/classification_test_input.vhd index 14504d5b..2487a556 100644 --- a/vsg/tests/vhdlFile/signal_declaration/classification_test_input.vhd +++ b/vsg/tests/vhdlFile/signal_declaration/classification_test_input.vhd @@ -11,6 +11,8 @@ architecture RTL of FIFO is signal fifo_rd : fifo_wr'subtype; + signal slv : std_logic_vector(integer_range_subtype); + begin end architecture RTL; diff --git a/vsg/vhdlFile/classify/alias_declaration.py b/vsg/vhdlFile/classify/alias_declaration.py index 07bdbde1..ddd1243e 100644 --- a/vsg/vhdlFile/classify/alias_declaration.py +++ b/vsg/vhdlFile/classify/alias_declaration.py @@ -29,7 +29,6 @@ def classify(iToken, lObjects): if utils.is_next_token(':', iCurrent, lObjects): iCurrent = utils.assign_next_token_required(':', token.colon, iCurrent, lObjects) iCurrent = subtype_indication.classify(iCurrent, lObjects) - iCurrent = utils.assign_next_token_required('is', token.is_keyword, iCurrent, lObjects) iCurrent = name.classify_until([';', '['], iCurrent, lObjects) diff --git a/vsg/vhdlFile/classify/array_constraint.py b/vsg/vhdlFile/classify/array_constraint.py index 9eca7fab..a5f84821 100644 --- a/vsg/vhdlFile/classify/array_constraint.py +++ b/vsg/vhdlFile/classify/array_constraint.py @@ -21,6 +21,11 @@ def detect(iToken, lObjects): return iToken +def detect_discrete_subtype_indication(iToken, lObjects): + if utils.is_next_token('(', iToken, lObjects): + return index_constraint.classify(iToken, lObjects) + return iToken + def classify(iToken, lObjects): iCurrent = utils.find_next_token(iToken, lObjects) @@ -41,3 +46,8 @@ def open_detected(iToken, lObjects): if utils.find_in_next_n_tokens('open', 2, iToken, lObjects): return True return False + + +def classify_index_constraint(iToken, lObjects): + print('--> classify_index_constraint') + return index_constraint.classify(iToken, lObjects) diff --git a/vsg/vhdlFile/classify/constraint.py b/vsg/vhdlFile/classify/constraint.py index 6024b9b0..59627cea 100644 --- a/vsg/vhdlFile/classify/constraint.py +++ b/vsg/vhdlFile/classify/constraint.py @@ -24,4 +24,8 @@ def detect(iToken, lObjects): if iReturn != iToken: return iReturn + iReturn = array_constraint.detect_discrete_subtype_indication(iToken, lObjects) + if iReturn != iToken: + return iReturn + return iToken diff --git a/vsg/vhdlFile/classify/index_constraint.py b/vsg/vhdlFile/classify/index_constraint.py index 84ae7152..4ff1df8d 100644 --- a/vsg/vhdlFile/classify/index_constraint.py +++ b/vsg/vhdlFile/classify/index_constraint.py @@ -19,7 +19,6 @@ def detect(iToken, lObjects): def classify(iToken, lObjects): - iCurrent = utils.assign_next_token_required('(', token.open_parenthesis, iToken, lObjects) while not utils.is_next_token(')', iCurrent, lObjects):