ruby-changes:49861
From: mame <ko1@a...>
Date: Sat, 20 Jan 2018 15:11:29 +0900 (JST)
Subject: [ruby-changes:49861] mame:r61979 (trunk): parse.y: Remove unneeded var_field_1 trick
mame 2018-01-20 15:11:21 +0900 (Sat, 20 Jan 2018) New Revision: 61979 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61979 Log: parse.y: Remove unneeded var_field_1 trick I thought this trick was needed because the result of var_field was passed to different arguments, as follows: ``` $1 = var_field(p, $1); $$ = backref_assign_error(p, $1, $1, &@$); ``` Currently the DSL supports that one result is passed to one argument. However, after the refactoring, I found that `backref_assign_error` uses only one `$1`. Modified files: trunk/ext/ripper/tools/dsl.rb trunk/parse.y Index: ext/ripper/tools/dsl.rb =================================================================== --- ext/ripper/tools/dsl.rb (revision 61978) +++ ext/ripper/tools/dsl.rb (revision 61979) @@ -9,7 +9,6 @@ class DSL https://github.com/ruby/ruby/blob/trunk/ext/ripper/tools/dsl.rb#L9 @error = options.include?("error") @brace = options.include?("brace") @final = options.include?("final") - @var_field_1 = options.include?("var_field_1") # create $1 == "$1", $2 == "$2", ... re, s = "", "" @@ -37,7 +36,6 @@ class DSL https://github.com/ruby/ruby/blob/trunk/ext/ripper/tools/dsl.rb#L36 s = "#{ s } = #@code;" s << "ripper_error(p);" if @error s = "{#{ s }}" if @brace - s = "$1 = var_field(p, $1);" + s if @var_field_1 "\t\t\t#{s}" end Index: parse.y =================================================================== --- parse.y (revision 61978) +++ parse.y (revision 61979) @@ -1260,7 +1260,7 @@ command_asgn : lhs '=' command_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L1260 rb_backref_error(p, $1); $$ = NEW_BEGIN(0, &@$); /*% %*/ - /*% ripper[var_field_1,error]: assign_error!(assign!($1, $3)) %*/ + /*% ripper[error]: assign_error!(assign!(var_field(p, $1), $3)) %*/ } ; @@ -1559,14 +1559,14 @@ mlhs_node : user_variable https://github.com/ruby/ruby/blob/trunk/parse.y#L1559 /*%%%*/ $$ = assignable(p, $1, 0, &@$); /*% %*/ - /*% ripper[var_field_1]: assignable(p, $1) %*/ + /*% ripper: assignable(p, var_field(p, $1)) %*/ } | keyword_variable { /*%%%*/ $$ = assignable(p, $1, 0, &@$); /*% %*/ - /*% ripper[var_field_1]: assignable(p, $1) %*/ + /*% ripper: assignable(p, var_field(p, $1)) %*/ } | primary_value '[' opt_call_args rbracket { @@ -1610,7 +1610,7 @@ mlhs_node : user_variable https://github.com/ruby/ruby/blob/trunk/parse.y#L1610 rb_backref_error(p, $1); $$ = NEW_BEGIN(0, &@$); /*% %*/ - /*% ripper[var_field_1,error]: assign_error!($1) %*/ + /*% ripper[error]: assign_error!(var_field(p, $1)) %*/ } ; @@ -1619,14 +1619,14 @@ lhs : user_variable https://github.com/ruby/ruby/blob/trunk/parse.y#L1619 /*%%%*/ $$ = assignable(p, $1, 0, &@$); /*% %*/ - /*% ripper[var_field_1]: assignable(p, $1) %*/ + /*% ripper: assignable(p, var_field(p, $1)) %*/ } | keyword_variable { /*%%%*/ $$ = assignable(p, $1, 0, &@$); /*% %*/ - /*% ripper[var_field_1]: assignable(p, $1) %*/ + /*% ripper: assignable(p, var_field(p, $1)) %*/ } | primary_value '[' opt_call_args rbracket { @@ -1670,7 +1670,7 @@ lhs : user_variable https://github.com/ruby/ruby/blob/trunk/parse.y#L1670 rb_backref_error(p, $1); $$ = NEW_BEGIN(0, &@$); /*% %*/ - /*% ripper[var_field_1,error]: assign_error!($1) %*/ + /*% ripper[error]: assign_error!(var_field(p, $1)) %*/ } ; @@ -1849,7 +1849,7 @@ arg : lhs '=' arg_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L1849 rb_backref_error(p, $1); $$ = NEW_BEGIN(0, &@$); /*% %*/ - /*% ripper[var_field_1,error]: assign_error!(opassign!($1, $2, $3)) %*/ + /*% ripper[error]: assign_error!(opassign!(var_field(p, $1), $2, $3)) %*/ } | arg tDOT2 arg { @@ -3675,14 +3675,14 @@ var_lhs : user_variable https://github.com/ruby/ruby/blob/trunk/parse.y#L3675 /*%%%*/ $$ = assignable(p, $1, 0, &@$); /*% %*/ - /*% ripper[var_field_1]: assignable(p, $1) %*/ + /*% ripper: assignable(p, var_field(p, $1)) %*/ } | keyword_variable { /*%%%*/ $$ = assignable(p, $1, 0, &@$); /*% %*/ - /*% ripper[var_field_1]: assignable(p, $1) %*/ + /*% ripper: assignable(p, var_field(p, $1)) %*/ } ; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/