From: Urabe Shyouhei Date: 2009-02-10T18:31:02+09:00 Subject: [ruby-core:21948] Re: New hash : syntax for the 1.8 series? Brent Roman wrote: > Is anyone working working on porting this back to 1.8? Not sure if it should go to 1.8, but porting itself is as easy as this: Index: parse.y =================================================================== --- parse.y (revision 22198) +++ parse.y (working copy) @@ -267,7 +267,7 @@ k__LINE__ k__FILE__ -%token tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR +%token tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL %token tINTEGER tFLOAT tSTRING_CONTENT %token tNTH_REF tBACK_REF %token tREGEXP_END @@ -2504,6 +2504,10 @@ { $$ = list_append(NEW_LIST($1), $3); } + | tLABEL arg_value + { + $$ = list_append(NEW_LIST(NEW_LIT(ID2SYM($1))), $2); + } ; operation : tIDENTIFIER @@ -4526,6 +4530,17 @@ } } + if ((lex_state == EXPR_BEG && !cmd_state) || + lex_state == EXPR_ARG || + lex_state == EXPR_CMDARG) { + if (peek(':') && !(lex_p + 1 < lex_pend && lex_p[1] == ':')) { + lex_state = EXPR_BEG; + nextc(); + yylval.id = rb_intern(tok()); + return tLABEL; + } + } + if (lex_state != EXPR_DOT) { const struct kwtable *kw;