Repository navigation
det SORT / MERGE: EBCDIC and literal COLLATING SEQUENCE alphabets (#4268) - #4540
Merged
Merged
Conversation
) The det translator refused every SORT / MERGE COLLATING SEQUENCE (and PROGRAM COLLATING SEQUENCE) other than NATIVE / STANDARD-1. Now: - STANDARD-2 is the data's byte order, as STANDARD-1. - ALPHABET ... IS EBCDIC and literal alphabets (literals, multi-character literals, THRU ascending or descending, ALSO, SPACE / ZERO / QUOTE) order the alphanumeric keys through a new Sort.Collating; numeric keys still compare by value. - Sort.Collating keeps IBM's order (code page 037; THRU and the unnamed characters in EBCDIC native order) and GnuCOBOL's (its own EBCDIC table, measured over all 256 bytes; the data's bytes), sorts by IBM's, and stops the run by name on a pair the two order differently (register D1). Every neighbour pair is checked after the sort, whichever pairs TimSort compared. - Refused by name: an alphabet ordinal, HIGH-VALUE / LOW-VALUE in an alphabet, a key holding numeric / national items under an alphabet. - program.alphabets keeps each definition's tokens, not its first word. Proof: SORTCS (EBCDIC and a literal alphabet over alphanumeric, descending group, numeric + edited and edited keys) and SORTPC (PROGRAM COLLATING SEQUENCE) equal GnuCOBOL's output in bytes, typed and groups modes; runtime refusal tests for an EBCDIC and a literal-alphabet disagreement. Register F4 updated: the SORT verbs are translated; JCL utility steps stay refused by name (JclSteps.utility) and are the next slice. Part of #4268 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01W3KVtYHQp8KsfKcHsdiPbR
# Conflicts: # tests/cobol_mainframe/test_det_programs.py
Contributor
squid-protocol
marked this pull request as ready for review
October 6, 2026 06:53
This was referenced Oct 6, 2026
Merged
squid-protocol
added a commit
that referenced
this pull request
Oct 6, 2026
…4539) (#4556) The det translator compared alphanumeric operands in byte order whatever the program's PROGRAM COLLATING SEQUENCE, silently. Now, under an EBCDIC or a literal alphabet (#4540's Sort.Collating): - The nonnumeric comparisons of IF, EVALUATE (conditions and THRU ranges), PERFORM UNTIL and condition-names (88 THRU ranges) go through Sort.Collating.relation: the shorter operand padded with spaces, IBM's order taken, operands IBM and GnuCOBOL order differently stopped by name (register D1). Items, literals, figurative constants, typed (lifted) items and function results alike. - Numeric comparisons stay by value; national data is refused by the translator already. NATIVE / STANDARD-1 / STANDARD-2 stay byte order. - An equality consults the alphabet only when it has ALSO (otherwise each character has its own position). - Refused by name: HIGH-VALUE / LOW-VALUE under a literal alphabet (MOVE, VALUE -- the program --, comparisons, DISPLAY, STRING, INSPECT), an ordering of an item holding packed / binary / signed items, a comparison with an ALL literal, an ordinal alphabet. Proof: PCSEB (EBCDIC), PCSLT (a literal alphabet with ALSO and descending THRU), PCSS2 (STANDARD-2) and PCSRV (the issue's repro) equal GnuCOBOL's output in bytes, typed and groups modes; on origin/main PCSEB, PCSLT and PCSRV differ. Refusal tests at translation and run time. Closes #4539 Claude-Session: https://claude.ai/code/session_01W3KVtYHQp8KsfKcHsdiPbR Co-authored-by: Claude Opus 5.5 <[email protected]>
This was referenced Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of #4268 (COBOL statement side; the SORT / MERGE / RELEASE / RETURN parsers and SD files already landed in #4286).
What this adds
The det translator refused every SORT / MERGE
COLLATING SEQUENCE(andPROGRAM COLLATING SEQUENCE) other than NATIVE / STANDARD-1. Now:STANDARD-2 uses the data's byte order, the same as STANDARD-1 (GnuCOBOL measured identical over all 256 bytes).
ALPHABET x IS EBCDICand literal alphabets (literals, multi-character literals, ascending or descending THRU, ALSO, SPACE / ZERO / QUOTE) now order the alphanumeric keys (alphanumeric, alphabetic, edited and all-character groups) through the newcobolrt/Sort.Collating. Numeric keys (zoned, packed, binary, signed) still compare by value, as IBM and GnuCOBOL both do.Two orders, one answer.
Sort.Collatingkeeps IBM's order and GnuCOBOL's:[ ] ^ |and every byte above X'7F'. For literal alphabets it follows the data's bytes.The port sorts by IBM's order. If the two orders put a pair of keys in different order, the run stops with a named error (register D1). Every neighbouring pair is re-checked after the sort, so a proven sort is IBM's order.
Refused with a named error: alphabet ordinals (numeric literals), HIGH-VALUE / LOW-VALUE in an alphabet, and a key that holds numeric or national items under an alphabet (packed and binary bytes aren't characters).
program.alphabetsnow keeps each definition's tokens, not just the first word.Proof (GnuCOBOL oracle,
cobc -std=ibm -fsign=EBCDIC)SORTCS: EBCDIC and a literal alphabet over:SORTPC: PROGRAM COLLATING SEQUENCE applied to a SORT that has no COLLATING phrase.^) and one literal-alphabet disagreement (unnamedAvsz). Translate-time refusals are tested too, along with a parser unit test.SORTIPandSORTUG(USING/GIVING, input/output procedures, multiple keys, descending, duplicates, packed/signed/binary keys, MERGE).WRITE ADVANCING), and ST3014 has no holes.Gates
pr_gates.py: 7/7 pass.pr_gates.py --ratchets: 6/6 pass (ports, port-surface, estate, fact-crosscheck, completeness, ground-truth), none skipped.proof_sweep.py --det-only --skip-db2: as expected; the baseline is unchanged.Register
Next slice (out of scope here)
JCL utility steps, refused by name today (
JclSteps.utility):Found on the way
#4539: the det translator ignores PROGRAM COLLATING SEQUENCE in alphanumeric relation conditions, silently (repro in the issue).
🤖 Generated with Claude Code
https://claude.ai/code/session_01W3KVtYHQp8KsfKcHsdiPbR