🚀 Start Phase 15.3: Nyash compiler MVP implementation

Major milestone:
- Set up apps/selfhost-compiler/ directory structure
- Implement basic Nyash compiler in Nyash (CompilerBox)
- Stage-1: Basic arithmetic parser (int/string/+/-/*/括弧/return)
- JSON v0 output compatible with --ny-parser-pipe
- Runner integration with NYASH_USE_NY_COMPILER=1 flag
- Comprehensive smoke tests for PHI/Bridge/Stage-2

Technical updates:
- Updated CLAUDE.md with Phase 15.3 status and MIR14 details
- Statement separation policy: newline-based with minimal ASI
- Fixed runaway ny-parser-pipe processes (CPU 94.9%)
- Clarified MIR14 as canonical instruction set (not 13/18)
- LoopForm strategy: PHI auto-generation during reverse lowering

Collaborative development:
- ChatGPT5 implementing compiler skeleton
- Codex provided LoopForm PHI generation guidance
- Claude maintaining documentation and coordination

🎉 セルフホスティングの歴史的一歩!自分自身をコンパイルする日が近いにゃ!

Co-Authored-By: ChatGPT <noreply@openai.com>
This commit is contained in:
Selfhosting Dev
2025-09-15 01:21:37 +09:00
parent d01f9b9c93
commit af11c6855b
28 changed files with 1007 additions and 40 deletions

View File

@ -0,0 +1,38 @@
# Phase 15.3 — Imports/Namespace/nyash.toml Plan
Status: 15.3 planning; focus remains on Stage1/2 compiler MVP. This document scopes when and how to bring `nyash.toml`/include/import/namespace into the selfhost path without destabilizing parity.
Goals
- Keep runnerlevel `nyash.toml` parsing/resolution as the source of truth during 15.3.
- Accept `using/import` syntax in the Ny compiler as a noop (record only) until resolution is delegated.
- Avoid VM changes; resolution happens before codegen.
Scope & Sequence (Phase 15.3)
1) Stage1/2 compiler stability (primary)
- Ny→JSON v0 → Bridge → PyVM/llvmlite parity maintained
- PHI merge remains on Bridge (If/Loop)
2) Imports/Namespace minimal acceptance (15.3late)
- Parse `using ns` / `using "path" [as alias]` as statements in the Ny compiler
- Do not resolve; emit no JSON entries (or emit metadata) — runner continues to strip/handle
- Gate via `NYASH_ENABLE_USING=1`
3) Runner remains in charge
- Keep existing Rust runners `using` stripping + modules registry population
- `nyash.toml` parsing stays in Rust (Phase 15)
Out of scope (Phase 15)
- Porting `nyash.toml` parsing to Ny
- Crossmodule codegen/linking in Ny compiler
- Advanced include resolution / package graph
Acceptance (15.3)
- Ny compiler can lex/parse `using` forms without breaking Stage1/2 programs
- Runner path (Rust) continues to resolve `using` and `nyash.toml` as before (parity unchanged)
Looking ahead (Core14 / Phase 16)
- Evaluate moving `nyash.toml` parsing to Ny as a library box (ConfigBox)
- Unify include/import/namespace into a single resolver pass in Ny with a small JSON side channel back to the runner
- Keep VM unchanged; all resolution before MIR build
Switches
- `NYASH_ENABLE_USING=1` — enable `using` acceptance in Ny compiler (no resolution)
- `NYASH_SKIP_TOML_ENV=1` — skip applying [env] in nyash.toml (existing)