COBOL Line Filtering: Add GnuCOBOL compatibility for EJECT/SKIP statements and remove right side sequence numbers #408
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This change improves COBOL source line handling in cobol-check to enhance compatibility with GnuCOBOL and address issues with right-hand sequence numbers.
Details
Pagination Directives Filtering:
Lines containing the pagination directives EJECT or SKIP (and variants) are now automatically commented out during source processing. This prevents GnuCOBOL from failing on these unsupported statements.
Right-Side Sequence Number Removal:
All COBOL source lines now have any right-hand sequence numbers (columns 73–80) removed. This fixes issues where such numbers would cause parsing or execution errors.
Non-Disruptive:
The filtering is implemented in a way that does not affect other line processing or introduce regressions. All existing tests pass, and new tests have been added to verify the new behavior.
Tests:
Unit and integration tests were added for:
Files Changed
Modified:
Constants.java - Added COBOL column constants (COBOL_LINE_NUMBER_COLUMN_END, COBOL_CODE_AREA_END)
StringHelper.java - Added shouldFilterLine() and removeRightSideSequenceNumbers() methods
CobolReader.java - Integrated line filtering in readLine() and peekNextMeaningfulLine() methods
StringHelperTest.java - Added unit tests for new filtering methods
Added:
CobolReaderLineFilteringTest.java - Integration tests for end-to-end line filtering functionality
TEST-FILTER.cbl and TEST-FILTER\Testcobollinefilter.cut - Cobol program and test cases to test this change