summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-compiler
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-04-14 23:47:40 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-10-12 16:21:18 +0900
commit6e86e290e4bd029e3ef53be6c4ac1d52e20538af (patch)
tree9e097d86686d54a9d73f9d00ce99e20f2791d4a3 /mrbgems/mruby-compiler
parentb2398879fa4d40f65703ca819d012af4a000bbb2 (diff)
downloadmruby-6e86e290e4bd029e3ef53be6c4ac1d52e20538af.tar.gz
mruby-6e86e290e4bd029e3ef53be6c4ac1d52e20538af.zip
Rightward-assign by ASSOC.
[ruby-bugs:15921]
Diffstat (limited to 'mrbgems/mruby-compiler')
-rw-r--r--mrbgems/mruby-compiler/core/parse.y23
1 files changed, 22 insertions, 1 deletions
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y
index c7c3d2a2f..73e928b20 100644
--- a/mrbgems/mruby-compiler/core/parse.y
+++ b/mrbgems/mruby-compiler/core/parse.y
@@ -1416,7 +1416,7 @@ heredoc_end(parser_state *p)
%type <nd> singleton string string_fragment string_rep string_interp xstring regexp
%type <nd> literal numeric cpath symbol
-%type <nd> top_compstmt top_stmts top_stmt
+%type <nd> top_compstmt top_stmts top_stmt rassign
%type <nd> bodystmt compstmt stmts stmt expr arg primary command command_call method_call
%type <nd> expr_value arg_rhs primary_value
%type <nd> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
@@ -1658,9 +1658,30 @@ stmt : keyword_alias fsym {p->lstate = EXPR_FNAME;} fsym
{
$$ = new_masgn(p, $1, new_array(p, $3));
}
+ | rassign
| expr
;
+rassign : arg tASSOC lhs
+ {
+ void_expr_error(p, $1);
+ $$ = new_asgn(p, $3, $1);
+ }
+ | arg tASSOC mlhs
+ {
+ void_expr_error(p, $1);
+ $$ = new_masgn(p, $3, $1);
+ }
+ | rassign tASSOC lhs
+ {
+ $$ = new_asgn(p, $3, $1);
+ }
+ | rassign tASSOC mlhs
+ {
+ $$ = new_masgn(p, $3, $1);
+ }
+ ;
+
command_asgn : lhs '=' command_rhs
{
$$ = new_asgn(p, $1, $3);