🎁 feat: pack構文革命完全達成 - Box哲学の具現化
【実装内容】 - packキーワード追加: TokenType::PACK, "pack" mapping - パーサー対応: init同様の特別扱い + from Parent.pack() - インタープリター対応: pack > init > Box名順優先選択 - デリゲーション統合: from Parent.pack()で親packを呼び出し - テスト完備: test_pack_syntax.nyash包括テスト 【革命的効果】 - Box哲学具現化: 「箱に詰める」でコードを書くたび哲学体験 - 他言語差別化: new/init超越のNyash独自アイデンティティ - 直感的UX: Gemini・ChatGPT両先生一致推薦の最適命名 - メンタルモデル統一: 全Boxで1つのpack動詞に収束 - 拡張基盤: try_pack, from_*パターンへの発展準備完了 🎉 Everything is Box - Now Everything is Packed\! 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -480,18 +480,29 @@ impl NyashParser {
|
||||
// DOTを確認
|
||||
self.consume(TokenType::DOT)?;
|
||||
|
||||
// method名を取得
|
||||
let method = if let TokenType::IDENTIFIER(name) = &self.current_token().token_type {
|
||||
let name = name.clone();
|
||||
self.advance();
|
||||
name
|
||||
} else {
|
||||
let line = self.current_token().line;
|
||||
return Err(ParseError::UnexpectedToken {
|
||||
found: self.current_token().token_type.clone(),
|
||||
expected: "method name".to_string(),
|
||||
line,
|
||||
});
|
||||
// method名を取得 (IDENTIFIERまたはINITを受け入れ)
|
||||
let method = match &self.current_token().token_type {
|
||||
TokenType::IDENTIFIER(name) => {
|
||||
let name = name.clone();
|
||||
self.advance();
|
||||
name
|
||||
}
|
||||
TokenType::INIT => {
|
||||
self.advance();
|
||||
"init".to_string()
|
||||
}
|
||||
TokenType::PACK => {
|
||||
self.advance();
|
||||
"pack".to_string()
|
||||
}
|
||||
_ => {
|
||||
let line = self.current_token().line;
|
||||
return Err(ParseError::UnexpectedToken {
|
||||
found: self.current_token().token_type.clone(),
|
||||
expected: "method name".to_string(),
|
||||
line,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 引数リストをパース
|
||||
|
||||
Reference in New Issue
Block a user