//! Pattern lowerers for different loop constructs
//!
//! Phase 2: Extracted from control_flow.rs
//! - Pattern 1: Simple While Loop (pattern1_minimal.rs)
//! - Pattern 2: Loop with Conditional Break (pattern2_with_break.rs)
//! - Pattern 3: Loop with If-Else PHI (pattern3_with_if_phi.rs)
//! - Pattern 4: Loop with Continue (pattern4_with_continue.rs) [Phase 194+]
//!
//! Phase 194: Table-driven router for pattern dispatch
//! - Router module provides table-driven pattern matching
//! - Each pattern exports can_lower() and lower() functions
//! - See router.rs for how to add new patterns
//!
//! Phase 193: AST Feature Extraction Modularization
//! - ast_feature_extractor.rs: Pure function module for analyzing loop AST
//! - High reusability for Pattern 5-6 and pattern analysis tools
//!
//! Phase 193-4 / Phase 222.5-C: Exit Binding Builder
//! - exit_binding.rs: Fully boxified exit binding generation (orchestrator)
//! - exit_binding_validator.rs: CarrierInfo and ExitMeta validation
//! - exit_binding_constructor.rs: Exit binding construction and ValueId allocation
//! - exit_binding_applicator.rs: Boundary application logic
//! - Eliminates hardcoded variable names and ValueId assumptions
//! - Supports both single and multi-carrier loop patterns
//!
//! Phase 33-22: Common Pattern Infrastructure
//! - common_init.rs: CommonPatternInitializer for unified initialization
//! - conversion_pipeline.rs: JoinIRConversionPipeline for unified conversion flow
//!
//! Phase 171-172: Refactoring Infrastructure
//! - loop_scope_shape_builder.rs: Unified LoopScopeShape initialization (Issue 4)
//! - condition_env_builder.rs: Unified ConditionEnv construction (Issue 5)
//!
//! Phase 33-23: Pattern-Specific Analyzers (Stage 2)
//! - pattern4_carrier_analyzer.rs: Pattern 4 carrier analysis and normalization (Issue 2)
//!
//! Stage 3 + Issue 1: Trim Pattern Extraction
//! - trim_pattern_validator.rs: Trim pattern validation and whitespace check generation
//! - trim_pattern_lowerer.rs: Trim-specific JoinIR lowering
//!
//! Phase 179-B: Generic Pattern Framework
//! - pattern_pipeline.rs: Unified preprocessing pipeline for Patterns 1-4
//!
//! Phase 91 P5b: Escape Pattern Recognizer
//! - escape_pattern_recognizer.rs: P5b (escape sequence handling) pattern detection
//! - Extracted from ast_feature_extractor for improved modularity
//!
//! Phase 93/94: Pattern Policies
//! - policies/: Pattern recognition and routing decision (future expansion)
//! - Currently a placeholder directory for future policy box organization
//!
//! Phase 255 P2: Common Utilities
//! - common/: Shared helper functions (var() etc.) to eliminate code duplication

#![allow(dead_code)]

