Files
hakorune/docs/guides/language-guide.md
Selfhosting Dev 3ba96d9a03 🚀 feat: Multiple improvements for Nyash parser and LLVM backend
Parser improvements:
- Added expression statement fallback in parse_statement() for flexible syntax
- Fixed ternary operator to use PeekExpr instead of If AST (better lowering)
- Added peek_token() check to avoid ?/?: operator conflicts

LLVM Python improvements:
- Added optional ESC_JSON_FIX environment flag for string concatenation
- Improved PHI generation with better default handling
- Enhanced substring tracking for esc_json pattern

Documentation updates:
- Updated language guide with peek expression examples
- Added box theory diagrams to Phase 15 planning
- Clarified peek vs when syntax differences

These changes enable cleaner parser implementation for self-hosting,
especially for handling digit conversion with peek expressions instead
of 19-line if-else chains.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-14 19:16:32 +09:00

22 lines
996 B
Markdown

# Nyash Language Guide
Start here to learn Nyash language basics and find deeper references.
- Syntax Cheat Sheet: quick-reference/syntax-cheatsheet.md
- Full Language Reference (2025): reference/language/LANGUAGE_REFERENCE_2025.md
- Phase 12.7 Grammar (peek / ternary / sugar):
- Overview: development/roadmap/phases/phase-12.7/grammar-specs/README.md
- Tokens & Grammar: development/roadmap/phases/phase-12.7/ancp-specs/ANCP-Token-Specification-v1.md
- Sugar transformations (?., ??, |> ...): tools/nyfmt/NYFMT_POC_ROADMAP.md
Common Constructs
- Ternary operator: `cond ? then : else` (Phase 12.7); lowered to If-expression
- Peek expression: `peek value { lit => expr, else => expr }`
- Null-coalesce: `x ?? y``peek x { null => y, else => x }`
- Safe access: `a?.b``peek a { null => null, else => a.b }`
When you need the implementation details
- Tokenizer: src/tokenizer.rs
- Parser: src/parser/expressions.rs, src/parser/statements.rs
- Lowering to MIR: src/mir/builder/**