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

ruby-changes:49744

From: mame <ko1@a...>
Date: Tue, 16 Jan 2018 10:33:04 +0900 (JST)
Subject: [ruby-changes:49744] mame:r61861 (trunk): parse.y (symbol_append): Added to factor out `%i[]` and `%I[]`

mame	2018-01-16 10:32:58 +0900 (Tue, 16 Jan 2018)

  New Revision: 61861

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

  Log:
    parse.y (symbol_append): Added to factor out `%i[]` and `%I[]`

  Modified files:
    trunk/parse.y
Index: parse.y
===================================================================
--- parse.y	(revision 61860)
+++ parse.y	(revision 61861)
@@ -430,6 +430,8 @@ static NODE *new_regexp(struct parser_pa https://github.com/ruby/ruby/blob/trunk/parse.y#L430
 static NODE *new_xstring(struct parser_params *, NODE *, const YYLTYPE *loc);
 #define new_string1(str) (str)
 
+static NODE *symbol_append(struct parser_params *p, NODE *symbols, NODE *symbol);
+
 #define new_brace_body(param, stmt, loc) NEW_ITER(param, stmt, loc)
 #define new_do_body(param, stmt, loc) NEW_ITER(param, stmt, loc)
 
@@ -3593,15 +3595,7 @@ symbol_list	: /* none */ https://github.com/ruby/ruby/blob/trunk/parse.y#L3595
 		| symbol_list word ' '
 		    {
 		    /*%%%*/
-			$2 = evstr2dstr(p, $2);
-			if (nd_type($2) == NODE_DSTR) {
-			    nd_set_type($2, NODE_DSYM);
-			}
-			else {
-			    nd_set_type($2, NODE_LIT);
-			    add_mark_object(p, $2->nd_lit = rb_str_intern($2->nd_lit));
-			}
-			$$ = list_append(p, $1, $2);
+			$$ = symbol_append(p, $1, evstr2dstr(p, $2));
 		    /*%
 			$$ = dispatch2(symbols_add, $1, $2);
 		    %*/
@@ -3658,12 +3652,8 @@ qsym_list	: /* none */ https://github.com/ruby/ruby/blob/trunk/parse.y#L3652
 		| qsym_list tSTRING_CONTENT ' '
 		    {
 		    /*%%%*/
-			VALUE lit;
-			lit = $2->nd_lit;
-			nd_set_type($2, NODE_LIT);
-			add_mark_object(p, $2->nd_lit = ID2SYM(rb_intern_str(lit)));
 			nd_set_loc($2, &@2);
-			$$ = list_append(p, $1, $2);
+			$$ = symbol_append(p, $1, $2);
 		    /*%
 			$$ = dispatch2(qsymbols_add, $1, $2);
 		    %*/
@@ -8958,6 +8948,19 @@ new_defined(struct parser_params *p, NOD https://github.com/ruby/ruby/blob/trunk/parse.y#L8948
     return NEW_DEFINED(remove_begin_all(expr), loc);
 }
 
+static NODE*
+symbol_append(struct parser_params *p, NODE *symbols, NODE *symbol)
+{
+    if (nd_type(symbol) == NODE_DSTR) {
+	nd_set_type(symbol, NODE_DSYM);
+    }
+    else {
+	nd_set_type(symbol, NODE_LIT);
+	symbol->nd_lit = add_mark_object(p, rb_str_intern(symbol->nd_lit));
+    }
+    return list_append(p, symbols, symbol);
+}
+
 static NODE *
 new_regexp(struct parser_params *p, NODE *node, int options, const YYLTYPE *loc)
 {

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

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