Files
hakorune/tools/selfhost/test_pattern5b_escape_minimal.hako
nyash-codex 7e03cb6425 docs(phase-91): Update Phase 91 README with Step 2 completion status
### Updates

#### 1. Status Section
- Updated Status to reflect all completed steps (1, 2-A/B/D, 2-E)
- Documented parity verification success

#### 2. Completion Status Section (NEW)
- Added dedicated section for Phase 91 Step 2 completion
- Listed all deliverables with checkmarks
- Documented test results: 1062/1062 PASS

#### 3. Next Steps
- Clarified Phase 92 lowering requirements
- Updated timeline expectations

#### 4. Test Fixture Fix
- Fixed syntax error in test_pattern5b_escape_minimal.hako
  (field declarations: changed `console: ConsoleBox` to `console ConsoleBox`)

### Context

Phase 91 Step 2 is now fully complete:
-  AST recognizer (detect_escape_skip_pattern)
-  Canonicalizer integration (UpdateKind::ConditionalStep)
-  Unit tests (test_escape_skip_pattern_recognition)
-  Parity verification (strict mode green)

Ready for Phase 92 lowering implementation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-16 14:55:40 +09:00

60 lines
1.7 KiB
Plaintext

// Minimal Pattern P5b (Escape Handling) Test Fixture
// Purpose: Verify JoinIR Canonicalizer recognition of escape sequence patterns
//
// Pattern: loop(i < n) with conditional increment on escape character
// Carriers: i (position), out (accumulator)
// Exit: break on quote character
//
// This pattern is common in string parsing:
// - JSON string readers
// - CSV parsers
// - Template engines
// - Escape sequence handlers
static box Main {
console ConsoleBox
main() {
me.console = new ConsoleBox()
// Test data: string with escape sequence
// Original: "hello\" world"
// After parsing: hello" world
local s = "hello\\\" world"
local n = s.length()
local i = 0
local out = ""
// Pattern P5b: Escape sequence handling loop
// - Header: loop(i < n)
// - Escape check: if ch == "\\" { i = i + 1 }
// - Process: out = out + ch
// - Update: i = i + 1
loop(i < n) {
local ch = s.substring(i, i + 1)
// Break on quote (string boundary)
if ch == "\"" {
break
}
// Handle escape sequence: skip the escape char itself
if ch == "\\" {
i = i + 1 // Skip escape character (i increments by +2 total with final i++)
if i < n {
ch = s.substring(i, i + 1)
}
}
// Accumulate processed character
out = out + ch
i = i + 1 // Standard increment
}
// Expected output: hello" world (escape removed)
me.console.log(out)
return "OK"
}
}