Files
hakorune/apps/tests/phase210_match_literal_min.hako
nyash-codex d7805e5974 feat(joinir): Phase 213-2 Step 2-2 & 2-3 Data structure extensions
Extended PatternPipelineContext and CarrierUpdateInfo for Pattern 3 AST-based generalization.

Changes:
1. PatternPipelineContext:
   - Added loop_condition: Option<ASTNode>
   - Added loop_body: Option<Vec<ASTNode>>
   - Added loop_update_summary: Option<LoopUpdateSummary>
   - Updated build_pattern_context() for Pattern 3

2. CarrierUpdateInfo:
   - Added then_expr: Option<ASTNode>
   - Added else_expr: Option<ASTNode>
   - Updated analyze_loop_updates() with None defaults

Status: Phase 213-2 Steps 2-2 & 2-3 complete
Next: Create Pattern3IfAnalyzer to extract if statement and populate update summary
2025-12-10 00:01:53 +09:00

42 lines
1.1 KiB
Plaintext

// Phase 210: Pattern 1 (SimpleWhile) test - match literal implementation
// Tests: Simple loop without break/continue, early return only
// Target: _match_literal pattern from JsonParser
//
// Expected behavior:
// Compare "hello" with "hello" character by character
// If all match, return 1
// If any mismatch, return 0 (early return)
//
// Expected result: 1 (match success)
static box Main {
main() {
local s
s = "hello"
local literal
literal = "hello"
local pos
pos = 0
local len
len = 5
local i
i = 0
loop(i < len) {
// Character-by-character comparison
// Note: Using string equality instead of substring for simplicity
// Real _match_literal uses substring(pos+i, pos+i+1)
// Simplified: just check if we reach the end
// (full substring comparison would require StringBox.substring)
if i >= len {
return 0
}
i = i + 1
}
// If we exit loop normally, all characters matched
return 1
}
}