Repository navigation
Description
Why
The scanner and the COBOL→Java translator each turn COBOL files into "the program the compiler sees", separately. The fact cross-check gate (#4273, fact-crosscheck.yml) catches them disagreeing, but not sharing a blind spot: on 2026-10-19 both missed COPY "ws-state.cpy". (scanner #5618 / PR #5626, translator #5645), so they agreed and the gate stayed green. BMS already follows the shared pattern (the translator imports core.bms_screen_fields / core.bms_symbolic), as do core.cobol_source_format, core.source_text.read_source and core.compiler_options. Do the same for the rest of the text-level front end.
What the preprocessor does (one module in gitgalaxy/core, no tree-sitter, zero-dependency)
Input: a COBOL source file + copy libraries. Output: the expanded program text plus a line map (every expanded line → original file and line).
- Layout: fixed format (sequence area 1-6, indicator 7:
*/comment,Ddebug,-continuation; text past 72) and free format (*>),>>SOURCE FORMATswitching. Reusecore/cobol_source_format.py. - Continuations: join continued literals and words (
-in column 7). - COPY: find
COPY name [OF|IN lib]in every spelling (unquoted, quoted, quoted with extension"x.cpy"), resolve the member (core/copy_libraries.py, the engine already owns resolution since det translator: take COPY resolution from the engine (ownership per #4273), replacing the first-hit directory search #4468), insert it, recursively, with cycle detection. - Substitution:
COPY … REPLACING(==pseudo-text==, partial words,:TAG:templates), theREPLACEstatement, conditional compilation (>>IF/>>ELSE/>>END-IF,>>DEFINE) per the compiler options already parsed bycore.compiler_options. - Line map, so findings and generated Java point at
CUSTREC.cpy:12, not a line of the expanded text.
Out of scope:EXEC SQL/CICS/DLIblocks pass through untouched; statement parsing and record layouts stay where they are (the translator's tree-sitter grammar is byte-proven against GnuCOBOL, Translator front-end bake-off: which COBOL parser should the det translator use? #4378).
Where it replaces duplicate code
- Translator:
gitgalaxy/tools/cobol_to_java/det/source.pyexpand()(:728),_replacing/_replace(:809/:820),copy_names/_copy_match/_COPY(:652-:665), comment/free-format helpers (:288, :574, :581),as_fixed/as_fixed_rows(:1001). - Scanner:
gitgalaxy/core/mainframe_boundary.py_copy_replacing(:641),_continued_literal(:552); the REPLACING application ingitgalaxy/tools/cobol_to_cobol/galaxy_ir.py(COBOL engine: a section-level COPY ... REPLACING is not applied to the copied 01 records (misnamed or missing) #4457); any COPY regex instandards/language_standards/languages/cobol.py.
Acceptance
- One module used by both sides; the translator and the scanner no longer contain their own COPY/REPLACING/continuation code.
- Fixes 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 (translator
COPY "x.cpy".) here; the scanner fix from COBOL: quoted copybook literals with an extension (COPY "x.cpy".) record no COPY statements, free and fixed format #5618/PR COBOL: quoted copybook literals with an extension keep IN/REPLACING; plain section COPYs get a row (Fixes #5618) #5626 is subsumed (keep its tests). - Re-proof: every crucible port and equivalence case still passes byte-for-byte (CICS crucible, estate crucible, golden crucible), the fact cross-check ledger does not grow (it should shrink where the two sides now share text), COBOL goldens unchanged or drift explained.
- Tests per step and shape, fixed and free format, our own fixtures (licensing rule: no third-party code).
- Note in
docs/language_status/fact_ownership.md: the expanded text is a shared input, no longer a duplicated channel.
Part of the CICS→Java path (Training Montage). Follow-up: #5649 (translator consumes engine layouts).
🤖 Generated with Claude Code
Activity
evidence report: fingerprint core.cobol_preprocessor, which the trans…
core.cobol_preprocessor: one COPY / REPLACING rule for the scanner an…
Scanner: _COPY_IN_ENTRY / _COPY_LIBRARY come from core.cobol_preproce…
Continuation joining: the literal-resume rule lives in core.cobol_pre…
Continuation joining: continued_literal and join_continuation live in…
det/source.py: sort the preprocessor imports (Part of #5648)
19 remaining items
core.cobol_preprocessor: MappedLine / line_map, the expansion's line …
data_moves: a literal holding `*>` is not a floating comment (Part of #…
data_moves: a doubled quote inside a literal does not end it (Part of #…
golden: re-bless for continued-literal MOVE rows (Part of #5648)
tests: mark the CicsTask abend test slow (cold shared javac build in …
data_moves: a fixed-format continued literal is one token (Part of #5648
squid-protocol commentedon Oct 22, 2026
Churn run
5648-20261022T1542Z(host nyx) ended without a PR. No change: translator det/source.py already on shared preprocessor. #5648 left open: scanner side (mainframe_boundary, galaxy_ir) and line-map consumption not verified.squid-protocol commentedon Oct 23, 2026
Claimed by promoter-bot host
nyx, lease renewed 2026-10-23T07:29Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove theclaim:nyxlabel.squid-protocol commentedon Oct 23, 2026
Closing: audit on origin/main shows every acceptance item met (shared core preprocessor used by det/source.py and mainframe_boundary.py, #5645 fixed, fact_ownership.md note, fixed+free-format tests). Caveat for the doc's 'Not yet shared' section: the scanner does not yet call expand() or consume the line map (needs a golden bless, no consumer yet); file separately if wanted.
squid-protocol commentedon Oct 23, 2026
Churn run
5648-20261023T0744Z(host nyx) ended without a PR. audit: all acceptance met, issue closed; no PR