feat: 改行処理Phase 1 Smart advance完全実装 - 深度追跡でskip_newlines削減開始
✨ Smart advance()による自動改行処理を実装 - depth_tracking.rsで括弧深度(paren/brace/bracket)を自動管理 - 括弧内では改行を自動スキップ、演算子後の行継続も自動判定 - デフォルトで有効化(NYASH_SMART_ADVANCE=0で無効化可能) ♻️ skip_newlines()の段階的削除を開始 - primary.rsのオブジェクトリテラル内8箇所を削除(48→40箇所、17%削減) - 深度追跡により手動skip_newlines()が不要に 🧪 テスト結果 - 文区切り、演算子行継続、括弧内改行、次行演算子すべて成功 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
mod common;
|
||||
mod cursor; // TokenCursor: 改行処理を一元管理
|
||||
mod declarations;
|
||||
mod depth_tracking; // Phase 1: 深度追跡機能(Smart advance用)
|
||||
pub mod entry_sugar; // helper to parse with sugar level
|
||||
mod expr;
|
||||
mod expr_cursor; // TokenCursorを使用した式パーサー(実験的)
|
||||
@ -138,22 +139,13 @@ pub struct NyashParser {
|
||||
std::collections::HashMap<String, std::collections::HashSet<String>>,
|
||||
/// 🔥 デバッグ燃料:無限ループ検出用制限値 (None = 無制限)
|
||||
pub(super) debug_fuel: Option<usize>,
|
||||
/// Phase 1: Smart advance用深度カウンタ(改行自動スキップ判定)
|
||||
pub(super) paren_depth: usize, // ()
|
||||
pub(super) brace_depth: usize, // {}
|
||||
pub(super) bracket_depth: usize, // []
|
||||
}
|
||||
|
||||
// Implement ParserUtils trait
|
||||
impl ParserUtils for NyashParser {
|
||||
fn tokens(&self) -> &Vec<Token> {
|
||||
&self.tokens
|
||||
}
|
||||
|
||||
fn current(&self) -> usize {
|
||||
self.current
|
||||
}
|
||||
|
||||
fn current_mut(&mut self) -> &mut usize {
|
||||
&mut self.current
|
||||
}
|
||||
}
|
||||
// ParserUtils trait implementation is in depth_tracking.rs
|
||||
|
||||
impl NyashParser {
|
||||
/// 新しいパーサーを作成
|
||||
@ -163,6 +155,9 @@ impl NyashParser {
|
||||
current: 0,
|
||||
static_box_dependencies: std::collections::HashMap::new(),
|
||||
debug_fuel: Some(100_000), // デフォルト値
|
||||
paren_depth: 0,
|
||||
brace_depth: 0,
|
||||
bracket_depth: 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user