Repository navigation
Description
Why
The det COBOL-to-Java translator parses COBOL with the tree-sitter grammar from tree_sitter_language_pack (det/layout.py for the DATA DIVISION, det/stmt.py for statements). Its layouts are byte-proven against GnuCOBOL, so it works where it parses. But on 2026-10-03 the grammar failed on 31 of 149 unported programs (25 in the DATA DIVISION, 6 in the PROCEDURE DIVISION: long continued literals, *> comments, SEARCH ALL, IDMS; #4273's experiment comment). Before the 4th CICS estate (the "one-shot" attempt), we should know whether a better front end exists, and decide it with data rather than swap blindly. The translator is a proven system, so any switch has to prove it is at least as good on everything that already works.
Candidates
| Tool | License | Activity (Oct 2026) | What it is | Likely role |
|---|---|---|---|---|
| Eclipse Che4z COBOL LSP | EPL-2.0 (weak copyleft; fine as an external, unmodified test tool) | very active, Broadcom-backed | Industrial IBM Enterprise COBOL parser: CICS, SQL, IDMS, DaCo, copybook preprocessing | units, calls, CICS / SQL referee |
| mapa | MIT | active, single author | ANTLR grammars for IBM Z COBOL, CICS APIs/SPIs and JCL, plus a call-tree tool (CALL, LINK, XCTL, SQL CALL, program inputs/outputs) | network-map referee (call tree, CICS, JCL) |
| Spantree tree-sitter-cobol-enterprise | MIT | new (Apr 2026) | Tree-sitter grammar for IBM Enterprise COBOL; EXEC CICS / SQL parsed into typed nodes; 65/66 CardDemo files parse | parser referee; translator front-end candidate |
| ProLeap | MIT | stale (last release 2018) | ANTLR4 AST + semantic graph (data and control flow); passes NIST COBOL-85; EXEC blocks kept as text | data-flow referee |
| Cobrix | Apache-2.0 | active | Copybook parser + EBCDIC reader: COMP-3, OCCURS DEPENDING ON, REDEFINES | record-layout / byte-offset referee |
| cobol-rekt | MIT | active | Reverse-engineering toolkit: flowcharts, control-flow analysis | reachability / dead-code referee |
| TypeCobol | CeCILL-C (LGPL-like) | active | Incremental IBM Enterprise COBOL 6 parser (C#) | dialect-coverage reference |
| Not permissive: SuperBOL (AGPL), GnuCOBOL (GPL; already our oracle, run as a separate process) | leave as is |
The most natural drop-in is Spantree tree-sitter-cobol-enterprise: same tree-sitter API, IBM Enterprise COBOL, typed EXEC CICS / SQL nodes. The JVM parsers (Che4z, ProLeap, mapa) and TypeCobol would mean a bigger integration (a JVM or .NET bridge), offset by richer semantics (preprocessing, data / control flow).
Bake-off protocol (proposal)
- Corpus: the 149 programs where the current grammar failed or was never tried, the 54 det-ported programs, NIST CCVS85, and estate-crucible v0.3.0+ (incl. the multicultural / DBCS horrors).
- Per candidate, measure:
- parse success (clean / partial / failure) per division;
- no regression on the 54 ported programs: identical layouts (byte offsets, sizes, usages) and statement trees as today, proven by re-running the equivalence harness;
- coverage of what the translator needs: EXEC CICS / SQL as typed structures vs text, COPY / REPLACING (today
det/source.pyexpands it itself), nested / sibling programs, DECIMAL-POINT IS COMMA, national / DBCS (COBOL translator: national/DBCS data (USAGE NATIONAL, PIC N, DBCS literals) not modelled by the det port or the oracle register #4272); - speed per member (and memory, for ANTLR grammars on large members);
- integration cost: Python binding vs JVM / .NET bridge, CI cost, maintenance health and license.
- Decision table: keep, replace, or hybrid (e.g. one parser for layouts and another for statements, or a fallback chain when the primary fails).
Open questions (brainstorm here)
- Is a fallback chain better than a single replacement (try A, then B, refuse only if both fail)?
- Should the front end take the engine's facts (COBOL: engine-to-translator fact cross-check as a CI gate (and who owns each fact) #4273's ownership decision) for some channels once the engine passes the cross-check gate?
- A young grammar (Spantree, Apr 2026) vs a stale but NIST-proven one (ProLeap) vs an industrial LSP (Che4z): how do we weigh maintenance risk?
- If EXEC CICS / SQL become typed, which det-port features (COBOL translator: embedded SQL breadth (dynamic SQL, CALL, WHENEVER, CONNECT, scroll cursors, host-variable arrays, ROLLBACK) #4269 SQL breadth, COBOL translator: CICS command breadth (START/RETRIEVE, channels/containers, GETMAIN, LOAD, CONVERSE, INQUIRE, ASSIGN, counters, HANDLE ABEND PROGRAM) #4270 CICS breadth) get easier?
- Timing: run the bake-off now and decide after the 4th-estate attempt, or decide before it?
Related: #4273, #4268-#4272 (translator breadth), #4048 (evidence records: a front-end change must re-prove every port), the referee-panel issue (#4377).
🤖 Generated with Claude Code
Activity
squid-protocol commentedon Oct 5, 2026
Phase 1 bake-off: measured, no switch
Full report:
/srv/storage_16tb/projects/gitgalaxy/bakeoff/bakeoff.md+bakeoff.json(tooling inbakeoff/tools/, not committed). Engine575bba16a, language-pack 1.20.0 vs Spantree86a2c479cb7e, each fed the translator's own DATA / PROC inputs. Nothing undergitgalaxy/tools/cobol_to_java/changed.Programs usable (DATA and PROC both parse without ERROR)
current_w)current_w, else Spantreelayout.parsere-targeted to Spantree, about 215 lines) gives 0 diffs on the 54 ported programs: 16,794 items compared on offsets, sizes, usages, PIC, OCCURS / ODO, REDEFINES, VALUEs, 88s and SIGN, and all 54 record images are byte-identical. It is also at 0 diffs on 30,985 items across all four sets.MOVE ALL '9'(CUSTCTRL) andFUNCTION ANNUITYin an expression (epsmpmt).DECLARATIVES, which wrecks the whole PROCEDURE DIVISION (94 CCVS programs);PERFORM TEST AFTER VARYING;PIC IS, whereISis lexed into the picture (71 CCVS programs);RECORD n/LABEL RECORDS;ELSE,WHEN OTHER,END-x,AT END,THRU,ALLand the figurative constants never appear as nodes. So stmt.py's flat-stream walker would need a re-lexing flattening shim. Estimate: about 1 day for layout.py (the adapter is done), and 3–5 days for stmt.py plus re-proving all 54 ports. The stmt.py work is also blocked on the 6 ported PROC failures, which need grammar patches.det.source.as_fixedkeeps joined continuation lines whole past column 72. Re-wrapping them into proper fixed form (literal continuation with-) lets the current grammar parse 12 of the 30 failing unported programs and 103 of the 111 failing CCVS programs:Recommendation:
as_fixed, strip the continuation markers inlayout._txt, and add a row map instmt.origin. This is a follow-up ticket after paused PR WIP: Generator: no entry points or handlers with no COBOL behaviour behind them (#4342) #4349, since it is in that PR's area.🤖 Generated with Claude Code
squid-protocol commentedon Oct 5, 2026
Decision: keep the current tree-sitter grammar. Closing.
Phase 1 (full results in the comment above) measured:
MOVE ALL, DECLARATIVES).The real lever is the translator's own input: re-wrapping joined continuation lines into proper fixed form in
det/source.as_fixedraises current-grammar parses from 119 to 131 of 149 unported programs and from 39 to 142 of 150 NIST programs, with no change to ported-program input. That is tracked in #4412.Kept for later:
fix(det): re-wrap joined continuation lines to fixed form for the par…