Skip to content

COBOL→Java translator: det/source.py _COPY does not match a quoted copybook literal with an extension (COPY "x.cpy".), so the copybook is never expanded #5645

Closed as not planned

Description

@squid-protocol

Problem

The translator resolves COPY with its own regex, not the scanner's copy_statement_data: gitgalaxy/tools/cobol_to_java/det/source.py:652

_WORD = r"(?:[^\W_]|[#@$-])"
_COPY = re.compile(rf"(?<!{_WORD})COPY\s+(['\"]?)({_WORD}+)\1(?:\s+(?:OF|IN)\s+({_WORD}+))?", re.I)

A quoted member must be all word characters, so a quoted file literal with an extension matches nothing (checked at main):

source match
COPY "ws-state.cpy". none
COPY 'ws-state.cpy'. none
COPY "WSSTATE". WSSTATE
COPY WSSTATE. WSSTATE

Effect on translation: the include is not expanded, so the copybook's data items are unresolved in the generated Java (generation or compile failure for any program that names copybooks this way: GnuCOBOL free-format style, and fixed format too). #5618 / PR #5626 fix the scanner side only (mainframe_boundary.py, galaxy_ir.py); this is the translator's copy of the same rule.

Acceptance

  • _COPY (and any sibling COPY/REPLACING parsing in det/) accepts a quoted literal with dots/extension, single or double quotes, fixed and free format, with OF/IN lib and REPLACING; the member resolves to the copybook file in the source tree (ws-state.cpy -> that file; unquoted WSSTATE keeps today's lookup).
  • Tests (our own fixtures) for each shape, including a small program whose translation needs the quoted copybook's fields; existing estate/CICS crucible translations unchanged.
  • Share one COPY-literal rule between scanner and translator if practical, so they can't drift again.

Found while checking how the #5618 fix reaches CICS→Java translation (#5457).

🤖 Generated with Claude Code

Activity

  1. added
    bug
    core-engine
    priority: high
    scope:core
    on Oct 19, 2026
  2. squid-protocol commented on Oct 19, 2026

    @squid-protocol
    OwnerAuthor

    Folded into #5648 (shared COBOL preprocessor): the translator's COPY handling moves into one module shared with the scanner, and this case (COPY "x.cpy".) is in its acceptance. Fixing it here first would mean fixing it twice.

    🤖 Generated with Claude Code

  3. added a commit that references this issue on Oct 19, 2026
    0ceb755
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

    bugcore-enginepriority: highscope:core

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions