Skip to content

fix(det): re-wrap joined continuation lines to fixed form for the parser (#4412) - #4433

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

squid-protocol merged 6 commits into
mainfrom
fix/4412-det-rewrap

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Closes #4412. Stacked on #4432 (#4411). This branch contains #4432's two commits, so review only the last commit. It targets main so that CI runs; once #4432 merges, the diff shrinks to this change.

Change (about 30 lines of logic, as #4378's bake-off comment describes)

  • det/source.as_fixed_rows: a line longer than columns 8-72 (a joined continuation) is wrapped back into fixed form. It splits at a space outside literals; a literal still open at column 72 continues on the next row with - in column 7 and the quote again in column 10. The function also returns a row map to the expanded lines. as_fixed returns its text. unwrap joins the continuations again.
  • det/stmt.parse: origin() maps parser rows through the row map. Statement, EXEC and SORT text is unwrapped before the hand parsers read it.
  • det/layout: _txt strips the continuation markers. One fix beyond the bake-off prototype: the grammar's string node for a continued literal covers only its last row's piece, so on the prototype a 99-character VALUE decoded as its final 33 characters. _literal_start starts the literal at the quote still open on its first row. Item lines and DATA errors map through the row map.

Evidence

Ported programs: parser input byte-identical. No ported program has a line past column 72. The bytes fed to tree-sitter by layout.parse and stmt.parse, hashed per program, are identical for 54/54. det_port.py check against #4432's translation gives 55/55 ports unchanged.

Parse coverage. Measured with the translator's own front end on the #4378 bake-off corpora: DATA and PROC parsed with no ERROR region, the bake-off's criterion.

corpus before after bake-off predicted
ported (54) 54 54 54
unported (149) 118 131 119 → 131
NIST CCVS85 (150) 39 143 39 → 142
estate-crucible (40 today) 25 25 —

No program lost its parse. Every re-wrapped VALUE literal decodes verbatim: 355/355, checked against the joined source line.

Newly parsed programs: refuse vs translate. 117 programs are newly parsed: 13 unported, which are all NIST copies in the robust-src set, plus 104 NIST. All are batch; none uses CICS.

  • 6 refused whole, all with no open EVALUATE: a SEARCH … WHEN, whose WHEN the walker reads as an EVALUATE's. This is a translator gap that predates this change.

  • 111 translated with statement holes, none clean. Top hole reasons (programs):

    • WRITE … ADVANCING: 111. Every NIST program writes its print file with it.
    • an index name (INDEXED BY) taken for a data item (SET/MOVE/IF … no such item): 60+;
    • DECLARATIVES: 20;
    • COMPUTE … ALL: 9;
    • PERFORM VARYING … AFTER: 6.

    The translation was run with a placeholder stub and no generated project. So "no repository for this file" holes on file I/O are left out of these counts: they are an artefact of the measurement setup.

Known gap, not chased. Single-quoted continued literals still fail (CardDemo CBSTM03A: DATA DIVISION does not parse).

Tests (72 pass):

  • lines within column 72 are byte-identical, with an identity row map;
  • a long line re-wraps to rows of at most 72 characters and unwraps to itself;
  • a re-wrapped VALUE literal and a statement literal decode verbatim, and statement lines survive the row map;
  • a parse-rate regression test on NIST CCVS85 from the language-crucible: at least 130 of 150 through the front end, 136 today, 37 on fix(det): refuse accepted-but-ignored CICS options and swallowed parse errors (#4411) #4432.

Gates: pr_gates.py --fast 5/5 pass. Coordination: nothing under the crucible ports, the harness or the evidence tooling is touched (#4425). #4349 (#4342) works in the same area and is paused.

🤖 Generated with Claude Code

squid-protocol and others added 5 commits October 5, 2026 07:02
…e errors (#4411)

The det translator now refuses, by name, what it used to accept and ignore:

- det/cics.OPTIONS lists the options each modelled EXEC CICS command honours;
  any other option is a hole ("<verb> <opt>: option not modelled"): RETURN
  IMMEDIATE, READ GTEQ / GENERIC, STARTBR / READNEXT / ENDBR GENERIC / REQID,
  LINK SYNCONRETURN / DATALENGTH / SYSID, ASSIGN beyond its five, FORMATTIME
  forms it does not write, RECEIVE MAP ASIS, READQ TS SET, a TD option read
  as TS, SEND TEXT CURSOR(value) ...
- KEYLENGTH only as the file's full key, a known value on a known file;
  READ / READNEXT / READPREV LENGTH only as the INTO area's own length.
- det/stmt.parse: an ERROR / MISSING node outside the PROCEDURE DIVISION node
  refuses the program (it had dropped whole paragraphs: ENTRY ... USING in
  DBUNLDGS / PAUDBLOD / PAUDBUNL); one nested in a statement is a hole, in an
  IF / EVALUATE / WHEN header an unparsed condition.
- det/layout.parse: an ERROR / MISSING inside a data entry, and an unquoted
  VALUE word that is no number, refuse instead of being read as text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…arser (#4412)

det/source.as_fixed kept a joined continuation as one line past column 72,
which the tree-sitter COBOL grammar fails on. as_fixed_rows now wraps such a
line back into fixed form (split at a space outside literals, or a literal
continued with '-' in column 7 and the quote again in column 10) and returns
a row map to the expanded lines:

- det/stmt.parse: origin() maps parser rows through the row map; statement,
  EXEC and SORT text has the continuation markers joined again (unwrap).
- det/layout: _txt joins them too, and a continued literal's string node (to
  the grammar only its last row's piece) starts at the quote still open on its
  first row; item lines and errors map through the row map.

Lines within column 72 reach the parser byte-identical, so all 54 det-ported
programs' parser input is unchanged (det_port.py check: 55/55 ports
unchanged). #4378 bake-off corpora: unported 118 -> 131 of 149, NIST CCVS85
39 -> 143 of 150; all 355 re-wrapped VALUE literals decode verbatim.
Single-quoted continuations (CardDemo CBSTM03A) still fail: a separate shape.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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

Imports: union of #4412's as_fixed_rows/unwrap and #4430's cobol_parser.
Error lines keep #4412's line_of row map. Tests: keep both blocks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VrujbRefDqQ8ptAwTBQTaz
@squid-protocol
squid-protocol marked this pull request as ready for review October 5, 2026 12:19
@squid-protocol
squid-protocol merged commit a651776 into main Oct 5, 2026
38 checks passed
@squid-protocol
squid-protocol deleted the fix/4412-det-rewrap branch October 5, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

det translator: re-wrap joined continuation lines to fixed form in det/source.as_fixed (recovers most parse failures)

2 participants