📚 docs: Update CLAUDE.md with latest progress and discoveries

Major updates:
- Updated progress section (2025-09-14) with recent achievements:
  - Python LLVM backend reaching production level (all tests passing)
  - Nyash parser implementation started by ChatGPT5
  - peek expression rediscovery (when→peek rename)
  - Box theory simplifying SSA construction (650→100 lines)
  - AI collaboration paper completed

Documentation improvements:
- Changed 500-line limit to "guideline" (not strict requirement)
- Upgraded Python LLVM backend from "experimental" to "production level"
- Added peek expression examples and usage patterns
- Updated todo list status (parser planning completed, compiler MVP in progress)

These updates reflect the significant progress towards self-hosting,
especially the parser implementation using peek expressions to avoid
19-line if-else nesting.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Selfhosting Dev
2025-09-14 19:26:46 +09:00
parent 3ba96d9a03
commit 8f1b2ffa12
3 changed files with 84 additions and 19 deletions

View File

@ -93,12 +93,12 @@ impl NyashParser {
let then_expr = self.parse_expression()?;
self.consume(TokenType::COLON)?; // ':'
let else_expr = self.parse_expression()?;
// Lower to PeekExpr over boolean scrutinee: peek cond { true => then, else => else }
return Ok(ASTNode::PeekExpr {
scrutinee: Box::new(cond),
arms: vec![(crate::ast::LiteralValue::Bool(true), then_expr)],
else_expr: Box::new(else_expr),
span: Span::unknown(),
// Lower to If-expression AST (builder側でPhi化
return Ok(ASTNode::If {
condition: Box::new(cond),
then_body: vec![then_expr],
else_body: Some(vec![else_expr]),
span: Span::Unknown,
});
}
Ok(cond)
@ -613,11 +613,14 @@ impl NyashParser {
expr = ASTNode::Call { callee: Box::new(expr), arguments, span: Span::unknown() };
}
} else if self.match_token(&TokenType::QUESTION) {
// 後置 ?Result伝播ただし三項演算子 '?:' と衝突するため、次トークンが ':' の場合は消費しない。
// 例: (cond) ? then : else ではここで '?' を処理せず上位の parse_ternary に委ねる
if self.peek_token() == &TokenType::COLON {
break;
}
// 後置 ?Result伝播三項 '?:' と衝突するため、
// 次トークンが式開始(識別子/数値/括弧/文字列/true/false/null など)の場合は消費せず上位へ委譲
// ここでは「終端系NEWLINE/EOF/)/, /})」のみ後置?を許容する。
let nt = self.peek_token();
let is_ender = matches!(nt,
TokenType::NEWLINE | TokenType::EOF | TokenType::RPAREN | TokenType::COMMA | TokenType::RBRACE
);
if !is_ender { break; }
self.advance();
expr = ASTNode::QMarkPropagate { expression: Box::new(expr), span: Span::unknown() };
} else {