Skip to content

Forge COBOL readers: hyphen word boundaries (END-PERFORM, END-IF, END-CALL) and column-7 comment lines #3420

Closed

Description

@squid-protocol

Found by the mainframe ground-truth ledger while building the CardDemo answer key. The answer key's own reader had the same hyphen bugs; this PR fixes and pins them there. Causes: forge_hyphen_word_boundary and forge_reads_comment_lines.

1. \b matches after a hyphen (cobol_graveyard_finder.py)

  • _PERFORM = \bPERFORM\s+(NAME) (line 53): with END-PERFORM followed by PERFORM X, \b matches between - and P. That reads as a PERFORM of the word PERFORM and swallows the real call. On CardDemo COTRTLIC, 9450-CLOSE-FORWARD-CURSOR and its -EXIT are PERFORMed from a live paragraph but are reported dead.
  • _last_sentence counts \bIF\b against \bEND-IF\b, so each END-IF counts as an IF too, and any sentence with a closed IF looks unterminated. A paragraph ending … END-IF … GOBACK. or … PERFORM GET-ME-OUT-OF-HERE. then reads as falling through. On CBSA, DELACC, INQACCCU and UPDCUST's A999 are dead but the forge reports them live. The key had the same bug and missed them too; this PR corrects the CBSA key. EVALUATE / END-EVALUATE has the same problem.
  • Fix: use (?<![\w-]) instead of \b before the verb, as the key reader now does.

2. cobol_dag_architect.py scans comment lines and hyphenated words

  • re.finditer(r'CALL\s+(?![\'"])([A-Z0-9\-]+)', safe_content) (line 131) matches:

    • commented-out lines (column-7 *), for example *CALL ASSEMBLER PROGRAM, * CALL MENU PROGRAM, * CALL CARD DETAIL PROGRAM;
    • END-CALL followed by the next word (IF);
    • 3200-INSERT-IMS-CALL THRU.

    That's 12 false dynamic CALLs on CardDemo (ASSEMBLER, MENU, CARD, TO, FAILED, FAIL, IF, THRU).

  • OPEN modes are read from commented-out SELECT/OPEN lines too. On DBUNLDGS that gives 2 false outputs, OUTFIL1 and OUTFIL2, whose SELECT and OPEN are both commented out.

Acceptance

The matching forge | dead, forge | dynamic CALLs and forge | outputs ledger entries stop reproducing (CardDemo and CBSA), and are ratcheted out with ground_truth_ledger.py update. Add fixtures for each shape.

🤖 Generated with Claude Code

Activity

  1. added
    bug
    legacy-modernization
    on Sep 23, 2026
  2. squid-protocol commented on Sep 23, 2026

    @squid-protocol
    OwnerAuthor

    One more mechanism for this issue, found by the blind cross-check (cross_verify.py): cobol_graveyard_finder._is_terminal / _last_sentence test only a unit's last sentence. In CBSA's BNK1CAC/CCA/CCS/CRA/DAC/DCS/TFN/UAC and BNKMENU, A010 has an unconditional EXEC CICS RETURN TRANSID(...) RESP(...) END-EXEC. sentence followed by an IF <resp not normal> … PERFORM ABEND-THIS-TASK END-IF. recovery sentence. The RETURN already ends the unit, so A999 is dead in all nine. The key's own reader had the same bug; the key is now corrected and those 9 entries are ledgered as forge_last_sentence_only. When fixing it, note the other side of the same code: CardDemo CBSTM03A reaches 8200/8300/8400-*-OPEN only through ALTER 8100-FILE-OPEN TO PROCEED TO …. A reader that stops treating a stray trailing EXIT. as fall-through must count ALTER targets, or it will mark those live paragraphs dead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buglegacy-modernization

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions