From 13d0832965a36d2c16a71acf982b7c98c4c37af6 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 2 Nov 2016 08:41:43 +0900 Subject: allow quoted labels in hashes; fix #3231 --- mrbgems/mruby-compiler/core/parse.y | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index fc2c65b7c..a00fd0c49 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -1089,7 +1089,7 @@ heredoc_end(parser_state *p) %token tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL %token tINTEGER tFLOAT tCHAR tXSTRING tREGEXP -%token tSTRING tSTRING_PART tSTRING_MID +%token tSTRING tSTRING_PART tSTRING_MID tLABEL_END %token tNTH_REF tBACK_REF %token tREGEXP_END @@ -3241,6 +3241,14 @@ assoc : arg_value tASSOC arg_value { $$ = cons(new_sym(p, $1), $2); } + | tSTRING_BEG tLABEL_END arg_value + { + $$ = cons(new_sym(p, new_strsym(p, $2)), $3); + } + | tSTRING_BEG string_rep tLABEL_END arg_value + { + $$ = cons(new_dsym(p, push($2, $3)), $4); + } ; operation : tIDENTIFIER @@ -4080,8 +4088,13 @@ parse_string(parser_state *p) return tREGEXP; } - yylval.nd = new_str(p, tok(p), toklen(p)); + if (IS_LABEL_SUFFIX(0)) { + p->lstate = EXPR_BEG; + nextc(p); + return tLABEL_END; + } + return tSTRING; } -- cgit v1.2.3