diff --git a/docs/architecture/README.md b/docs/architecture/README.md deleted file mode 100644 index 8618facd..00000000 --- a/docs/architecture/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Architecture Docs Moved - -アーキテクチャの正本は `docs/reference/architecture/` へ集約しました。 - -- 入口: [../reference/architecture/](../reference/architecture/) -- 代表: [PHI and SSA](../reference/architecture/phi-and-ssa.md) - -このディレクトリは互換のための案内のみ残しています。 - diff --git a/docs/architecture/phi-and-ssa.md b/docs/architecture/phi-and-ssa.md deleted file mode 100644 index 13682cfc..00000000 --- a/docs/architecture/phi-and-ssa.md +++ /dev/null @@ -1,7 +0,0 @@ -# Moved: PHI and SSA - -このドキュメントは再編により移動しました。 -新しい場所: [../reference/architecture/phi-and-ssa.md](../reference/architecture/phi-and-ssa.md) - -この stub は後方互換のために残しています。 - diff --git a/docs/blueprints/README.md b/docs/blueprints/README.md deleted file mode 100644 index 3e9ae5f4..00000000 --- a/docs/blueprints/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Moved: Blueprints - -Blueprints は `development/design/blueprints/` に集約しました。 - -- 新しい場所: [../development/design/blueprints/](../development/design/blueprints/) - -この stub は後方互換のために残しています。 - diff --git a/docs/blueprints/strings-utf8-byte.md b/docs/blueprints/strings-utf8-byte.md deleted file mode 100644 index d2844bac..00000000 --- a/docs/blueprints/strings-utf8-byte.md +++ /dev/null @@ -1,7 +0,0 @@ -# Moved: Strings Blueprint — UTF‑8 / Bytes - -このドキュメントは再編により移動しました。 -新しい場所: [../development/design/blueprints/strings-utf8-byte.md](../development/design/blueprints/strings-utf8-byte.md) - -この stub は後方互換のために残しています。 - diff --git a/docs/comparison/README.md b/docs/comparison/README.md deleted file mode 100644 index 1fcd388f..00000000 --- a/docs/comparison/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Moved: Comparison - -比較記事は `docs/guides/comparison/` に移動しました。 - -- 代表: [nyash-vs-others.md](../guides/comparison/nyash-vs-others.md) - diff --git a/docs/design/README.md b/docs/design/README.md deleted file mode 100644 index 1732bedf..00000000 --- a/docs/design/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Design Notes Moved - -`docs/design/` の設計ノートは `docs/development/design/legacy/` に移動しました。 - -- 新しい場所: [../development/design/legacy/](../development/design/legacy/) -- よく参照されるページ: - - [flow-blocks.md](../development/design/legacy/flow-blocks.md) - - [using-loader-integration.md](../development/design/legacy/using-loader-integration.md) - -このディレクトリは互換のための案内のみ残しています。 - diff --git a/docs/design/flow-blocks.md b/docs/design/flow-blocks.md deleted file mode 100644 index bb1f0c36..00000000 --- a/docs/design/flow-blocks.md +++ /dev/null @@ -1,5 +0,0 @@ -# Moved: Flow Blocks (Design Draft) - -このドキュメントは再編により移動しました。 -新しい場所: [../development/design/legacy/flow-blocks.md](../development/design/legacy/flow-blocks.md) - diff --git a/docs/design/using-loader-integration.md b/docs/design/using-loader-integration.md deleted file mode 100644 index 7f6bee11..00000000 --- a/docs/design/using-loader-integration.md +++ /dev/null @@ -1,5 +0,0 @@ -# Moved: Using → Loader Integration (Minimal) - -このドキュメントは再編により移動しました。 -新しい場所: [../development/design/legacy/using-loader-integration.md](../development/design/legacy/using-loader-integration.md) - diff --git a/docs/ideas/tools/cax/README.md b/docs/development/proposals/ideas/tools/cax/README.md similarity index 100% rename from docs/ideas/tools/cax/README.md rename to docs/development/proposals/ideas/tools/cax/README.md diff --git a/docs/ideas/tools/cax/chatgpt-design-spec.md b/docs/development/proposals/ideas/tools/cax/chatgpt-design-spec.md similarity index 100% rename from docs/ideas/tools/cax/chatgpt-design-spec.md rename to docs/development/proposals/ideas/tools/cax/chatgpt-design-spec.md diff --git a/docs/ideas/tools/cax/gemini-ipc-implementation.nyash b/docs/development/proposals/ideas/tools/cax/gemini-ipc-implementation.nyash similarity index 100% rename from docs/ideas/tools/cax/gemini-ipc-implementation.nyash rename to docs/development/proposals/ideas/tools/cax/gemini-ipc-implementation.nyash diff --git a/docs/ideas/tools/cax/inspiration-process.md b/docs/development/proposals/ideas/tools/cax/inspiration-process.md similarity index 100% rename from docs/ideas/tools/cax/inspiration-process.md rename to docs/development/proposals/ideas/tools/cax/inspiration-process.md diff --git a/docs/ideas/tools/cax/technical-roadmap.md b/docs/development/proposals/ideas/tools/cax/technical-roadmap.md similarity index 100% rename from docs/ideas/tools/cax/technical-roadmap.md rename to docs/development/proposals/ideas/tools/cax/technical-roadmap.md diff --git a/docs/examples/README.md b/docs/examples/README.md deleted file mode 100644 index ad2ce604..00000000 --- a/docs/examples/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Examples moved - -例は `docs/guides/examples/` に移動しました。 - -- 新しい場所: [../guides/examples/](../guides/examples/) -- 代表例: [http_result_patterns.md](../guides/examples/http_result_patterns.md) - diff --git a/docs/examples/http_result_patterns.md b/docs/examples/http_result_patterns.md deleted file mode 100644 index 4908f8f4..00000000 --- a/docs/examples/http_result_patterns.md +++ /dev/null @@ -1,5 +0,0 @@ -# Moved: HTTP Result Patterns - -このドキュメントは再編により移動しました。 -新しい場所: [../guides/examples/http_result_patterns.md](../guides/examples/http_result_patterns.md) - diff --git a/docs/ideas/README.md b/docs/ideas/README.md deleted file mode 100644 index fc0a77c5..00000000 --- a/docs/ideas/README.md +++ /dev/null @@ -1,127 +0,0 @@ -# Nyash Ideas Repository - Post‑Bootstrap 実装アイデア管理 - -**目的**: 機能追加ポーズ中に発想されたアイデアをPost‑Bootstrap実装用に整理・保管 -**原則**: 80/20ルール - 80%実装完了時の「残り20%」+新機能アイデア - -## 📁 フォルダ構造 - -### `/tools/` - 開発ツール・支援システム -実装優先度順に配置 -``` -tools/ -├── cax/ # C-ABI Explorer (高優先度・世界初) -├── macro-debugger/ # マクロ実行デバッガ(Phase 16関連) -├── nyash-profiler/ # 実行プロファイラ -└── static-analyzer/ # 静的解析ツール -``` - -### `/language/` - 言語機能拡張 -設計完了度順に配置 -``` -language/ -├── concurrency/ # 並行性Box (設計完了・docs化済み) -├── flow-blocks/ # フロー演算子 (設計完了・docs化済み) -├── scope-reuse/ # スコープ演算子 (設計完了・docs化済み) -├── pure-functional-blocks.md # []純粋関数型ブロック vs {}通常ブロック (NEW!) -├── pattern-matching/ # パターンマッチング拡張 -├── async-await/ # 非同期構文Sugar -└── metaprogramming/ # メタプログラミング機能 -``` - -### `/runtime/` - ランタイム・VM改善 -技術的重要度順に配置 -``` -runtime/ -├── nyash-self-vm/ # Nyash自己実装VM (ChatGPT提案) -├── gc-improvements/ # GC最適化・切替可能性 -├── jit-enhancements/ # JIT性能向上 -└── memory-management/ # メモリ管理改善 -``` - -### `/ecosystem/` - エコシステム・統合 -実用性順に配置 -``` -ecosystem/ -├── python-integration/ # Python統合・transpilation -├── vscode-extension/ # VSCode拡張 -├── package-manager/ # パッケージマネージャ -└── documentation-tools/ # ドキュメント自動生成 -``` - -### `/experimental/` - 実験的・研究用アイデア -``` -experimental/ -├── ai-collaboration/ # AI協働開発手法 -├── academic-papers/ # 学術発表用実験 -├── performance-research/ # 性能研究・ベンチマーク -└── future-concepts/ # 将来構想・ビジョン -``` - -## 🎯 管理ルール - -### 新アイデア追加時 -1. **適切なカテゴリに配置** -2. **README.md作成**(概要・優先度・実装見積もり) -3. **関連docs更新**(既存設計との統合性確認) - -### 実装着手時 -1. **Phase移行**: `docs/ideas/` → `docs/development/` -2. **実装計画**: ロードマップ・マイルストーン作成 -3. **ブランチ作成**: `feature/idea-name` で開発開始 - -### 完成後 -1. **docs統合**: 正式ドキュメントに昇格 -2. **アイデア削除**: または `implemented/` フォルダに移動 - -## 📋 現在のアイデア一覧 - -### 🔥 高優先度(Post‑Bootstrap 即実装) -- **CAX (C-ABI Explorer)**: 革新的デバッグツール(世界初) -- **Pure Functional []Blocks**: 純粋関数型ブロック vs 通常{}ブロック (NEW!) -- **Nyash Self-VM**: Python/Rust VM統一化 -- **Flow Blocks**: 設計完了、実装のみ -- **Concurrency Boxes**: Go超越の並行性 - -### ⭐ 中優先度(Phase 16-17) -- **Macro Revolution**: マクロシステム拡張 -- **Python Integration**: transpilation + 相互運用 -- **Static Analysis**: 型推論・最適化支援 - -### 💡 低優先度(将来構想) -- **Package Manager**: エコシステム成熟後 -- **VSCode Extension**: 言語安定後 -- **Academic Research**: 発表機会に応じて - -## 🔄 更新プロセス - -### Weekly Review -- 新アイデアの整理・分類 -- 優先度見直し -- 重複・統合可能性検討 - -### Phase間Review -- 実装完了アイデアの整理 -- 次Phase候補の選定 -- ロードマップ更新 - -## 💭 アイデア品質基準 - -### High Quality (即実装候補) -- ✅ 技術的実現性: 明確な実装パス -- ✅ ユーザー価値: 具体的な問題解決 -- ✅ Nyash親和性: 箱理論との整合性 -- ✅ 独創性: 既存ツールにない価値 - -### Medium Quality (将来実装) -- ✅ 概念明確性: アイデアの核心が明確 -- ⚠️ 実装詳細: 一部未確定要素あり -- ✅ 価値仮説: 実用性の仮説あり - -### Low Quality (要再検討) -- ⚠️ 概念曖昧: アイデアが抽象的 -- ❌ 技術困難: 実装パスが不明確 -- ❌ 価値不明: 実用性が疑問 - ---- - -**Note**: このREADMEは、アイデア管理の指針として機能。新アイデア発想時は、必ずここを参照して適切な分類・記録を行う。 diff --git a/docs/proposals/README.md b/docs/proposals/README.md deleted file mode 100644 index aaf3de7a..00000000 --- a/docs/proposals/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Proposals Moved - -提案(RFC)は `docs/development/proposals/` に集約しました。 - -- 新しい場所: [../development/proposals/](../development/proposals/) - diff --git a/docs/proposals/concurrency/boxes.md b/docs/proposals/concurrency/boxes.md deleted file mode 100644 index 76dce17b..00000000 --- a/docs/proposals/concurrency/boxes.md +++ /dev/null @@ -1,5 +0,0 @@ -# Moved: Concurrency — Box Model (Proposal) - -この提案は再編により移動しました。 -新しい場所: [../../development/proposals/concurrency/boxes.md](../../development/proposals/concurrency/boxes.md) - diff --git a/docs/proposals/scope-reuse.md b/docs/proposals/scope-reuse.md deleted file mode 100644 index dc931dd8..00000000 --- a/docs/proposals/scope-reuse.md +++ /dev/null @@ -1,5 +0,0 @@ -# Moved: Scope Reuse Blocks (MVP Proposal) - -この提案は再編により移動しました。 -新しい場所: [../development/proposals/scope-reuse.md](../development/proposals/scope-reuse.md) - diff --git a/docs/proposals/unified-members.md b/docs/proposals/unified-members.md deleted file mode 100644 index 6287a01d..00000000 --- a/docs/proposals/unified-members.md +++ /dev/null @@ -1,5 +0,0 @@ -# Moved: Unified Members Proposal - -この提案は再編により移動しました。 -新しい場所: [../development/proposals/unified-members.md](../development/proposals/unified-members.md) - diff --git a/docs/reference/architecture/TECHNICAL_ARCHITECTURE_2025.md b/docs/reference/architecture/TECHNICAL_ARCHITECTURE_2025.md index d81a0209..82ca9358 100644 --- a/docs/reference/architecture/TECHNICAL_ARCHITECTURE_2025.md +++ b/docs/reference/architecture/TECHNICAL_ARCHITECTURE_2025.md @@ -4,9 +4,9 @@ This index points to the currently maintained architectural documents: - Core Concepts: reference/architecture/nyash_core_concepts.md - Execution Backends: reference/architecture/execution-backends.md -- Lowering Contexts: ../../design/LOWERING_CONTEXTS.md -- LLVM Layer Overview: ../../design/LLVM_LAYER_OVERVIEW.md +- Lowering Contexts: ../../development/design/legacy/LOWERING_CONTEXTS.md +- LLVM Layer Overview: ../../development/design/legacy/LLVM_LAYER_OVERVIEW.md - VM Overview: vm.md -- Cranelift AOT design: ../../design/backend-cranelift-aot-design.md +- Cranelift AOT design: ../../development/design/legacy/backend-cranelift-aot-design.md Note: Some long-form papers reside under `private/papers/reference/architecture/`. diff --git a/docs/reference/architecture/execution-backends.md b/docs/reference/architecture/execution-backends.md index 9c7bc0d7..0cdb3ecd 100644 --- a/docs/reference/architecture/execution-backends.md +++ b/docs/reference/architecture/execution-backends.md @@ -4,5 +4,5 @@ For the full guide, see: - execution-backends.md (legacy location kept up to date) Additional references: -- ../../design/backend-llvm-implementation-guide.md +- ../../development/design/legacy/backend-llvm-implementation-guide.md - vm.md diff --git a/docs/status/README.md b/docs/status/README.md deleted file mode 100644 index faf3801a..00000000 --- a/docs/status/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Status/Golden moved - -ゴールデン出力などのステータス関連ドキュメントは `docs/development/testing/golden/` へ移動しました。 - -- 新しい場所: [../development/testing/golden/](../development/testing/golden/) - diff --git a/docs/tests/README.md b/docs/tests/README.md deleted file mode 100644 index e9c392eb..00000000 --- a/docs/tests/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Tests moved - -テスト関連のドキュメントは `docs/development/testing/` に移動しました。 - -- 新しい場所: [../development/testing/](../development/testing/) - diff --git a/src/config/env.rs b/src/config/env.rs index 556579f8..1ee6e0ea 100644 --- a/src/config/env.rs +++ b/src/config/env.rs @@ -365,14 +365,8 @@ pub fn using_ast_enabled() -> bool { _ => !using_is_prod(), // dev/ci → true, prod → false } } -pub fn resolve_fix_braces() -> bool { - // Safer default: OFF(誤補正の副作用を避ける) - // 明示ON: NYASH_RESOLVE_FIX_BRACES=1 - matches!( - std::env::var("NYASH_RESOLVE_FIX_BRACES").ok().as_deref(), - Some("1") | Some("true") | Some("on") - ) -} +// Legacy resolve_fix_braces() removed (Phase 15 cleanup) +// AST-based integration handles syntax properly without text-level brace fixing pub fn vm_use_py() -> bool { std::env::var("NYASH_VM_USE_PY").ok().as_deref() == Some("1") } diff --git a/src/runner/modes/common_util/resolve/seam.rs b/src/runner/modes/common_util/resolve/seam.rs index 46de3b20..bf7145cd 100644 --- a/src/runner/modes/common_util/resolve/seam.rs +++ b/src/runner/modes/common_util/resolve/seam.rs @@ -32,53 +32,5 @@ pub fn log_prelude_body_seam(prelude_clean: &str, body: &str, seam_dbg: bool) { eprintln!("[using][seam] body_head =<<<{}>>>", head.replace('\n', "\\n")); } -/// Apply optional seam safety: append missing '}' for unmatched '{' in prelude -/// When `trace` is true, emits a short note with delta count. -pub fn fix_prelude_braces_if_enabled(prelude_clean: &str, combined: &mut String, trace: bool) { - if !crate::config::env::resolve_fix_braces() { - return; - } - // compute { } delta ignoring strings and comments - let mut delta: i32 = 0; - let mut it = prelude_clean.chars().peekable(); - let mut in_str = false; - let mut in_sl = false; - let mut in_ml = false; - while let Some(c) = it.next() { - if in_sl { - if c == '\n' { in_sl = false; } - continue; - } - if in_ml { - if c == '*' { - if let Some('/') = it.peek().copied() { - it.next(); - in_ml = false; - } - } - continue; - } - if in_str { - if c == '\\' { it.next(); continue; } - if c == '"' { in_str = false; } - continue; - } - if c == '"' { in_str = true; continue; } - if c == '/' { - match it.peek().copied() { - Some('/') => { in_sl = true; it.next(); continue; } - Some('*') => { in_ml = true; it.next(); continue; } - _ => {} - } - } - if c == '{' { delta += 1; } - if c == '}' { delta -= 1; } - } - if delta > 0 { - if trace { eprintln!("[using][seam] fix: appending {} '}}' before body", delta); } - for _ in 0..delta { - combined.push('}'); - combined.push('\n'); - } - } -} +// Legacy brace fix function removed (Phase 15 cleanup) +// AST-based integration handles syntax errors properly without text-level hacks diff --git a/src/runner/modes/vm_fallback.rs b/src/runner/modes/vm_fallback.rs index b36805e2..38165e2c 100644 --- a/src/runner/modes/vm_fallback.rs +++ b/src/runner/modes/vm_fallback.rs @@ -12,7 +12,7 @@ impl NyashRunner { Ok(s) => s, Err(e) => { eprintln!("❌ Error reading file {}: {}", filename, e); process::exit(1); } }; - // Using preprocessing (legacy inline or AST-prelude merge when NYASH_USING_AST=1) + // Using preprocessing with AST-prelude merge (when NYASH_USING_AST=1) let mut code2 = code; let use_ast_prelude = crate::config::env::enable_using() && crate::config::env::using_ast_enabled(); diff --git a/tools/smokes/v2/profiles/quick/core/json_errors_ast.sh b/tools/smokes/v2/profiles/quick/core/json_errors_ast.sh new file mode 100644 index 00000000..41729993 --- /dev/null +++ b/tools/smokes/v2/profiles/quick/core/json_errors_ast.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# json_errors_ast.sh - JSON error cases via AST using + +source "$(dirname "$0")/../../../lib/test_runner.sh" +require_env || exit 2 +preflight_plugins || exit 2 + +TEST_DIR="/tmp/json_errors_ast_$$" +mkdir -p "$TEST_DIR" +cd "$TEST_DIR" + +cat > nyash.toml << EOF +[using.json_native] +path = "$NYASH_ROOT/apps/lib/json_native/" +main = "parser/parser.nyash" + +[using.aliases] +json = "json_native" +EOF + +cat > driver.nyash << 'EOF' +using json_native as JsonParserModule + +static box Main { + main() { + local bad = new ArrayBox() + bad.push("{") + bad.push("[1,2,,3]") + bad.push("{\"a\" 1}") + bad.push("{\"a\":}") + + local i = 0 + loop(i < bad.length()) { + local s = bad.get(i) + local parser = JsonParserModule.create_parser() + local res = parser.parse(s) + if parser.has_errors() or res == null { + print("ERR") + } else { + print("OK") + } + i = i + 1 + } + return 0 + } +} +EOF + +expected=$(cat << 'TXT' +ERR +ERR +ERR +ERR +TXT +) + +output=$("$NYASH_BIN" --backend vm driver.nyash 2>&1 | filter_noise) +compare_outputs "$expected" "$output" "json_errors_ast" + +cd / +rm -rf "$TEST_DIR" diff --git a/tools/smokes/v2/profiles/quick/core/json_nested_ast.sh b/tools/smokes/v2/profiles/quick/core/json_nested_ast.sh new file mode 100644 index 00000000..1a1c7067 --- /dev/null +++ b/tools/smokes/v2/profiles/quick/core/json_nested_ast.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# json_nested_ast.sh - Nested arrays/objects roundtrip via AST using + +source "$(dirname "$0")/../../../lib/test_runner.sh" +require_env || exit 2 +preflight_plugins || exit 2 + +TEST_DIR="/tmp/json_nested_ast_$$" +mkdir -p "$TEST_DIR" +cd "$TEST_DIR" + +cat > nyash.toml << EOF +[using.json_native] +path = "$NYASH_ROOT/apps/lib/json_native/" +main = "parser/parser.nyash" + +[using.aliases] +json = "json_native" +EOF + +cat > driver.nyash << 'EOF' +using json_native as JsonParserModule + +static box Main { + main() { + local samples = new ArrayBox() + samples.push("[1,[2,3],{\"x\":[4]}]") + samples.push("{\"a\":{\"b\":[1,2]},\"c\":\"d\"}") + samples.push("{\"n\":-1e-3,\"z\":0.0}") + + local i = 0 + loop(i < samples.length()) { + local s = samples.get(i) + local r = JsonParserModule.roundtrip_test(s) + print(r) + i = i + 1 + } + return 0 + } +} +EOF + +expected=$(cat << 'TXT' +[1,[2,3],{"x":[4]}] +{"a":{"b":[1,2]},"c":"d"} +{"n":-1e-3,"z":0.0} +TXT +) + +output=$("$NYASH_BIN" --backend vm driver.nyash 2>&1 | filter_noise) +compare_outputs "$expected" "$output" "json_nested_ast" + +cd / +rm -rf "$TEST_DIR" diff --git a/tools/smokes/v2/profiles/quick/core/json_roundtrip_ast.sh b/tools/smokes/v2/profiles/quick/core/json_roundtrip_ast.sh index 8878f04d..c815e6ba 100644 --- a/tools/smokes/v2/profiles/quick/core/json_roundtrip_ast.sh +++ b/tools/smokes/v2/profiles/quick/core/json_roundtrip_ast.sh @@ -9,8 +9,17 @@ TEST_DIR="/tmp/json_roundtrip_ast_$$" mkdir -p "$TEST_DIR" cd "$TEST_DIR" +cat > nyash.toml << EOF +[using.json_native] +path = "$NYASH_ROOT/apps/lib/json_native/" +main = "parser/parser.nyash" + +[using.aliases] +json = "json_native" +EOF + cat > driver.nyash << 'EOF' -using "apps/lib/json_native/parser/parser.nyash" as JsonParserModule +using json_native as JsonParserModule static box Main { main() { @@ -61,7 +70,7 @@ false TXT ) -output=$(run_nyash_vm driver.nyash) +output=$("$NYASH_BIN" --backend vm driver.nyash 2>&1 | filter_noise) compare_outputs "$expected" "$output" "json_roundtrip_ast" cd /