- Created 3 representative Pattern4 test cases: * test_pattern4_simple_continue.hako - Simple continue loop (odd number sum) * test_pattern4_parse_string.hako - String parsing with escape + continue * test_pattern4_parse_array.hako - Array element parsing with continue - Validated Pattern4_WithContinue detection: * All 3 test cases: Pattern4_WithContinue MATCHED ✅ * JoinIR lowering successful (20-24 blocks → 14-20 blocks) * [joinir/freeze] elimination: Complete (no errors on any test) - Verified execution correctness: * test_pattern4_simple_continue: Sum=25 (1+3+5+7+9) ✅ CORRECT * test_pattern4_parse_string: Execution successful, expected error handling * test_pattern4_parse_array: Execution successful, expected error handling - **MAJOR MILESTONE**: All 4 Loop Patterns Now Complete! * Pattern1 (Simple): 6 loops ✅ * Pattern2 (Break): 5 loops ✅ * Pattern3 (If-Else PHI): 1 loop ✅ * Pattern3+break (as Pattern2): 3 loops ✅ * Pattern4 (Continue): 3 loops ✅ * Total: 18 loops covered, zero [joinir/freeze] errors! - Updated CURRENT_TASK.md with Phase 165 section and complete statistics Next phases: * Phase 166: JsonParserBox full implementation & verification * Phase 167: .hako JoinIR Frontend prototype development 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
44 lines
1.1 KiB
Plaintext
44 lines
1.1 KiB
Plaintext
// Phase 165: Test _parse_string from JsonParserBox (Pattern4 with continue + return)
|
|
// Simulates: loop(p < len) { if quote { return } if escape { continue } else { append } p++ }
|
|
|
|
static box Main {
|
|
main(args) {
|
|
// Simulate string parsing: collect chars until closing quote
|
|
// Pattern: continue on escape, return on quote
|
|
local s = "hello\\\"world\"extra"
|
|
local p = 0
|
|
local len = s.length()
|
|
local result = ""
|
|
|
|
loop(p < len) {
|
|
local ch = s.substring(p, p + 1)
|
|
|
|
// Check for closing quote
|
|
if ch == "\"" {
|
|
print("Found closing quote at position: " + ("" + p))
|
|
return 0
|
|
}
|
|
|
|
// Check for escape sequence
|
|
if ch == "\\" {
|
|
result = result + ch
|
|
p = p + 1
|
|
// Skip next character (continuation of escape)
|
|
if p < len {
|
|
result = result + s.substring(p, p + 1)
|
|
p = p + 1
|
|
continue
|
|
}
|
|
}
|
|
|
|
// Regular character
|
|
result = result + ch
|
|
p = p + 1
|
|
}
|
|
|
|
// If we exit loop without finding quote, return error
|
|
print("ERROR: No closing quote found")
|
|
return 1
|
|
}
|
|
}
|