Files
hakorune/docs/development/roadmap/phases/phase-12.7/grammar-reform-summary.txt

92 lines
3.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

================================================================================
Nyash文法改革 - 実装向け要約
2025-09-03
================================================================================
【最重要決定事項】
1. 予約語は10個のみ
- box, new, me, public, if, loop, break, return, import, from
2. コンストラクタ名は「birth」で統一
- Everything is Box哲学を体現
- packはビルトインBox継承時のみ将来廃止検討
3. 変数宣言は := 演算子を導入
- x := 10 // 新規宣言
- x = 20 // 既存変数への代入
- let x = 10 // オプション(糖衣構文)
4. デリゲーションと親メソッド呼び出し
- box Child from Parent { } // fromは残す
- Parent::method() // 親メソッド呼び出し(推奨)
- from method() // 単一親の場合の糖衣構文
5. デフォルト非公開
- privateキーワード削除
- publicを付けたものだけ公開
================================================================================
【具体例】
================================================================================
box Counter from BaseCounter {
// フィールド(デフォルト非公開)
count := 0
// 公開フィールド
public name: str
// コンストラクタbirthで統一
public birth(name) {
me.name = name
BaseCounter::birth() // 親のbirth呼び出し
}
// メソッド(@overrideは属性
@override
public increment() {
me.count = me.count + 1
BaseCounter::increment() // 親メソッド呼び出し
return me.count
}
}
// 使用
counter := new Counter("MyCounter")
counter.increment()
================================================================================
【移行チェックリスト】
================================================================================
□ init → birth に変更
□ private削除デフォルト非公開
□ var x = → x := に変更
□ from Parent.method() → Parent::method()
□ override → @override
□ and/or/not → &&/||/!
□ try/catch → Result型 + ?演算子
================================================================================
【パーサー実装への影響】
================================================================================
1. 予約語リストを10個に削減
2. := 演算子のサポート追加
3. :: 演算子の拡張(親メソッド呼び出し対応)
4. @属性のサポート追加
5. privateキーワードの削除
6. 文脈的from解釈の実装
================================================================================
【次のアクション】
================================================================================
1. LANGUAGE_REFERENCE_2025.mdの更新
2. CLAUDE.mdの更新birthを最優先に
3. パーサーの予約語リスト修正
4. テストケースの更新
5. 既存サンプルコードの移行
================================================================================