From 1dc0da821817ecfc8c87de5b13168b489e86d584 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 30 Oct 2019 10:03:42 +0900 Subject: Fix here-doc inside parens and brackets; fix #4796 --- mrbgems/mruby-compiler/core/parse.y | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index 6afc3f8fe..05262c60a 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -1620,7 +1620,7 @@ command_asgn : lhs '=' command_rhs { $$ = new_op_asgn(p, $1, $2, $3); } - | primary_value '[' opt_call_args rbracket tOP_ASGN command_rhs + | primary_value '[' opt_call_args ']' tOP_ASGN command_rhs { $$ = new_op_asgn(p, new_call(p, $1, intern("[]",2), $3, '.'), $5, $6); } @@ -1849,7 +1849,7 @@ mlhs_node : variable { assignable(p, $1); } - | primary_value '[' opt_call_args rbracket + | primary_value '[' opt_call_args ']' { $$ = new_call(p, $1, intern("[]",2), $3, '.'); } @@ -1888,7 +1888,7 @@ lhs : variable { assignable(p, $1); } - | primary_value '[' opt_call_args rbracket + | primary_value '[' opt_call_args ']' { $$ = new_call(p, $1, intern("[]",2), $3, '.'); } @@ -2028,7 +2028,7 @@ arg : lhs '=' arg_rhs { $$ = new_op_asgn(p, $1, $2, $3); } - | primary_value '[' opt_call_args rbracket tOP_ASGN arg_rhs + | primary_value '[' opt_call_args ']' tOP_ASGN arg_rhs { $$ = new_op_asgn(p, new_call(p, $1, intern("[]",2), $3, '.'), $5, $6); } @@ -2226,7 +2226,7 @@ arg_rhs : arg %prec tOP_ASGN } ; -paren_args : '(' opt_call_args rparen +paren_args : '(' opt_call_args ')' { $$ = $2; } @@ -2237,18 +2237,18 @@ opt_paren_args : none ; opt_call_args : none - | call_args - | args ',' + | call_args opt_terms + | args comma { $$ = cons($1,0); NODE_LINENO($$, $1); } - | args comma assocs ',' + | args comma assocs comma { $$ = cons(push($1, new_kw_hash(p, $3)), 0); NODE_LINENO($$, $1); } - | assocs ',' + | assocs comma { $$ = cons(list1(new_kw_hash(p, $1)), 0); NODE_LINENO($$, $1); @@ -2929,7 +2929,7 @@ method_call : operation paren_args { $$ = new_zsuper(p); } - | primary_value '[' opt_call_args rbracket + | primary_value '[' opt_call_args ']' { $$ = new_call(p, $1, intern("[]",2), $3, '.'); } @@ -3725,11 +3725,8 @@ opt_nl : /* none */ rparen : opt_nl ')' ; -rbracket : opt_nl ']' - ; - trailer : /* none */ - | nl + | terms | comma ; -- cgit v1.2.3