Bug #1: AND compound branch-body MOVE not propagated (HIGH)
Root cause: ELSE on same line as false_body, rest of line lost after
self.advance(). Fix: reinsert ELSE body text same as ELSE IF does.
Result: MOVE 'Y'/'N' TO WS-FLAG correctly propagated, all 3 paths
verified (A<=10/B<20=F, A>10/B<20=T, A>10/B>=20=F).
Bug #2: Performance — path explosion (25 IFs = 47s, 10000 records)
Root cause: BrSeq inner loop combined all paths before capping.
Fix: early break at _MAX_PATHS in the combo loop.
+ _MAX_PATHS reduced from 10000 to 500.
Result: 47s/10000rec -> 0.2s/27rec (235x improvement)
Bug #3: COPY+REDEFINES parse failure (test-only)
Root cause: test code called parse_data_division on full source
instead of extract_data_division first. Fixed.
Real pipeline (extract_structure -> generate_data) was never affected.
Co-Authored-By: Claude <noreply@anthropic.com>
Root cause: IF condition and EVALUATE WHEN parsing swallowed entire
line including THEN-body (e.g. '50 MOVE BIG...' instead of just '50').
Fix:
1. Single-line IF cond_text truncated at COBOL statement-starting keywords
(MOVE/DISPLAY/COMPUTE/ADD/...)
2. Multi-line IF continuation loop also breaks on these keywords (was
missing DISPLAY, READ, WRITE, CLOSE, OPEN, SEARCH, ...)
3. EVALUATE WHEN raw_val truncated at same keyword set
4. All raw-string escape sequences fixed (Python 3.12 SyntaxWarning)
Verification:
- IF single-line A>50: A=51(true)/12(false) previously A=01/00
- IF multi-line X>50: X=51(true)/12(false) previously not steered
- EVALUATE WHEN 1/2/OTHER: C=1/2/4 previously C=0/0/0
- IF AND compound: (A<=10,B<20), (A>10,B<20), (A>10,B>=20)
- IF >75: A=76(true)/12(false) previously not steered
R11 tests updated: BUG documentation replaced with real assertions.
13 suites / 0 FAIL.
Co-Authored-By: Claude <noreply@anthropic.com>
Bug 1: ELSE IF breaks IF false_seq parsing (core.py)
- _parse_if checked self.clean() == 'ELSE' which fails on 'ELSE IF ...'
- Fix: use startswith('ELSE'), reinsert IF portion for recursive parse
- Impact: ALL ELSE IF chains were silently dropped (huge branch loss)
Bug 2: READ skip loop greedily consumes subsequent statements (core.py)
- READ's AT END / NOT AT END skip loop used bare advance() with no
statement boundary detection
- Fix: add _stmt_boundary regex that stops on IF/PERFORM/READ/etc.
- Impact: everything after first READ was consumed as 'AT END' lines
Bug 3: _walk() in extract_structure doesn't descend into BrPerform (__init__.py)
- Branch counting _walk() only handled BrIf/BrEval/BrSeq
- IF statements inside PERFORM bodies were never counted
- Fix: add BrPerform.body_seq and BrSearch descent
Combined impact: matching programs (MT01-33) now correctly report
their branches instead of 0. Full regression: 749 passed (unchanged).