From 943fbb2beafd5c9d6d39fb653135bded84531b3c Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 1 Jan 2020 11:55:08 +0900 Subject: Allow `here-doc` in the middle of Hash expressions; fix #4815 --- mrbgems/mruby-compiler/core/parse.y | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index f8db486a5..993cbca8c 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -1307,7 +1307,6 @@ heredoc_end(parser_state *p) p->parsing_heredoc = p->parsing_heredoc->cdr; if (p->parsing_heredoc == NULL) { p->lstate = EXPR_BEG; - p->cmd_start = TRUE; end_strterm(p); p->lex_strterm = p->lex_strterm_before_heredoc; p->lex_strterm_before_heredoc = NULL; @@ -2346,7 +2345,7 @@ opt_block_arg : comma block_arg ; comma : ',' - | ',' heredoc_bodies + | ',' opt_nl heredoc_bodies ; args : arg @@ -3709,24 +3708,28 @@ assocs : assoc $$ = list1($1); NODE_LINENO($$, $1); } - | assocs ',' assoc + | assocs comma assoc { $$ = push($1, $3); } ; +label_tag : tLABEL_TAG + | tLABEL_TAG heredoc_bodies + ; + assoc : arg tASSOC arg { void_expr_error(p, $1); void_expr_error(p, $3); $$ = cons($1, $3); } - | tIDENTIFIER tLABEL_TAG arg + | tIDENTIFIER label_tag arg { void_expr_error(p, $3); $$ = cons(new_sym(p, $1), $3); } - | string_fragment tLABEL_TAG arg + | string_fragment label_tag arg { void_expr_error(p, $3); if ($1->car == (node*)NODE_DSTR) { -- cgit v1.2.3