pub(in crate::mir::builder) mod common; // Phase 255 P2: Common AST helpers
pub(in crate::mir::builder) mod extractors; // Phase 282 P3: Common extraction interfaces
pub(in crate::mir::builder) mod pattern_recognizers; // Phase 287 P1: Modularized pattern recognizers
pub(in crate::mir::builder) mod ast_feature_extractor;
pub(in crate::mir::builder) mod policies; // Phase 93/94: Pattern routing policies (future expansion)
pub(in crate::mir::builder) mod body_local_policy; // Phase 92 P3: promotion vs slot routing
pub(in crate::mir::builder) mod escape_pattern_recognizer; // Phase 91 P5b
pub(in crate::mir::builder) mod common_init;
pub(in crate::mir::builder) mod loop_true_counter_extractor; // Phase 104: loop(true) counter extraction for Pattern2
pub(in crate::mir::builder) mod read_digits_break_condition_box; // Phase 104: break cond normalization for read_digits(loop(true))
pub(in crate::mir::builder) mod pattern2; // Phase 263 P0.2: Pattern2 module (api/ SSOT entry point)
pub(in crate::mir::builder) mod pattern2_break_condition_policy_router; // Phase 105: policy router box for Pattern2 break condition
pub(in crate::mir::builder) mod pattern2_policy_router; // Phase 108: unified Pattern2 policy router (balanced/read_digits/default)
pub(in crate::mir::builder) mod pattern2_inputs_facts_box; // Phase 105: Pattern2 input facts (analysis only)
pub(in crate::mir::builder) mod pattern2_lowering_orchestrator; // Phase 105: Pattern2 orchestration (wiring/emission)
pub(in crate::mir::builder) mod pattern2_steps; // Phase 106: Pattern2 step boxes (pipeline SSOT)
pub(in crate::mir::builder) mod condition_env_builder;
pub(in crate::mir::builder) mod conversion_pipeline;
pub(in crate::mir::builder) mod exit_binding;
pub(in crate::mir::builder) mod exit_binding_applicator; // Phase 222.5-C
pub(in crate::mir::builder) mod exit_binding_constructor; // Phase 222.5-C
pub(in crate::mir::builder) mod exit_binding_validator; // Phase 222.5-C
pub(in crate::mir::builder) mod loop_scope_shape_builder;
pub(in crate::mir::builder) mod pattern1_minimal;
pub(in crate::mir::builder) mod pattern2_with_break;
pub(in crate::mir::builder) mod pattern3_with_if_phi;
pub(in crate::mir::builder) mod pattern4_carrier_analyzer;
pub(in crate::mir::builder) mod pattern4_with_continue;
pub(in crate::mir::builder) mod pattern6_nested_minimal; // Phase 188.3: 1-level nested loop (Pattern1 outer + Pattern1 inner)
pub(in crate::mir::builder) mod pattern6_scan_with_init; // Phase 254 P0: index_of/find/contains pattern
pub(in crate::mir::builder) mod pattern7_split_scan; // Phase 256 P0: split/tokenization with variable step
pub(in crate::mir::builder) mod pattern8_scan_bool_predicate; // Phase 259 P0: boolean predicate scan (is_integer/is_valid)
pub(in crate::mir::builder) mod pattern9_accum_const_loop; // Phase 270 P1: accumulator const loop (橋渡しパターン)
pub(in crate::mir::builder) mod pattern_pipeline;
pub(in crate::mir::builder) mod router;
pub(in crate::mir::builder) mod trim_loop_lowering; // Phase 180: Dedicated Trim/P5 lowering module
pub(in crate::mir::builder) mod trim_pattern_lowerer;
pub(in crate::mir::builder) mod trim_pattern_validator;

// Re-export router for convenience
pub(in crate::mir::builder) use router::{route_loop_pattern, LoopPatternContext};

// Phase 140-P4-A: Re-export for loop_canonicalizer SSOT (crate-wide visibility)
pub(crate) use ast_feature_extractor::detect_skip_whitespace_pattern;

// Phase 104: Re-export read_digits(loop(true)) detection for loop_canonicalizer
pub(crate) use ast_feature_extractor::detect_read_digits_loop_true_pattern;

// Phase 142-P1: Re-export continue pattern detection for loop_canonicalizer
pub(crate) use ast_feature_extractor::detect_continue_pattern;

// Phase 143-P0: Re-export parse_number pattern detection for loop_canonicalizer
pub(crate) use ast_feature_extractor::detect_parse_number_pattern;

// Phase 143-P1: Re-export parse_string pattern detection for loop_canonicalizer
pub(crate) use ast_feature_extractor::detect_parse_string_pattern;

// Phase 91 P5b: Re-export escape skip pattern detection for loop_canonicalizer
pub(crate) use ast_feature_extractor::detect_escape_skip_pattern;
