From c3f02ec83399f66e64db7a8d60599ea5bcb6b170 Mon Sep 17 00:00:00 2001 From: Jeremiah Leary Date: Sun, 19 Nov 2023 07:49:34 -0600 Subject: [PATCH] Issue#966: Updating classifier to handle subtypes within constraints. (#1032) --- .../classification_results.txt | 51 +++++++++++++++++-- .../classification_test_input.vhd | 9 ++++ vsg/vhdlFile/classify/discrete_range.py | 3 ++ 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/vsg/tests/vhdlFile/subtype_declaration/classification_results.txt b/vsg/tests/vhdlFile/subtype_declaration/classification_results.txt index ef69c6e6..166df7e6 100644 --- a/vsg/tests/vhdlFile/subtype_declaration/classification_results.txt +++ b/vsg/tests/vhdlFile/subtype_declaration/classification_results.txt @@ -104,13 +104,56 @@ 19 | -------------------------------------------------------------------------------- -20 | begin - +20 | -- Example 4 : subtype in subtype declaration + -------------------------------------------------------------------------------- -21 | +21 | subtype identifier is type_mark(type_mark(blah)); + + + + + + + + + + + +-------------------------------------------------------------------------------- +22 | -------------------------------------------------------------------------------- -22 | end architecture RTL; +23 | subtype identifier is type_mark(type_mark + + + + + + +-------------------------------------------------------------------------------- +24 | ( + +-------------------------------------------------------------------------------- +25 | blah + +-------------------------------------------------------------------------------- +26 | ) + +-------------------------------------------------------------------------------- +27 | ); + + +-------------------------------------------------------------------------------- +28 | + +-------------------------------------------------------------------------------- +29 | begin + +-------------------------------------------------------------------------------- +30 | + +-------------------------------------------------------------------------------- +31 | end architecture RTL; diff --git a/vsg/tests/vhdlFile/subtype_declaration/classification_test_input.vhd b/vsg/tests/vhdlFile/subtype_declaration/classification_test_input.vhd index 0fc60203..9c6ce582 100644 --- a/vsg/tests/vhdlFile/subtype_declaration/classification_test_input.vhd +++ b/vsg/tests/vhdlFile/subtype_declaration/classification_test_input.vhd @@ -17,6 +17,15 @@ architecture RTL of FIFO is subtype new_std_logic is (resolved) std_ulogic; + -- Example 4 : subtype in subtype declaration + subtype identifier is type_mark(type_mark(blah)); + + subtype identifier is type_mark(type_mark + ( + blah + ) + ); + begin end architecture RTL; diff --git a/vsg/vhdlFile/classify/discrete_range.py b/vsg/vhdlFile/classify/discrete_range.py index b69dd336..8ff70009 100644 --- a/vsg/vhdlFile/classify/discrete_range.py +++ b/vsg/vhdlFile/classify/discrete_range.py @@ -4,6 +4,7 @@ from vsg import parser from vsg.vhdlFile import utils from vsg.vhdlFile.classify import range +from vsg.vhdlFile.classify import subtype_indication def detect(iToken, lObjects): @@ -11,6 +12,8 @@ def detect(iToken, lObjects): discrete_range ::= *discrete*_subtype_indication | range ''' + if utils.are_next_consecutive_tokens([None, '(', None, ')'], iToken, lObjects): + return subtype_indication.classify(iToken, lObjects) return range.detect(iToken, lObjects)