feat(parser): Phase 152-A - Grouped assignment expression (箱化モジュール化)

Implement Stage-3 grouped assignment expression `(x = expr)` following
the 箱化モジュール化 (modular box) pattern established in Phase 133/134.

**Implementation**:
- AssignmentExprParser module (Rust: 183 lines)
  - src/parser/stage3/assignment_expr_parser.rs (+183 lines)
  - src/parser/stage3/mod.rs (+9 lines)
- AST node addition: GroupedAssignmentExpr
  - src/ast.rs (+7 lines)
  - src/ast/utils.rs (+9 lines)
- MIR lowering via 1-line delegation
  - src/mir/builder/exprs.rs (+5 lines)
  - src/mir/builder/vars.rs (+4 lines)
- Parser integration via 1-line delegation
  - src/parser/expr/primary.rs (+6 lines)
  - src/parser/mod.rs (+1 line)

**Test Results**: 3/3 PASS
- assignment_expr_simple.hako: RC 1 
- assignment_expr_shortcircuit.hako: RC 1 
- shortcircuit_and_phi_skip.hako: RC 1  (updated to use expression context)

**Stage-3 Gate**: No impact on Stage-2/legacy
- NYASH_FEATURES=stage3 required
- Pattern: '(' IDENT '=' expr ')'
- Value/type same as rhs, side effect assigns to lhs

**箱化モジュール化パターン**:
- Dedicated module for assignment expression parsing
- Clear responsibility separation
- 1-line delegation for integration
- Testability improvement
- Follows Phase 133/134-A/134-B pattern

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-04 13:32:58 +09:00
parent a7f5da658a
commit c70e76ff57
11 changed files with 240 additions and 1 deletions

View File

@ -52,6 +52,8 @@ impl ASTNode {
ASTNode::MapLiteral { .. } => "MapLiteral",
// Optional diagnostic-only wrapper
ASTNode::ScopeBox { .. } => "ScopeBox",
// Phase 152-A: Grouped assignment expression
ASTNode::GroupedAssignmentExpr { .. } => "GroupedAssignmentExpr",
}
}
@ -91,6 +93,8 @@ impl ASTNode {
ASTNode::ArrayLiteral { .. } => E,
ASTNode::MapLiteral { .. } => E,
ASTNode::AwaitExpression { .. } => E,
// Phase 152-A: Grouped assignment expression (expression with side effect)
ASTNode::GroupedAssignmentExpr { .. } => E,
// Statement nodes - 実行可能なアクション
ASTNode::Program { .. } => S,
@ -330,6 +334,10 @@ impl ASTNode {
format!("Index(target={:?}, index={:?})", target, index)
}
ASTNode::ScopeBox { .. } => "ScopeBox".to_string(),
// Phase 152-A: Grouped assignment expression
ASTNode::GroupedAssignmentExpr { lhs, .. } => {
format!("GroupedAssignmentExpr(lhs={})", lhs)
}
}
}
@ -380,6 +388,8 @@ impl ASTNode {
ASTNode::ArrayLiteral { span, .. } => *span,
ASTNode::MapLiteral { span, .. } => *span,
ASTNode::ScopeBox { span, .. } => *span,
// Phase 152-A: Grouped assignment expression
ASTNode::GroupedAssignmentExpr { span, .. } => *span,
}
}
}