Phase 21.3 WIP: Hako Source Checker improvements

## 🎯 Checker/Analyzer拡張

###  実装追加
- テストフレームワーク追加(tools/hako_check/tests/)
- ルール改善(HC003グローバルassign、HC040静的箱トップレベルassign)
- テストランナー(run_tests.sh)

### 🔧 Rust側修正
- AST utilities拡張(src/ast/utils.rs)
- MIR lowerers新設(src/mir/lowerers/)
- Parser制御フロー改善(src/parser/statements/control_flow.rs)
- Tokenizer識別子処理改善(src/tokenizer/lex_ident.rs)

### 📁 主要変更
- tools/hako_check/cli.hako - CLI改善
- tools/hako_check/hako_source_checker.hako - Checker core更新
- tools/hako_check/tests/ - NEW (テストケース追加)
- tools/hako_check/run_tests.sh - NEW (テストランナー)
- src/mir/lowerers/ - NEW (MIR lowering utilities)

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-07 21:04:01 +09:00
parent b8fbbafc0c
commit 86489ffe43
20 changed files with 547 additions and 165 deletions

View File

@ -12,6 +12,8 @@ impl ASTNode {
ASTNode::Print { .. } => "Print",
ASTNode::If { .. } => "If",
ASTNode::Loop { .. } => "Loop",
ASTNode::While { .. } => "While",
ASTNode::ForRange { .. } => "ForRange",
ASTNode::Return { .. } => "Return",
ASTNode::Break { .. } => "Break",
ASTNode::Continue { .. } => "Continue",
@ -62,6 +64,8 @@ impl ASTNode {
ASTNode::FunctionDeclaration { .. } => ASTNodeType::Structure,
ASTNode::If { .. } => ASTNodeType::Structure,
ASTNode::Loop { .. } => ASTNodeType::Structure,
ASTNode::While { .. } => ASTNodeType::Structure,
ASTNode::ForRange { .. } => ASTNodeType::Structure,
ASTNode::TryCatch { .. } => ASTNodeType::Structure,
// Expression nodes - 値を生成する表現
@ -140,6 +144,20 @@ impl ASTNode {
} => {
format!("Loop({} statements)", body.len())
}
ASTNode::While {
condition: _, body, ..
} => {
format!("While({} statements)", body.len())
}
ASTNode::ForRange {
var_name,
start: _,
end: _,
body,
..
} => {
format!("ForRange(var={}, {} statements)", var_name, body.len())
}
ASTNode::Return { value, .. } => {
if value.is_some() {
"Return(with value)".to_string()
@ -329,6 +347,8 @@ impl ASTNode {
ASTNode::Print { span, .. } => *span,
ASTNode::If { span, .. } => *span,
ASTNode::Loop { span, .. } => *span,
ASTNode::While { span, .. } => *span,
ASTNode::ForRange { span, .. } => *span,
ASTNode::Return { span, .. } => *span,
ASTNode::Break { span, .. } => *span,
ASTNode::Continue { span, .. } => *span,