Implements the Trim pattern detection logic for carrier promotion:
- find_definition_in_body(): Iterative AST traversal to locate variable definitions
- is_substring_method_call(): Detects substring() method calls
- extract_equality_literals(): Extracts string literals from OR chains (ch == " " || ch == "\t")
- TrimPatternInfo: Captures detected pattern details for carrier promotion
This enables Pattern 5 to detect trim-style loops:
```hako
loop(start < end) {
local ch = s.substring(start, start+1)
if ch == " " || ch == "\t" || ch == "\n" || ch == "\r" {
start = start + 1
} else {
break
}
}
```
Unit tests cover:
- Simple and nested definition detection
- substring method call detection
- Single and chained equality literal extraction
- Full Trim pattern detection with 2-4 whitespace characters
Next: Phase 171-C-3 integration with Pattern 2/4 routing
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Nyash Development Documentation 🔧
開発者向けの進行中タスクと開発計画ドキュメントです。
📂 ディレクトリ構造
current/
CURRENT_TASK.md- 現在進行中のタスク- アクティブな開発作業の詳細
- 最新の実装状況
roadmap/
- phases/ - フェーズ別開発計画
- phase-8/ - AST→MIR変換
- phase-9/ - VM/JIT実装
- phase-10/ - AOT最適化
- native-plan/ - ネイティブビルド計画
- 実行バックエンド統合
- パフォーマンス目標
proposals/
- RFC(Request for Comments)
- 新機能提案
- 設計ディスカッション
🎯 重要な参照先
- 進行状況:
current/CURRENT_TASK.md - 開発計画:
roadmap/phases/ - 技術提案:
proposals/
📝 注意事項
このディレクトリの内容は開発中であり、頻繁に変更されます。
安定した仕様はreference/を参照してください。