feat: 改行処理革命Phase 2-B完了 - Box宣言系skip_newlines()完全削除

 **41%削減達成**: 48→35→21箇所(14箇所削除)
- fields.rs: 9箇所のskip_newlines()削除
- box_definition.rs: 3箇所削除
- static_box.rs: 2箇所削除

 **Smart advance()実用化**: 深度追跡で自動改行処理完璧機能
- Box宣言、match式OR、複数行構文すべて対応
- NYASH_SMART_ADVANCE=1で安定動作確認

🔧 **ORパターンバグ同時修正**: exprs_peek.rsでInteger/Boolean型マッチング実装
- 修正前: 1 | 2 => "found" が動作せず(String型のみ)
- 修正後: 全リテラル型(Integer/Bool/Float/Null/Void)完全対応

🎉 **技術的価値**: 手動skip依存→コンテキスト認識自動処理への移行成功

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Selfhosting Dev
2025-09-23 11:22:16 +09:00
parent 536e64441a
commit ad62066172
5 changed files with 45 additions and 54 deletions

View File

@ -40,7 +40,6 @@ pub(crate) fn try_parse_header_first_field_or_property(
p.advance();
let _init_expr = p.parse_expression()?; // P0: parse and discard
fields.push(fname);
p.skip_newlines();
return Ok(true);
}
// name: Type => expr → computed property (getter method with return expr)
@ -61,7 +60,6 @@ pub(crate) fn try_parse_header_first_field_or_property(
span: Span::unknown(),
};
methods.insert(getter_name, method);
p.skip_newlines();
return Ok(true);
}
// name: Type { ... } [postfix]
@ -78,7 +76,6 @@ pub(crate) fn try_parse_header_first_field_or_property(
span: Span::unknown(),
};
methods.insert(getter_name, method);
p.skip_newlines();
return Ok(true);
}
}
@ -108,7 +105,6 @@ pub(crate) fn try_parse_visibility_block_or_single(
}
if p.match_token(&TokenType::LBRACE) {
p.advance();
p.skip_newlines();
while !p.match_token(&TokenType::RBRACE) && !p.is_at_end() {
if let TokenType::IDENTIFIER(fname) = &p.current_token().token_type {
let fname = fname.clone();
@ -116,7 +112,6 @@ pub(crate) fn try_parse_visibility_block_or_single(
fields.push(fname);
p.advance();
if p.match_token(&TokenType::COMMA) { p.advance(); }
p.skip_newlines();
continue;
}
return Err(ParseError::UnexpectedToken {
@ -126,7 +121,6 @@ pub(crate) fn try_parse_visibility_block_or_single(
});
}
p.consume(TokenType::RBRACE)?;
p.skip_newlines();
return Ok(true);
}
if let TokenType::IDENTIFIER(n) = &p.current_token().token_type {
@ -135,12 +129,10 @@ pub(crate) fn try_parse_visibility_block_or_single(
if try_parse_header_first_field_or_property(p, fname.clone(), methods, fields)? {
if visibility == "public" { public_fields.push(fname.clone()); } else { private_fields.push(fname.clone()); }
*last_method_name = None;
p.skip_newlines();
return Ok(true);
} else {
if visibility == "public" { public_fields.push(fname.clone()); } else { private_fields.push(fname.clone()); }
fields.push(fname);
p.skip_newlines();
return Ok(true);
}
}
@ -160,7 +152,6 @@ pub(crate) fn parse_init_block_if_any(
p.advance(); // consume 'init'
p.consume(TokenType::LBRACE)?;
while !p.match_token(&TokenType::RBRACE) && !p.is_at_end() {
p.skip_newlines();
if p.match_token(&TokenType::RBRACE) {
break;
}

View File

@ -116,7 +116,6 @@ impl NyashParser {
box_header::parse_header(self)?;
self.consume(TokenType::LBRACE)?;
self.skip_newlines(); // ブレース後の改行をスキップ
let mut fields = Vec::new();
let mut methods = HashMap::new();
@ -130,7 +129,6 @@ impl NyashParser {
let mut last_method_name: Option<String> = None;
while !self.match_token(&TokenType::RBRACE) && !self.is_at_end() {
self.skip_newlines(); // ループ開始時に改行をスキップ
// 分類(段階移行用の観測): 将来の分岐移譲のための前処理
if crate::config::env::parser_stage3() {
if let Ok(kind) = crate::parser::declarations::box_def::members::common::classify_member(self) {
@ -189,7 +187,6 @@ impl NyashParser {
&mut birth_once_props,
)? {
last_method_name = None; // do not attach method-level postfix here
self.skip_newlines();
continue;
}
}

View File

@ -18,7 +18,6 @@ impl NyashParser {
crate::parser::declarations::static_def::header::parse_static_header(self)?;
self.consume(TokenType::LBRACE)?;
self.skip_newlines(); // ブレース後の改行をスキップ
let mut fields = Vec::new();
let mut methods = HashMap::new();
@ -30,7 +29,6 @@ impl NyashParser {
// Track last inserted method name to allow postfix catch/cleanup fallback parsing
let mut last_method_name: Option<String> = None;
while !self.match_token(&TokenType::RBRACE) && !self.is_at_end() {
self.skip_newlines(); // ループ開始時に改行をスキップ
// Fallback: method-level postfix catch/cleanup immediately following a method
if crate::parser::declarations::box_def::members::postfix::try_parse_method_postfix_after_last_method(