@@ -267,7 +267,7 @@ import static org.jruby.util.CommonByteLists.FWD_KWREST;
267267%type <DefHolder> def_name defn_head defs_head
268268%type <NodeExits> block_open k_while k_until k_for allow_exits
269269%type <@@prod_type@@> top_compstmt top_stmts top_stmt begin_block endless_arg endless_command
270- %type <@@prod_type@@> bodystmt compstmt stmts stmt_or_begin stmt expr arg primary command command_call method_call
270+ %type <@@prod_type@@> bodystmt compstmt stmts stmt_or_begin stmt expr arg primary command command_call command_call_value method_call
271271%type <@@prod_type@@> expr_value expr_value_do arg_value primary_value
272272%type <@@prod_type@@> rel_expr
273273%type <@@prod_fcall_type@@> fcall
@@ -673,9 +673,8 @@ stmt : keyword_alias fitem {
673673 /* % ripper: END!($4) %*/
674674 }
675675 | command_asgn
676- | mlhs ' =' lex_ctxt command_call {
676+ | mlhs ' =' lex_ctxt command_call_value {
677677 /* %%%*/
678- p.value_expr($4 );
679678 $$ = node_assign($1 , $4 , $3 );
680679 /* % %*/
681680 /* % ripper: massign!($1, $4) %*/
@@ -737,20 +736,33 @@ command_asgn : lhs '=' lex_ctxt command_rhs {
737736 /* % %*/
738737 /* % ripper: opassign!(field!($1, $2, $3), $4, $6) %*/
739738 }
739+ | primary_value tCOLON2 tIDENTIFIER tOP_ASGN lex_ctxt command_rhs {
740+ /* %%%*/
741+ p.value_expr($6 );
742+ $$ = p.new_attr_op_assign($1 , $2 , $3 , $4 , $6 );
743+ /* % %*/
744+ /* % ripper: opassign!(field!($1, ID2VAL(idCOLON2), $3), $4, $6) %*/
745+ }
740746 | primary_value tCOLON2 tCONSTANT tOP_ASGN lex_ctxt command_rhs {
741747 /* %%%*/
742748 int line = @1 .start();
743749 $$ = p.new_const_op_assign(line, p.new_colon2(line, $1 , $3 ), $4 , $6 , $5 );
744750 /* % %*/
745751 /* % ripper: opassign!(const_path_field!($1, $3), $4, $6) %*/
746752 }
747- | primary_value tCOLON2 tIDENTIFIER tOP_ASGN lex_ctxt command_rhs {
753+ | tCOLON3 tCONSTANT tOP_ASGN lex_ctxt command_rhs {
748754 /* %%%*/
749- p.value_expr( $6 );
750- $$ = p.new_attr_op_assign( $1 , $2 , $3 , $4 , $6 );
755+ Integer pos = p.src_line( );
756+ $$ = p.new_const_op_assign(pos, new Colon3Node(pos, p.symbolID( $2 )) , $3 , $5 , $4 );
751757 /* % %*/
752- /* % ripper: opassign!(field !($1, ID2VAL(idCOLON2 ), $3) , $4, $6 ) %*/
758+ /* % ripper: opassign!(top_const_field !($2 ), $3, $5 ) %*/
753759 }
760+ | backref tOP_ASGN lex_ctxt command_rhs {
761+ /* %%%*/
762+ p.backref_error($1 );
763+ /* % %*/
764+ /* % ripper[error]: backref_error(p, RNODE($1), assign!(var_field(p, $1), $4)) %*/
765+ };
754766 | defn_head f_opt_paren_args '=' endless_command {
755767 p.endless_method_name($1, @1);
756768 p.restore_defun($1);
@@ -769,12 +781,6 @@ command_asgn : lhs '=' lex_ctxt command_rhs {
769781 /* % %*/
770782 /* % ripper: defs!(AREF($1, 0), AREF($1, 1), AREF($1, 2), $2, bodystmt!($4, Qnil, Qnil, Qnil)) %*/
771783 p.popCurrentScope();
772- }
773- | backref tOP_ASGN lex_ctxt command_rhs {
774- /* %%%*/
775- p.backref_error($1 );
776- /* % %*/
777- /* % ripper[error]: backref_error(p, RNODE($1), assign!(var_field(p, $1), $4)) %*/
778784 };
779785
780786endless_command : command
@@ -786,15 +792,15 @@ endless_command : command
786792 /* % ripper: rescue_mod!($:1, $:4) %*/
787793 }
788794 | keyword_not opt_nl endless_command {
795+ /* %%%/
789796 $$ = p.call_uni_op(p.method_cond($3), NOT);
790797 /*% ripper: unary!(ID2VAL(idNOT), $:3) %*/
791798 };
792799
793- command_rhs : command_call %prec tOP_ASGN {
794- p.value_expr($1 );
800+ command_rhs : command_call_value %prec tOP_ASGN {
795801 $$ = $1 ;
796802 }
797- | command_call modifier_rescue after_rescue stmt {
803+ | command_call_value modifier_rescue after_rescue stmt {
798804 /* %%%*/
799805 p.getLexContext().in_rescue = $3 .in_rescue;
800806 p.value_expr($1 );
@@ -913,6 +919,11 @@ expr_value_do : {
913919command_call : command
914920 | block_command
915921
922+ command_call_value : command_call {
923+ p.value_expr($1 );
924+ $$ = $1 ;
925+ };
926+
916927// Node:block_command - A call with a block (foo.bar {...}, foo::bar {...}, bar {...}) [!null]
917928block_command : block_call
918929 | block_call call_op2 operation2 command_args {
@@ -1716,7 +1727,7 @@ arg : lhs '=' lex_ctxt arg_rhs {
17161727 $$ = node_assign($1 , $4 , $3 );
17171728 /* % %*/
17181729 /* % ripper: assign!($1, $4) %*/
1719- }
1730+ }
17201731 | var_lhs tOP_ASGN lex_ctxt arg_rhs {
17211732 /* %%%*/
17221733 $$ = p.new_op_assign($1 , $2 , $4 , $3 );
@@ -1902,13 +1913,6 @@ arg : lhs '=' lex_ctxt arg_rhs {
19021913 p.getLexContext().in_defined = false ;
19031914 $$ = p.new_defined(@1 .start(), $4 );
19041915 }
1905- | arg ' ?' arg opt_nl ' :' arg {
1906- /* %%%*/
1907- p.value_expr($1 );
1908- $$ = p.new_if(@1 .start(), $1 , $3 , $6 );
1909- /* % %*/
1910- /* % ripper: ifop!($1, $3, $6) %*/
1911- }
19121916 | defn_head f_opt_paren_args ' =' endless_arg {
19131917 p.endless_method_name($1 , @1 );
19141918 p.restore_defun($1 );
@@ -1930,10 +1934,18 @@ arg : lhs '=' lex_ctxt arg_rhs {
19301934 /* % ripper: defs!(AREF($1, 0), AREF($1, 1), AREF($1, 2), $2, bodystmt!($4, Qnil, Qnil, Qnil)) %*/
19311935 p.popCurrentScope();
19321936 }
1937+ | arg ' ?' arg opt_nl ' :' arg {
1938+ /* %%%*/
1939+ p.value_expr($1 );
1940+ $$ = p.new_if(@1 .start(), $1 , $3 , $6 );
1941+ /* % %*/
1942+ /* % ripper: ifop!($1, $3, $6) %*/
1943+ }
19331944 | primary {
19341945 $$ = $1 ;
19351946 };
19361947
1948+
19371949endless_arg : arg %prec modifier_rescue
19381950 | endless_arg modifier_rescue after_rescue arg {
19391951 p.getLexContext().in_rescue = $3 .in_rescue;
@@ -2073,6 +2085,27 @@ call_args : command {
20732085 /* % %*/
20742086 /* % ripper: args_add!(args_new!, $1) %*/
20752087 }
2088+ | defn_head f_opt_paren_args ' =' endless_command {
2089+ p.endless_method_name($1 , @1 );
2090+ p.restore_defun($1 );
2091+ /* %%%*/
2092+ $$ = new DefnNode($1 .line, $1 .name, $2 , p.getCurrentScope(), p.reduce_nodes(p.remove_begin($4 )), @4 .end());
2093+ if (p.isNextBreak) $<DefnNode>$.setContainsNextBreak ();
2094+ // Changed from MRI (combined two stmts)
2095+ /* % %*/
2096+ /* % ripper: def!(get_value($1), $2, bodystmt!($4, Qnil, Qnil, Qnil)) %*/
2097+ p.popCurrentScope();
2098+ }
2099+ | defs_head f_opt_paren_args ' =' endless_command {
2100+ p.endless_method_name($1 , @1 );
2101+ p.restore_defun($1 );
2102+ /* %%%*/
2103+ $$ = new DefsNode($1 .line, (Node) $1 .singleton, $1 .name, $2 , p.getCurrentScope(), p.reduce_nodes(p.remove_begin($4 )), @4 .end());
2104+ if (p.isNextBreak) $<DefsNode>$.setContainsNextBreak ();
2105+ /* % %*/
2106+ /* % ripper: defs!(AREF($1, 0), AREF($1, 1), AREF($1, 2), $2, bodystmt!($4, Qnil, Qnil, Qnil)) %*/
2107+ p.popCurrentScope();
2108+ }
20762109 | args opt_block_arg {
20772110 /* %%%*/
20782111 $$ = arg_blk_pass($1 , $2 );
0 commit comments