[前][次][番号順一覧][スレッド一覧]

ruby-changes:45503

From: nobu <ko1@a...>
Date: Wed, 8 Feb 2017 16:06:44 +0900 (JST)
Subject: [ruby-changes:45503] nobu:r57576 (trunk): parse.y: named caputre into match_op_gen

nobu	2017-02-08 16:06:37 +0900 (Wed, 08 Feb 2017)

  New Revision: 57576

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57576

  Log:
    parse.y: named caputre into match_op_gen
    
    * parse.y (match_op_gen): move making named capture assignment
      nodes.  remove repeated conditions.

  Modified files:
    trunk/parse.y
Index: parse.y
===================================================================
--- parse.y	(revision 57575)
+++ parse.y	(revision 57576)
@@ -2259,12 +2259,6 @@ arg		: lhs '=' arg_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L2259
 		    {
 		    /*%%%*/
 			$$ = match_op($1, $3);
-			if (nd_type($1) == NODE_LIT) {
-			    VALUE lit = $1->nd_lit;
-			    if (RB_TYPE_P(lit, T_REGEXP)) {
-				$$->nd_args = reg_named_capture_assign(lit);
-			    }
-			}
 		    /*%
 			$$ = dispatch3(binary, $1, ID2SYM(idEqTilde), $3);
 		    %*/
@@ -8975,7 +8969,10 @@ match_op_gen(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L8969
 
 	  case NODE_LIT:
 	    if (RB_TYPE_P(node1->nd_lit, T_REGEXP)) {
-		return NEW_MATCH2(node1, node2);
+		const VALUE lit = node1->nd_lit;
+		NODE *match = NEW_MATCH2(node1, node2);
+		match->nd_args = reg_named_capture_assign(lit);
+		return match;
 	    }
 	}
     }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]