Handle LINKAGE SECTION and PROCEDURE DIVISION USING; skip ENTRY statements #409
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.
Handle LINKAGE SECTION and PROCEDURE DIVISION USING; skip ENTRY statements
Summary
This change updates the cobolcheck Generator to properly handle COBOL programs that declare a LINKAGE SECTION, use a multi-line PROCEDURE DIVISION USING clause, and include ENTRY statements (e.g., DLITCBL) that reference LINKAGE variables. It also adds a focused test program and test cases to validate behavior.
Changes
Introduce state to track multi-line clauses in
Generator:skipUsingClauseLinesandskipEntryStatementLines.Add
processLinkageSectionFix(String sourceLine)to:Skip
LINKAGE SECTIONline entirely.Normalize
PROCEDURE DIVISION USING ...toPROCEDURE DIVISION.while:Detect and skip
ENTRYstatements that reference LINKAGE variables (single- and multi-line), resuming after the terminating period.Route lines through the new processing step before writing:
writeLine(sourceLine)with the processed result, writing only when non-null.Add a COBOL sample program to exercise LINKAGE + USING + ENTRY:
src/main/cobol/TEST-LINKAGE.CBL(new).Add tests:
src/test/cobol/TEST-LINKAGE/TestLinkageSection.cut(new) with two test cases covering main and an additional entry point behavior.Testing
New COBOL program
TEST-LINKAGE.CBLexercises LINKAGE, PROCEDURE DIVISION USING, and ENTRY scenarios.New cut tests:
WS-COUNTERto 1 and setsWS-WORK-AREAto "MAIN ENTRY".WS-COUNTERto 10 and setsWS-WORK-AREAto "ENTRY POINT".These validate that generation proceeds correctly without emitting LINKAGE/USING/ENTRY constructs while preserving program flow for testing.