Skip to content

det: read declared code pages and free format; refuse national text by name (#4462) - #4522

Merged
squid-protocol merged 5 commits into
mainfrom
fix/4462-det-refuse
Oct 6, 2026
Merged

squid-protocol merged 5 commits into
mainfrom
fix/4462-det-refuse

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #4462 (the code-page, free-format and KYUYJP-crash causes; the remaining causes stay ledgered under #4462).

What changed

  • Code pages, decoded the way the engine decodes them. The det source reader decodes the program and each COPY member with the code page the estate declares for that file, which is also the page the engine used (--source-encoding, file_data.source_decode = 'declared'). That page now flows through GalaxyIR.copy_pages(path) (new) → EngineCopies.pages (from the IR, or from the skeleton / port ticket's copy_pages, which is written only when the estate declares a page). A COPY member name can now hold national letters (COPY 'KUNDEÅ'). The CBL-card read for TRUNC / NUMPROC uses the same page.

  • Free format. After >>SOURCE FORMAT FREE (until ... FIXED), a line is code from column 1, of any length, up to a *> comment.

  • Refused by name, never a crash. source.unmodelled runs before the parser and raises a LayoutError / ExprError that names the file, line and character for:

    • any character beyond Latin-1 (national / DBCS text). KYUYJP used to raise UnicodeEncodeError.
    • a national letter in a name (BETRÄGE). The grammar reads ASCII words only.
    • DECIMAL-POINT IS COMMA, so 0,5 is never read as integers.

    Comments and IDENTIFICATION DIVISION comment entries are exempt. A VALUE number that is not a valid Decimal now raises LayoutError instead of InvalidOperation.

Effect on estate-crucible (fact cross-check)

program before now
GULFINQ (cp037) refused (COPY not expanded) translates, full agreement
MODRATE, PCEDFREE (free format) refused (DATA DIVISION line 1) translate, full agreement
KØBREG (cp277) refused (COPY KUNDEÅ) DATA DIVISION translates; PROCEDURE refused by a grammar gap (FUNCTION CURRENT-DATE (1:4))
KYUYJP UnicodeEncodeError refused by name: national / DBCS text
KYUYO01 (cp930), KYUYO02 (shift_jis) refused (COPY / unnamed parse error) decoded, then refused by name: national / DBCS text
ZINSBER (cp273) refused (COPY not expanded) decoded, then refused by name: DECIMAL-POINT IS COMMA

The keyed corpora are unchanged. Ledger: a new cause translator-refuses-national-text (4 entries), KØBREG moves to translator-refuses-grammar, and 8 entries plus the cause translator-copy-statement-forms are dropped.

Remaining causes (not fixed here, recommendation)

  • DBCS / national text (KYUY) and DECIMAL-POINT IS COMMA (ZINSBER): these are translator features. DBCS needs PIC G/N, SO/SI byte widths and name mangling for the ASCII-only grammar. Recommend a separate enhancement.
  • Single-quoted continued literals: the tree-sitter grammar rejects a continued literal in single quotes (double quotes work). as_fixed_rows re-wraps every long joined literal, so a long '...' literal is refused. This may explain the "long continued literals" grammar refusals. Recommend an issue; a possible fix is to re-wrap with double quotes.
  • PAYMAIN (several programs in one source): split per program, as COBOL engine and answer key read only the first program's DATA DIVISION in a multi-program source #4245 did for the engine. LNIDMS01 (IDMS): keep the refusal. LNCALC (PROGRAM-ID LNCALC. with no period): trivial to tolerate, but out of scope here. RPTHDR, CardDemo / GenApp / DSF grammar gaps, and FUNCTION ... (refmod): grammar work.

Evidence

🤖 Generated with Claude Code

https://claude.ai/code/session_01W3KVtYHQp8KsfKcHsdiPbR

squid-protocol and others added 4 commits October 5, 2026 18:34
…ional text by name (#4462)

- The det source reader decodes the program and each COPY member with the code page the engine
  decoded it with (the estate's --source-encoding declaration): GalaxyIR.copy_pages, the
  skeleton's / port ticket's copy_pages, EngineCopies.pages. A COPY member name may hold national
  letters (COPY 'KUNDEÅ'). The CBL-card read for TRUNC / NUMPROC uses the same page.
- >>SOURCE FORMAT FREE (until ... FIXED): code from column 1, any length, up to a *> comment.
- Refused by name before the parser (source.unmodelled -> LayoutError / ExprError): text beyond
  Latin-1 (KYUYJP raised UnicodeEncodeError), a national letter in a name, DECIMAL-POINT IS COMMA;
  a VALUE number that is no Decimal is a LayoutError, never InvalidOperation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… text refused by name

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@squid-protocol squid-protocol added bug Unintended behavior or logic failure in the engine legacy-modernization COBOL refractor, dead-code extraction, and JCL forging priority: high Core feature broken, but workarounds exist labels Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

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

Labels

bug Unintended behavior or logic failure in the engine legacy-modernization COBOL refractor, dead-code extraction, and JCL forging priority: high Core feature broken, but workarounds exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant