feat: IDENTIFIERキーをデフォルトで有効化 - DX大幅改善!
- primary.rs: sugar_level != "basic"でIDENTIFIERキーを許可
- デフォルトで {name: "value"} のようなモダンな構文が使える
- NYASH_SYNTAX_SUGAR_LEVEL=basic で厳密モード(文字列キーのみ)
- 環境変数なしで複数行match式が完全動作
- エラーメッセージも改善(basicモード時に解決方法を提示)
これでPhase 15セルフホスティングの開発が快適に!
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -43,9 +43,10 @@ impl NyashParser {
|
||||
self.advance();
|
||||
let mut entries: Vec<(String, ASTNode)> = Vec::new();
|
||||
let sugar_level = std::env::var("NYASH_SYNTAX_SUGAR_LEVEL").ok();
|
||||
// デフォルトでIDENTIFIERキーを許可(basicが明示的に指定された場合のみ無効)
|
||||
let ident_key_on = std::env::var("NYASH_ENABLE_MAP_IDENT_KEY").ok().as_deref()
|
||||
== Some("1")
|
||||
|| sugar_level.as_deref() == Some("full");
|
||||
|| sugar_level.as_deref() != Some("basic"); // basic以外は全て許可(デフォルト含む)
|
||||
self.skip_newlines();
|
||||
while !self.match_token(&TokenType::RBRACE) && !self.is_at_end() {
|
||||
self.skip_newlines();
|
||||
@ -67,7 +68,7 @@ impl NyashParser {
|
||||
expected: if ident_key_on {
|
||||
"string or identifier key in map literal".to_string()
|
||||
} else {
|
||||
"string key in map literal".to_string()
|
||||
"string key in map literal (set NYASH_SYNTAX_SUGAR_LEVEL=full for identifier keys)".to_string()
|
||||
},
|
||||
line,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user