From f7b4aae56eaf5787219d5a53dfcbcbf5d601ad4e Mon Sep 17 00:00:00 2001 From: Jeremiah Leary Date: Fri, 8 Jan 2021 17:26:28 -0600 Subject: [PATCH] Updates for issue #514: Parser did not accept infinite loops. 1) Updated test to expose issue 2) Updated parser to allow for infinite loops --- .../loop_statement/classification_results.txt | 22 +++++++++++++++---- .../classification_test_input.vhd | 3 +++ vsg/vhdlFile/classify/loop_statement.py | 22 ++++++++----------- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/vsg/tests/vhdlFile/loop_statement/classification_results.txt b/vsg/tests/vhdlFile/loop_statement/classification_results.txt index dcb01366..706fd25b 100644 --- a/vsg/tests/vhdlFile/loop_statement/classification_results.txt +++ b/vsg/tests/vhdlFile/loop_statement/classification_results.txt @@ -172,18 +172,32 @@ 42 | -------------------------------------------------------------------------------- -43 | +43 | FOR_LABEL : loop + + + +-------------------------------------------------------------------------------- +44 | null; + + +-------------------------------------------------------------------------------- +45 | end loop; + + + +-------------------------------------------------------------------------------- +46 | -------------------------------------------------------------------------------- -44 | end process; +47 | end process; -------------------------------------------------------------------------------- -45 | +48 | -------------------------------------------------------------------------------- -46 | end architecture RTL; +49 | end architecture RTL; diff --git a/vsg/tests/vhdlFile/loop_statement/classification_test_input.vhd b/vsg/tests/vhdlFile/loop_statement/classification_test_input.vhd index 3849b120..77bd8a35 100644 --- a/vsg/tests/vhdlFile/loop_statement/classification_test_input.vhd +++ b/vsg/tests/vhdlFile/loop_statement/classification_test_input.vhd @@ -40,6 +40,9 @@ begin end loop; + FOR_LABEL : loop + null; + end loop; end process; diff --git a/vsg/vhdlFile/classify/loop_statement.py b/vsg/vhdlFile/classify/loop_statement.py index 91433169..a02670e7 100644 --- a/vsg/vhdlFile/classify/loop_statement.py +++ b/vsg/vhdlFile/classify/loop_statement.py @@ -15,23 +15,19 @@ def detect(iToken, lObjects): sequence_of_statements end loop [ loop_label ] ; ''' - if utils.find_in_next_n_tokens(':', 2, iToken, lObjects): iCurrent = utils.find_next_token(iToken, lObjects) iCurrent += 1 - iCurrent = utils.find_next_token(iToken, lObjects) + iCurrent = utils.find_next_token(iCurrent, lObjects) iCurrent += 1 - if iteration_scheme.detect(iToken, lObjects): - return classify(iToken, lObjects) - if utils.is_next_token('loop', iToken, lObjects): - return classify(iToken, lObjects) - return iToken else: - if iteration_scheme.detect(iToken, lObjects): - return classify(iToken, lObjects) - if utils.is_next_token('loop', iToken, lObjects): - return classify(iToken, lObjects) - return iToken + iCurrent = iToken + + if iteration_scheme.detect(iCurrent, lObjects): + return classify(iToken, lObjects) + if utils.is_next_token('loop', iCurrent, lObjects): + return classify(iToken, lObjects) + return iToken @@ -41,7 +37,7 @@ def classify(iToken, lObjects): iCurrent = iteration_scheme.classify(iCurrent, lObjects) - iCurrent = utils.assign_next_token_required('loop', token.loop_keyword, iToken, lObjects) + iCurrent = utils.assign_next_token_required('loop', token.loop_keyword, iCurrent, lObjects) iCurrent = sequence_of_statements.detect(iCurrent, lObjects)