🚀 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

@ -242,10 +242,23 @@ fn lower_expr_with_vars(
match e {
ExprV0::Var { name } => {
if let Some(&vid) = vars.get(name) {
Ok((vid, cur_bb))
} else {
Err(format!("undefined variable: {}", name))
return Ok((vid, cur_bb));
}
if name == "me" {
// Optional gate: allow a dummy 'me' instance for Stage-2 JSON smoke
if std::env::var("NYASH_BRIDGE_ME_DUMMY").ok().as_deref() == Some("1") {
let class = std::env::var("NYASH_BRIDGE_ME_CLASS").unwrap_or_else(|_| "Main".to_string());
let dst = f.next_value_id();
if let Some(bb) = f.get_block_mut(cur_bb) {
bb.add_instruction(MirInstruction::NewBox { dst, box_type: class, args: vec![] });
}
vars.insert("me".to_string(), dst);
return Ok((dst, cur_bb));
} else {
return Err("undefined 'me' outside box context (set NYASH_BRIDGE_ME_DUMMY=1 to inject placeholder)".into());
}
}
Err(format!("undefined variable: {}", name))
}
ExprV0::Call { name, args } => {
// Lower args