chore: Phase 25.1 完了 - LoopForm v2/Stage1 CLI/環境変数削減 + Phase 26-D からの変更

Phase 25.1 完了成果:
-  LoopForm v2 テスト・ドキュメント・コメント完備
  - 4ケース(A/B/C/D)完全テストカバレッジ
  - 最小再現ケース作成(SSAバグ調査用)
  - SSOT文書作成(loopform_ssot.md)
  - 全ソースに [LoopForm] コメントタグ追加

-  Stage-1 CLI デバッグ環境構築
  - stage1_cli.hako 実装
  - stage1_bridge.rs ブリッジ実装
  - デバッグツール作成(stage1_debug.sh/stage1_minimal.sh)
  - アーキテクチャ改善提案文書

-  環境変数削減計画策定
  - 25変数の完全調査・分類
  - 6段階削減ロードマップ(25→5、80%削減)
  - 即時削除可能変数特定(NYASH_CONFIG/NYASH_DEBUG)

Phase 26-D からの累積変更:
- PHI実装改善(ExitPhiBuilder/HeaderPhiBuilder等)
- MIRビルダーリファクタリング
- 型伝播・最適化パス改善
- その他約300ファイルの累積変更

🎯 技術的成果:
- SSAバグ根本原因特定(条件分岐内loop変数変更)
- Region+next_iパターン適用完了(UsingCollectorBox等)
- LoopFormパターン文書化・テスト化完了
- セルフホスティング基盤強化

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: ChatGPT <noreply@openai.com>
Co-Authored-By: Task Assistant <task@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-21 06:25:17 +09:00
parent baf028a94f
commit f9d100ce01
366 changed files with 14322 additions and 5236 deletions

View File

@ -29,4 +29,3 @@ impl NyashTokenizer {
self.position >= self.input.len()
}
}

View File

@ -8,7 +8,9 @@ impl NyashTokenizer {
match std::env::var("NYASH_PARSER_ALLOW_SEMICOLON").ok() {
Some(v) => {
let lv = v.to_ascii_lowercase();
if lv == "0" || lv == "false" || lv == "off" { return false; }
if lv == "0" || lv == "false" || lv == "off" {
return false;
}
true
}
None => true,
@ -149,12 +151,20 @@ impl NyashTokenizer {
}
Some('"') => {
let string_value = self.read_string()?;
Ok(Token::new(TokenType::STRING(string_value), start_line, start_column))
Ok(Token::new(
TokenType::STRING(string_value),
start_line,
start_column,
))
}
// Stage3: シングルクォート文字列(オプトイン)
Some('\'') if crate::config::env::parser_stage3() => {
let string_value = self.read_single_quoted_string()?;
Ok(Token::new(TokenType::STRING(string_value), start_line, start_column))
Ok(Token::new(
TokenType::STRING(string_value),
start_line,
start_column,
))
}
Some(c) if c.is_ascii_digit() => {
let token_type = self.read_numeric_literal()?;
@ -216,7 +226,11 @@ impl NyashTokenizer {
Some('>') if self.peek_char() == Some('=') => {
self.advance();
self.advance();
Ok(Token::new(TokenType::GreaterEquals, start_line, start_column))
Ok(Token::new(
TokenType::GreaterEquals,
start_line,
start_column,
))
}
Some(c) => {
if let Some(token) = self.single_char_token(c) {

View File

@ -118,7 +118,11 @@ pub struct Token {
impl Token {
pub fn new(token_type: TokenType, line: usize, column: usize) -> Self {
Self { token_type, line, column }
Self {
token_type,
line,
column,
}
}
}
@ -126,7 +130,11 @@ impl Token {
#[derive(Error, Debug)]
pub enum TokenizeError {
#[error("Unexpected character '{char}' at line {line}, column {column}")]
UnexpectedCharacter { char: char, line: usize, column: usize },
UnexpectedCharacter {
char: char,
line: usize,
column: usize,
},
#[error("Unterminated string literal at line {line}")]
UnterminatedString { line: usize },

View File

@ -82,8 +82,10 @@ impl NyashTokenizer {
);
if is_stage3 {
if std::env::var("NYASH_TOK_TRACE").ok().as_deref() == Some("1") {
eprintln!("[tok-stage3] Degrading {:?} to IDENTIFIER (NYASH_PARSER_STAGE3={})",
tok, stage3_enabled);
eprintln!(
"[tok-stage3] Degrading {:?} to IDENTIFIER (NYASH_PARSER_STAGE3={})",
tok, stage3_enabled
);
}
tok = TokenType::IDENTIFIER(identifier.clone());
}
@ -101,8 +103,10 @@ impl NyashTokenizer {
| TokenType::IN
);
if is_stage3 {
eprintln!("[tok-stage3] Keeping {:?} as keyword (NYASH_PARSER_STAGE3={})",
tok, stage3_enabled);
eprintln!(
"[tok-stage3] Keeping {:?} as keyword (NYASH_PARSER_STAGE3={})",
tok, stage3_enabled
);
}
}
}

View File

@ -40,4 +40,3 @@ impl NyashTokenizer {
}
}
}

View File

@ -27,14 +27,16 @@ impl NyashTokenizer {
Some('\\') => string_value.push('\\'),
Some('"') => string_value.push('"'),
Some('\'') => string_value.push('\''), // 1-quote: エスケープされたシングルクォート
Some('/') => string_value.push('/'), // \/ を許容
Some('/') => string_value.push('/'), // \/ を許容
Some('u') => {
// Unicode decode (optional; default OFF)
if crate::config::env::parser_decode_unicode() {
let base = self.position; // index of 'u'
// read 4 hex digits without consuming; then advance position in bulk
// read 4 hex digits without consuming; then advance position in bulk
let read_hex4 = |input: &Vec<char>, start: usize| -> Option<u32> {
if start + 4 > input.len() { return None; }
if start + 4 > input.len() {
return None;
}
let d0 = input.get(start)?.to_digit(16)?;
let d1 = input.get(start + 1)?.to_digit(16)?;
let d2 = input.get(start + 2)?.to_digit(16)?;
@ -52,7 +54,8 @@ impl NyashTokenizer {
&& self.input.get(self.position) == Some(&'\\')
&& self.input.get(self.position + 1) == Some(&'u')
{
if let Some(u2) = read_hex4(&self.input, self.position + 2) {
if let Some(u2) = read_hex4(&self.input, self.position + 2)
{
if (0xDC00..=0xDFFF).contains(&u2) {
let high_ten = (u1 - 0xD800) as u32;
let low_ten = (u2 - 0xDC00) as u32;

View File

@ -2,13 +2,13 @@
* Nyash Tokenizer — split modules (kinds/cursor/whitespace/lexers/engine)
*/
mod kinds;
mod cursor;
mod whitespace;
mod lex_string;
mod lex_number;
mod lex_ident;
mod engine;
mod kinds;
mod lex_ident;
mod lex_number;
mod lex_string;
mod whitespace;
pub use kinds::{Token, TokenType, TokenizeError};
@ -21,4 +21,3 @@ pub struct NyashTokenizer {
}
// Public API and core logic are implemented in submodules via impl NyashTokenizer

View File

@ -40,4 +40,3 @@ impl NyashTokenizer {
}
}
}